From: nadir Date: Fri, 29 Aug 2003 12:08:49 +0000 (+0000) Subject: update from the MedMemory V1.0.1 X-Git-Tag: V1_0_1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=211c851d80b87846294d5e7dd43e4af2ab282d35;p=modules%2Fmed.git update from the MedMemory V1.0.1 --- diff --git a/idl/MED.idl b/idl/MED.idl index d282c81f5..36dec0a32 100644 --- a/idl/MED.idl +++ b/idl/MED.idl @@ -39,49 +39,44 @@ module SALOME_MED { 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 @@ -135,7 +130,7 @@ module SALOME_MED { - "CYLINDRICAL" - "SPHERICAL" */ - string getCoordinateSystem() raises (SALOME::SALOME_Exception); + string getCoordinatesSystem() raises (SALOME::SALOME_Exception); /*! Returns the number of nodes defined in mesh. @@ -456,7 +451,10 @@ module SALOME_MED { /*! 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. */ diff --git a/src/MEDMEM/INTERPOLATION/MEDMEM_Interpolation.hxx b/src/MEDMEM/INTERPOLATION/MEDMEM_Interpolation.hxx new file mode 100644 index 000000000..9ea924aed --- /dev/null +++ b/src/MEDMEM/INTERPOLATION/MEDMEM_Interpolation.hxx @@ -0,0 +1,286 @@ +# 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 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 class INTERPOLATION +{ +protected: + + FIELD * _fromField; + FIELD * _toField; + MESH * _fromMesh; + MESH * _toMesh; + + Meta_Wrapper * _fromWrapper; + Meta_Wrapper * _toWrapper; + + Meta_Mapping * _mapping; + +public : + + void init(); + + // Initialize INTERPOLATION in order to get : + // 1- the node number in the MESH which + // is the nearest from a given one ( use method : getNearestNode( double * node ) ); + // 2- the cell number (if exists) in the MESH 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 on + // Moreover, all the others functionalities are so available + INTERPOLATION(const FIELD & fromField, const MESH & toMesh); + + ~INTERPOLATION( ); + + // Get the node number in the MESH which is the nearest from a given one + int getNearestNode ( double * node ); + // Get the cell number (if exists) in the MESH 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 getMapping ( int flagIsConvexMesh=0 ); + // Get the interpolated field toField + FIELD * interpolate( /*med_interpolation_type*/ int itype,int flagIsConvexFromMesh=0); + +}; + + +template void INTERPOLATION::init() { + + const char * LOC = "INTERPOLATION::init(): "; + + BEGIN_OF(LOC); + _fromField = ( FIELD * ) NULL; + _toField = ( FIELD * ) NULL; + _fromMesh = ( MESH * ) NULL; + _toMesh = ( MESH * ) NULL; + _fromWrapper = ( Meta_Wrapper * ) NULL; + _toWrapper = ( Meta_Wrapper * ) NULL; + _mapping = ( Meta_Mapping * ) NULL; + END_OF(LOC); +} + + +template INTERPOLATION::INTERPOLATION(const MESH & fromMesh ) { + + const char * LOC = "INTERPOLATION::INTERPOLATION(MESH * fromMesh ) : "; + BEGIN_OF(LOC); + + init(); + + _fromMesh=const_cast (&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(_fromMesh->getNumberOfNodes(), + const_cast (_fromMesh->getCoordinates(MED_FULL_INTERLACE)), + const_cast (_fromMesh->getConnectivityptr()) + ); + + _mapping = new Meta_Mapping (_fromWrapper); + + END_OF(LOC); +}; + +template INTERPOLATION::INTERPOLATION(const MESH & fromMesh,const MESH & toMesh ) { + + const char * LOC = "INTERPOLATION::INTERPOLATION(MESH * fromMesh,,const MESH & toMesh) : "; + BEGIN_OF(LOC); + + init(); + + _fromMesh = const_cast ( &fromMesh ); + _toMesh = const_cast ( &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(_fromMesh->getNumberOfNodes(), + const_cast (_fromMesh->getCoordinates(MED_FULL_INTERLACE)), + const_cast (_fromMesh->getConnectivityptr()) + ); + + _toWrapper = new Meta_Wrapper(_toMesh->getNumberOfNodes(), + const_cast (_toMesh->getCoordinates(MED_FULL_INTERLACE)) + ); + + _mapping = new Meta_Mapping (_fromWrapper); + + END_OF(LOC); +}; + +template INTERPOLATION::INTERPOLATION(const FIELD & fromField,const MESH & toMesh) { + + const char * LOC = "INTERPOLATION::INTERPOLATION(const FIELD & field,const MESH & toMesh) : "; + BEGIN_OF(LOC); + + init(); + + _toMesh = const_cast(&toMesh); + _fromField = const_cast *>(&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(_fromMesh->getNumberOfNodes(), + const_cast (_fromMesh->getCoordinates(MED_FULL_INTERLACE)), + const_cast (_fromMesh->getConnectivityptr()), + const_cast *>(_fromField) + ); + + _toWrapper = new Meta_Wrapper(_toMesh->getNumberOfNodes(), + const_cast (_toMesh->getCoordinates(MED_FULL_INTERLACE)) + ); + + _mapping = new Meta_Mapping (_fromWrapper); + + END_OF(LOC); +}; + +template INTERPOLATION::~INTERPOLATION() +{ + if ( _fromWrapper ) delete _fromWrapper ; + if ( _toWrapper ) delete _toWrapper ; + if ( _mapping ) delete _mapping ; +}; + +template int INTERPOLATION::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 (node) ); + + END_OF(LOC); + +}; + +template int INTERPOLATION::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 vector INTERPOLATION::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 FIELD * INTERPOLATION::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 * toNodes = _toWrapper->Get_Nuage_Noeuds(); + + Wrapper_MED_Field resultat; + +cout<<"On commence l'interpolation"<; + + _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 + + diff --git a/src/MEDMEM/INTERPOLATION/MEDMEM_InterpolationHighLevelObjects.hxx b/src/MEDMEM/INTERPOLATION/MEDMEM_InterpolationHighLevelObjects.hxx new file mode 100644 index 000000000..ece92a5f6 --- /dev/null +++ b/src/MEDMEM/INTERPOLATION/MEDMEM_InterpolationHighLevelObjects.hxx @@ -0,0 +1,409 @@ +#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 class Meta_Wrapper; + +/*********************************************************/ +/* */ +/* Meta_dTree */ +/* */ +/*********************************************************/ + +template class Meta_dTree : public dTree,Wrapper_Nuage_Noeud,DIMENSION> +{ +public : + inline int trouve_plus_proche_point(double *node); +}; + +/*********************************************************/ +/* */ +/* Meta_Nuage_Maille */ +/* */ +/*********************************************************/ + + +class Meta_Nuage_Maille : public Wrapper_Nuage_Maille +{ +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_Maillage; + +/*********************************************************/ +/* */ +/* Meta_Mapping */ +/* */ +/*********************************************************/ + +template class Meta_Mapping : public Mapping,Wrapper_Noeud,DIMENSION> +{ +public : + Meta_Mapping(Meta_Wrapper * MW):Mapping,Wrapper_Noeud,DIMENSION>(MW->Get_Maillage(),MW->Get_Nuage_Noeuds(),NULL) {} + Meta_Mapping(Meta_Wrapper * MW,Meta_Wrapper * TWB):Mapping,Wrapper_Noeud,DIMENSION>(MW->Get_Maillage(),MW->Get_Nuage_Noeuds(),TWB->Get_Nuage_Noeuds()) {} + void Cree_Mapping(Meta_Wrapper * MWB, int flag_convexe) {Mapping,Wrapper_Noeud,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 class Meta_Wrapper +{ +protected : + Wrapper_Nuage_Noeud * 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 * 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 * c,int flag_mesh=1); + // fonctions d'acces sures + inline Wrapper_Nuage_Noeud * 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 class Meta_Calcul_Interpolation_Hybride : public Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille> +{ +public : + Meta_Calcul_Interpolation_Hybride(Meta_Wrapper * MW):Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(MW->Get_Nuage_Noeuds(),MW->Get_Nuage_Mailles(),MW->Get_Champ()) {} + Valeur operator() (Wrapper_Noeud & node, int num_maille){return Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>::operator()(node,num_maille);} + Valeur operator() (double * node, int num_maille) + { + static Wrapper_Noeud tmp; + tmp.positionne(node); + return Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(tmp,num_maille); + } +}; + +/*********************************************************/ +/* */ +/* Meta_Calcul_Interpolation_Hybride_P1 */ +/* */ +/*********************************************************/ + +template class Meta_Calcul_Interpolation_Hybride_P1 : public Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille> +{ +public : + Meta_Calcul_Interpolation_Hybride_P1(Meta_Wrapper * MW) + { + + Wrapper_Nuage_Noeud * 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_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_QUAD4 ]=new Calcul_Interpolation_Quad4 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_TETRA4 ]=new Calcul_Interpolation_Tetra4 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_HEXA8 ]=new Calcul_Interpolation_Hexa8 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_PENTA6 ]=new Calcul_Interpolation_Penta6 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_PYRA5 ]=new Calcul_Interpolation_Pyra5 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,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 operator() (Wrapper_Noeud & node, int num_maille){return Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>::operator()(node,num_maille);} + Valeur operator() (double * node, int num_maille) + { + static Wrapper_Noeud tmp; + tmp.positionne(node); + return Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(tmp,num_maille); + } +}; + +/*********************************************************/ +/* */ +/* Meta_Calcul_Interpolation_P0 */ +/* */ +/*********************************************************/ + +template class Meta_Calcul_Interpolation_P0 : public Calcul_Interpolation_P0,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille> +{ +public : + Meta_Calcul_Interpolation_P0(Meta_Wrapper * MW):Calcul_Interpolation_P0,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(MW->Get_Nuage_Noeuds(),MW->Get_Nuage_Mailles(),MW->Get_Champ()) {} + Valeur operator() (Wrapper_Noeud & node, int num_maille){return Calcul_Interpolation_P0,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>::operator()(node,num_maille);} + Valeur operator() (double * node, int num_maille) + { + static Wrapper_Noeud tmp; + tmp.positionne(node); + return Calcul_Interpolation_P0,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(tmp,num_maille); + } +}; + +/*********************************************************/ +/* */ +/* Meta_Interpolateur */ +/* */ +/*********************************************************/ + +template class Meta_Interpolateur +{ +protected : + FONCTEUR * fct; + Meta_Mapping * mapping; + Meta_Wrapper * fromWrapper; +public : + Meta_Interpolateur():fct(NULL),mapping(NULL),fromWrapper(NULL) {} + Meta_Interpolateur(Meta_Mapping * map, Meta_Wrapper * mw):mapping(map),fromWrapper(mw),fct(new FONCTEUR(mw)){} + ~Meta_Interpolateur() {if (fct) delete fct;} + Wrapper_MED_Field Perform_Interpolation(Wrapper_Nuage_Noeud * 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 OK ! "< inline int Meta_dTree::trouve_plus_proche_point(double *node) + { + static Wrapper_Noeud nodetmp; + nodetmp.positionne(node); + return dTree,Wrapper_Nuage_Noeud,DIMENSION>::trouve_plus_proche_point(Wrapper_Noeud(nodetmp)); + } + +/*********************************************************/ +/* */ +/* Meta_Nuage_Maille */ +/* */ +/*********************************************************/ + +Meta_Nuage_Maille::Meta_Nuage_Maille(CONNECTIVITY * conmed):Wrapper_Nuage_Maille(connectivite_med=new Wrapper_Med_Connectivity(conmed)) + { + } + +/*********************************************************/ +/* */ +/* Meta_Mapping */ +/* */ +/*********************************************************/ + +template inline int Meta_Mapping::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 nodetmp; + nodetmp.positionne(node); + return Mapping,Wrapper_Noeud,DIMENSION>::Trouve_Maille_Contenant_Point_Mth_Co(nodetmp,num_maille,interdit,max_loop,nme,flag_convexe); + } + +/*********************************************************/ +/* */ +/* Meta_Wrapper */ +/* */ +/*********************************************************/ + +template Meta_Wrapper::~Meta_Wrapper() + { + if ( noeuds ) delete noeuds ; + if ( mailles ) delete mailles ; + if ( maillage ) delete maillage ; + if ( champ ) delete champ ; + } +template inline void Meta_Wrapper::Construit_Wrapper_Nuage_Noeud ( int nn, double * nodes ) + { + if (nodes) noeuds=new Wrapper_Nuage_Noeud(nn,nodes); + else + { + cerr<<"Meta_Wrapper : Nuage MED_FULL_INTERLACE vide passé en argument au constructeur"< inline void Meta_Wrapper::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"< inline void Meta_Wrapper::Construit_Wrapper_Maillage ( void ) + { + if (mailles==NULL) + { + cerr<<"Meta_Wrapper : Le nuage de maille n'a pas été initialisé !"<SIZE()); + } +template inline void Meta_Wrapper::Construit_Wrapper_Champ ( const FIELD * medfield ) + { + if (medfield) champ=new Wrapper_MED_Field(medfield); + else + { + cerr<<"Meta_Wrapper : FIELD MED vide passé en argument au constructeur"< Meta_Wrapper::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 Meta_Wrapper::Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, const FIELD * 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 Meta_Wrapper::Meta_Wrapper(int nn,double *nodes) + { + init(); + Construit_Wrapper_Nuage_Noeud(nn,nodes); + } +template inline Wrapper_Nuage_Noeud * Meta_Wrapper::Get_Nuage_Noeuds ( void ) + { + if (noeuds) return noeuds; + else + { + cerr<<"Meta_Wrapper : Nuage noeuds demandé alors qu'il n'est pas construit !"< inline Meta_Nuage_Maille * Meta_Wrapper::Get_Nuage_Mailles ( void ) + { + if (mailles) return mailles ; + else + { + cerr<<"Meta_Wrapper : Nuage mailles demandé alors qu'il n'est pas construit !"< inline Meta_Maillage * Meta_Wrapper::Get_Maillage ( void ) + { + if (maillage) return maillage ; + else + { + cerr<<"Meta_Wrapper : Connectivitée maillage demandée alors qu'elle n'est pas construite !"< inline Wrapper_MED_Field * Meta_Wrapper::Get_Champ ( void ) + { + if (champ) return champ; + else + { + cerr<<"Meta_Wrapper : Champ demandé alors qu'il n'est pas construit !"< class Meta_dTree : public dTree,Wrapper_Nuage_Noeud,DIMENSION> +{ +protected : + Wrapper_Nuage_Noeud * 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 +{ +protected : + Wrapper_Med_Connectivity * connectivite_med; +public : + Meta_Nuage_Maille(CONNECTIVITY * connmed); + Meta_Nuage_Maille():Wrapper_Nuage_Maille(connectivite_med=new Wrapper_Med_Connectivity) {} + ~Meta_Nuage_Maille() {if (connectivite_med) delete connectivite_med;} +}; + + +typedef Wrapper_Maillage Meta_Maillage; + +template class Meta_Mapping : public Mapping,Wrapper_Noeud,DIMENSION> +{ +protected : + Wrapper_Nuage_Noeud * wrapping_nuage_source; + Wrapper_Nuage_Noeud * 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 vals); +}; + +// CODE + +template Meta_dTree::Meta_dTree(int nn,double * fullinterlace) +:dTree,Wrapper_Nuage_Noeud,DIMENSION> +(nuagetmp=new Wrapper_Nuage_Noeud(nn,fullinterlace)) + { + } + +template inline int Meta_dTree::trouve_plus_proche_point(double *node) + { + static Wrapper_Noeud nodetmp; + nodetmp.positionne(node); + return dTree,Wrapper_Nuage_Noeud,DIMENSION>::trouve_plus_proche_point(Wrapper_Noeud(nodetmp)); + } + +//* +Meta_Nuage_Maille::Meta_Nuage_Maille(CONNECTIVITY * conmed):Wrapper_Nuage_Maille(connectivite_med=new Wrapper_Med_Connectivity(conmed)) + { + } +//*/ + +template Meta_Mapping::Meta_Mapping(Meta_Maillage * mb,double * noeudssource,int ns,double * noeudscible,int nc) +:Mapping,Wrapper_Noeud,DIMENSION> +(mb, +wrapping_nuage_source=new Wrapper_Nuage_Noeud(ns,noeudssource), +wrapping_nuage_cible=new Wrapper_Nuage_Noeud(nc,noeudscible)) + { + } + +template inline int Meta_Mapping::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 nodetmp; + nodetmp.positionne(node); + return Mapping,Wrapper_Noeud,DIMENSION>::Trouve_Maille_Contenant_Point_Mth_Co(nodetmp,num_maille,interdit,max_loop,nme,flag_convexe); + } +template double Meta_Mapping::donne_valeur_interpolee_P1(double * node,vector vals) + { + int num_maille_contenant=Trouve_Maille_Contenant_Noeud(node,0); + double valeur_interpol=0; + vector valeurs=CB->Calcule_Coord_Baryc(num_maille_contenant,node); + int i; + int num_som; + for (i=0;i +#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)"< *> 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 ( "< +{ +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 ( "< +{ +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"< +{ +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"< +{ +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"< +{ +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"< +#define _MAPPING_ Mapping + + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Classe Mapping */ +/* */ +/*********************************************************/ + +// ATTENTION LE NUAGE DE NOEUD EST SUPPOSE NON REDONDANT ET AUCUNE VERIFICATION N'EST FAITE ! + +template class Mapping +{ +protected : + MAILLAGE * maillage_back; + NUAGEMAILLE * mailles_back; + NUAGENOEUD * noeuds_back; + NUAGENOEUD * noeuds_front; + Coordonnees_Barycentriques * CB; + dTree * my_dTree; + vector resultat_mapping; + vector 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 * 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 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 !"<SIZE(); + int num_maille_depart; + int nma=0; + resultat_mapping = vector(nbr_noeuds,UNDEFINED); + point_le_plus_proche = vector(nbr_noeuds,UNDEFINED); + noeuds_back->affiche(); + + for (i=0;itrouve_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"<DONNE_POINTEUR_NUAGEMAILLE(); + + CB=new Coordonnees_Barycentriques(mailles_back,noeuds_back); + + cout<<"MAPPING : VERIFICATION REDONDANCES DANS NUAGE NOEUD BACK"<SIZE(); + + vector redondance(nnb,0); + + for (i=0;i(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 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;iDONNE_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;iDONNE_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;(iDONNE_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 diff --git a/src/MEDMEM/INTERPOLATION/MEDMEM_MappingTools.hxx b/src/MEDMEM/INTERPOLATION/MEDMEM_MappingTools.hxx new file mode 100644 index 000000000..1781c4213 --- /dev/null +++ b/src/MEDMEM/INTERPOLATION/MEDMEM_MappingTools.hxx @@ -0,0 +1,199 @@ +#ifndef COORDONNEES_BARYCENTRIQUES_HPP +#define COORDONNEES_BARYCENTRIQUES_HPP + +// DECLARATIONS + +#define _TEMPL_SPE_ template +#define _COORDBARYC_ Coordonnees_Barycentriques +#define _COORDBARY_2D_ Coordonnees_Barycentriques +#define _COORDBARY_3D_ Coordonnees_Barycentriques + +template class Coordonnees_Barycentriques +{ +// TEMPLATE GENERIQUE VIDE OBLIGE DE PASSER PAR UNE SPECIALISATION +}; + +_TEMPL_SPE_ class _COORDBARY_2D_ +{ +protected : + NUAGEMAILLE * mailles; + NUAGENOEUD * sommets; + + vector etat_coord_baryc; + vector< vector< vector > > coord_baryc; + +public : + + Coordonnees_Barycentriques():mailles(NULL),sommets(NULL) {} + Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n); + ~Coordonnees_Barycentriques() {} + vector Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M); + vector Calcule_Base_Coord_Baryc(const vector &simplexe_base); + vector Calcule_Coord_Baryc(int num_maille, const NOEUD & M); +}; + +_TEMPL_SPE_ class _COORDBARY_3D_ +{ +protected : + NUAGEMAILLE * mailles; + NUAGENOEUD * sommets; + + vector etat_coord_baryc; + vector< vector< vector > > coord_baryc; + +public : + + Coordonnees_Barycentriques():mailles(NULL),sommets(NULL) {} + Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n); + ~Coordonnees_Barycentriques() {} + vector Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M); + vector Calcule_Base_Coord_Baryc(const vector &simplexe_base); + vector 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 : "<SIZE(); + etat_coord_baryc=vector(nbr_mailles,FAUX); + coord_baryc=vector< vector< vector > >(nbr_mailles); + cout<<"OK ! "< _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 >(nbr_faces); + + for (i=0;i 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 _COORDBARY_2D_::Calcule_Base_Coord_Baryc(const vector &simplexe_base) + { + const vector &ref=simplexe_base; + vector 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 _COORDBARY_2D_::Calcule_Coord_Baryc(int num_maille, const NOEUD & M) + { + int i,j; + vector 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 : "<SIZE(); + etat_coord_baryc=vector(nbr_mailles,FAUX); + coord_baryc=vector< vector< vector > >(nbr_mailles); + cout<<"OK ! "< _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 >(nbr_faces); + + for (i=0;i 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 _COORDBARY_3D_::Calcule_Base_Coord_Baryc(const vector &simplexe_base) + { + const vector &ref=simplexe_base; + vector 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 _COORDBARY_3D_::Calcule_Coord_Baryc(int num_maille, const NOEUD & M) + { + int i,j; + int nbr_faces=coord_baryc[num_maille].size(); + vector coord_baryc_M(nbr_faces,0); + for (i=0;i +#undef _COORDBARYC_2D_ Coordonnees_Barycentriques +#undef _COORDBARYC_3D_ Coordonnees_Barycentriques + +#endif diff --git a/src/MEDMEM/INTERPOLATION/MEDMEM_WrapperCells.hxx b/src/MEDMEM/INTERPOLATION/MEDMEM_WrapperCells.hxx new file mode 100644 index 000000000..f694a4565 --- /dev/null +++ b/src/MEDMEM/INTERPOLATION/MEDMEM_WrapperCells.hxx @@ -0,0 +1,887 @@ +#ifndef WRAPPERS_CELLS_HXX +#define WRAPPERS_CELLS_HXX + +#include "stdio.h" +#include "stdlib.h" + +#include + +#include +#include + +#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 &v1,const vector &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"< EXIT"< DONNE_SIMPLEXE_BASE(int num_face) const {cerr<<"APPEL D'UNE FONCTION VIRTUELLE DE LA CLASSE MERE WRAPPER_MAILLE => EXIT"< DONNE_FACE(int num_face) const {cerr<<"APPEL D'UNE FONCTION VIRTUELLE DE LA CLASSE MERE WRAPPER_MAILLE => EXIT"< EXIT"< contenu; +public : + ~Type_Wrapper_Maille(); + Type_Wrapper_Maille(); + inline Wrapper_Maille * operator[] (int i) {return contenu[i];} +}; + +/*********************************************************/ +/* */ +/* Classe Wrapper_Nuage_Maille */ +/* */ +/*********************************************************/ + +template class Wrapper_Nuage_Maille +{ +protected : + FORME_SKYLINE * mailles; + Type_Wrapper_Maille show; + int nbr_mailles; + vector 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 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 DONNE_FACE(int num_maille,int num_local_formant); + inline int DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(int num_maille_sec,const vector &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 &v1,const vector &v2) + { + int s1=v1.size(); + int s2=v2.size(); + if (s1!=s2) return FAUX; + int i1,i2; + int test; + for (i1=0;i1 Wrapper_Nuage_Maille::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;iDONNE_TYPE_MAILLE(i); + premier_pointeur[i]=mailles->DONNE_PREMIER_POINTEUR(i); + } + show[types[0]]->positionne(premier_pointeur[0]); + } +template const Wrapper_Maille & Wrapper_Nuage_Maille::operator[](int i) + { + return show[types[i]]->positionne(premier_pointeur[i]); + } +template inline int Wrapper_Nuage_Maille::DONNE_SOMMET_MAILLE(int num_maille,int num_som) + { + return (*this)[num_maille][num_som]; + } + +template inline int Wrapper_Nuage_Maille::DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(int num_maille,const vector &sommets_face) + { + vector face_loc; + int num_face; + int test=FAUX; + for (num_face=0;num_face int Wrapper_Nuage_Maille::DONNE_NBR_NOEUDS(int num_maille) + { + return (*this)[num_maille].DONNE_NBR_NOEUDS(); + } +template int Wrapper_Nuage_Maille::DONNE_NBR_FACES(int num_maille) + { + return (*this)[num_maille].DONNE_NBR_FACES(); + } +template vector Wrapper_Nuage_Maille::DONNE_SIMPLEXE_BASE(int num_maille,int num_face) + { + return (*this)[num_maille].DONNE_SIMPLEXE_BASE(num_face); + } +template vector Wrapper_Nuage_Maille::DONNE_FACE(int num_maille,int num_face) + { + return (*this)[num_maille].DONNE_FACE(num_face); + } +template int Wrapper_Nuage_Maille::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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 DONNE_FACE(int num_face) const + { + vector 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 DONNE_SIMPLEXE_BASE(int num_face) const + { + vector 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 diff --git a/src/MEDMEM/INTERPOLATION/MEDMEM_WrapperConnectivity.hxx b/src/MEDMEM/INTERPOLATION/MEDMEM_WrapperConnectivity.hxx new file mode 100644 index 000000000..439864aa7 --- /dev/null +++ b/src/MEDMEM/INTERPOLATION/MEDMEM_WrapperConnectivity.hxx @@ -0,0 +1,61 @@ +#ifndef MEDMEM_WRAPPER_CONNECTIVITY_HXX +#define MEDMEM_WRAPPER_CONNECTIVITY_HXX + +#include "MEDMEM_Connectivity.hxx" + +#include + +////////////////////////////////////////////////////////////////// +/// /// +/// 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 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;igetElementType(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 diff --git a/src/MEDMEM/INTERPOLATION/MEDMEM_WrapperField.hxx b/src/MEDMEM/INTERPOLATION/MEDMEM_WrapperField.hxx new file mode 100644 index 000000000..c345d4d26 --- /dev/null +++ b/src/MEDMEM/INTERPOLATION/MEDMEM_WrapperField.hxx @@ -0,0 +1,201 @@ +#ifndef MEDMEM_WRAPPER_FIELD_HXX +#define MEDMEM_WRAPPER_FIELD_HXX + +#include "MEDMEM_Field.hxx" + +#include + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS ET CODE /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Template Arithmétiques de Valdhuizen */ +/* */ +/*********************************************************/ + +template 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 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 struct X +{ + double left; + Right right; + X(double l,Right r):left(l),right(r){} + double operator[](int i) + { + return Multiply::apply(left,right[i]); + } +}; + +template X< Valeur,Plus,Valeur > operator+(Valeur v1,Valeur v2) +{ +return X< Valeur,Plus,Valeur >(v1,v2); +} + +template X< double,Multiply,Valeur > operator*(TYPE sca,Valeur v) +{ +return X< TYPE,Multiply,Valeur >(sca,v); +} + +template X< Valeur,Plus,X > operator+(Valeur v,X expression) +{ +return X< Valeur,Plus,X >(v,expression); +} + +template X< X,Plus,Valeur > operator+(X expression,Valeur v) +{ +return X< X,Plus,Valeur >(expression,v); +} + +template X< X,Plus, X > operator+(X el, X er ) +{ +return X< X,Plus,X >(el,er); +} + +template X< double,Multiply,X > operator*(double sca,X expression) +{ +return X< double,Multiply,X >(sca,expression); +} + +template X< double,Multiply,X > operator/(X l,double x) +{ +return X< double,Multiply,X >(((double) 1/x),l); +} + +/*********************************************************/ +/* */ +/* Classe Valeur */ +/* */ +/*********************************************************/ + +// Problèmes : les constructeurs par copie ne sont pas satisfaisants + +template 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 Valeur(X expression) + { + for (int i=0;i void operator=(X expression) + { + for (int i=0;i ostream &operator<<(ostream &os,Valeur v) +{ +os<<"("< * medfield) + { + nbr_valeurs=medfield->getNumberOfValues(); + nbr_composantes=medfield->getNumberOfComponents(); + valeurs=const_cast(medfield->getValue(MED_FULL_INTERLACE)); + } + ~Wrapper_MED_Field(){} + inline Valeur operator[](int i) + { + if ((i<0)||(i>=nbr_valeurs)) + { + cerr< + +#ifndef UNDEFINED +#define UNDEFINED -1 +#endif + +#ifndef FAUX +#define FAUX 0 +#endif + +#ifndef VRAI +#define VRAI 1 +#endif + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Wrapper_Maillage */ +/* */ +/*********************************************************/ + +template class Wrapper_Maillage +{ +protected : + NUAGEMAILLE * mailles; + + int nbr_noeuds; + + vector< vector > faces_contenues; + vector< vector > mailles_contenant_noeud; + vector< vector > voisins_de_maille; + + vector face_au_bord; + vector 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 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 int Wrapper_Maillage::DONNE_PREMIERE_MAILLE_CONTENANT(int num_noeud) const + { + return mailles_contenant_noeud[num_noeud][0]; + } +template int Wrapper_Maillage::DONNE_VOISIN_DE_MAILLE(int num_maille,int num_face) const + { + return voisins_de_maille[num_maille][num_face]; + } +template int Wrapper_Maillage::EST_AU_BORD_FACE_DE_MAILLE(int num_maille,int num_face) const + { + return face_au_bord[faces_contenues[num_maille][num_face]]; + } +template int Wrapper_Maillage::DONNE_NBR_FACES_MAILLE(int num_maille) + { + return mailles->DONNE_NBR_FACES(num_maille); + } +template vector Wrapper_Maillage::DONNE_SIMPLEXE_BASE(int num_maille,int num_face) const + { + return mailles->DONNE_SIMPLEXE_BASE(num_maille,num_face); + } +template NUAGEMAILLE * Wrapper_Maillage::DONNE_POINTEUR_NUAGEMAILLE() + { + return mailles; + } +template void Wrapper_Maillage::Construit_Contenant_Noeud() + { + int nbr_noeuds_maille; + int num,num_noeud,num_maille; + + mailles_contenant_noeud.resize(nbr_noeuds); + + for (num_maille=0;num_mailleSIZE();num_maille++) + { + nbr_noeuds_maille=mailles->DONNE_NBR_NOEUDS(num_maille); + for (num_noeud=0;num_noeudDONNE_SOMMET_MAILLE(num_maille,num_noeud); +// if ((num<0)||(num>=mailles_contenant_noeud.size())) +// { +// cerr<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 sommets_face; + + cout<<"Calcul du lien Sommet->Maille"<DONNE_NBR_FACES(num_maille); + voisins_de_maille[num_maille]=vector(tmp,UNDEFINED); + faces_contenues[num_maille]=vector(tmp,UNDEFINED); + approx_nbr_formants+=tmp; + } + + face_au_bord.reserve(approx_nbr_formants/10); + + cout<<"Calcul des voisins"<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_secnum_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 "< 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 &A,const Wrapper_Noeud &B) + { + double max=0; + double tmp; + for (int i=0;imax) max=tmp; + } + return max; + } + friend double DistanceL2(const Wrapper_Noeud &A,const Wrapper_Noeud &B) + { + double tmp,somme=0; + for (int i=0;i &A,const Wrapper_Noeud &B) + { + for (int i=0;i &A) + { + os<<"( "< class Wrapper_Nuage_Noeud + { + protected : + int nbr_noeuds; + double *noeuds; + Wrapper_Noeud 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 & operator [] (int i) + { + if ((i<0)||(i>=nbr_noeuds)) + { + cerr<<"Outbound call dans Wrapper Nuage Noeud"< +#define _DTREE_ dTree + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Calcul Statique de Puissance */ +/* */ +/*********************************************************/ + +// Permet de Calculer 2^n de façon statique + +template < int DIMENSION > struct DeuxPuissance + { + enum { valeur = 2 * DeuxPuissance::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 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 dTree +{ +protected : + // types + typedef _DTREE_ * Ptr_dTree; + // Static Const + static const int nbr_descendants=DeuxPuissance::valeur; + // champs + NUAGENOEUD * nuage; + Ptr_dTree descendant[nbr_descendants]; + vector * noeud_contenu; + int etat; + int niveau; + dTree * pere; + Sommet_dTree coord_max; + Sommet_dTree coord_min; +public : + + void init(); + dTree(); + dTree(NUAGENOEUD *n); + dTree(const Sommet_dTree &A,const Sommet_dTree &B,dTree *mypere); + dTree(const dTree &F); + ~dTree(); + void Get_Noeuds_Filtre(vector &tmp); + Sommet_dTree Get_Max() const; + Sommet_dTree Get_Min() const; + int is_in_dTree(NOEUD P) const; + double calcule_distance(NOEUD P) const; + dTree & operator = (const dTree & F); + Sommet_dTree 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(nuage->size()); + niveau=0; + + for (i=0;isize();i++) + { + (*noeud_contenu)[i]=i; + for (j=0;jcoord_max[j]) coord_max[j]=(*nuage)[i][j]; + if ((*nuage)[i][j] &A,const Sommet_dTree &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; + noeud_contenu->reserve((pere->noeud_contenu->size())/nbr_descendants); + + for (i=0;iB[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 !"< &tmp) + { + int i; + switch (etat) + { + case DTREE_RACINE : int pourlefunlecompilolesttropcon; + case DTREE_COURANT : + for (i=0;iGet_Noeuds_Filtre(tmp); + case DTREE_TERMINAL : + if (noeud_contenu->size()>0) + { + for (i=0;i _DTREE_::Get_Max() const + { + return coord_max; + } +_TEMPLATE_ Sommet_dTree _DTREE_::Get_Min() const + { + return coord_min; + } +_TEMPLATE_ int _DTREE_::is_in_dTree(NOEUD P) const + { + int test; + for (int i=0;itmp) 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 _DTREE_::donne_sommet(int selecteur) const + { + Sommet_dTree p; + int i; + int residu=selecteur; + int reste; + for (i=0;i 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 A=donne_sommet(i); + int test,j; + for (j=0;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;isize();i++) + { + tmp=DistanceL2(P,(*nuage)[i]); + if (tmpsize()!=0) + { + num_sol=(*noeud_contenu)[0]; + min=DistanceL2(P,(*nuage)[num_sol]); + for (i=1;isize();i++) + { + tmp=DistanceL2(P,(*nuage)[(*noeud_contenu)[i]]); + if (tmppere!=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 !"<size()>0) return (*(noeud_contenu))[0]; + } + else + { + int i; + for (i=0;itrouve_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;itppp_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;icoord_max[i]+d) return 0; + if (P[i]niveau+1; + } + else + { + niveau=0; + } + + if (noeud_contenu->size()<=NBR_NOEUDS_PAR_CASE) + { + etat=DTREE_TERMINAL; + } + else + { + int i,num_loc,test; + + Sommet_dTree centre(coord_max,coord_min); + + for (i=0;isize();num_loc++) + { + int indice=(*noeud_contenu)[num_loc]; + NOEUD & courant=(*nuage)[indice]; + test=1; + for (i=0;(test)&&(iis_in_dTree(courant)) + { + descendant[i]->noeud_contenu->push_back(indice); + test=0; + } + } + } + + delete noeud_contenu; + noeud_contenu=NULL; + + for (i=0;icree_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;iGet_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"<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"<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"< class Sommet_dTree +{ +protected : + double coord[DIMENSION]; +public : + Sommet_dTree() + { + } + Sommet_dTree(double *c) + { + for (int i=0;i &A,const Sommet_dTree &B) + { + double max=0; + double tmp; + for (int i=0;imax) max=tmp; + } + return max; + } +}; + +#endif diff --git a/src/MEDMEM/INTERPOLATION/create_mesh_interpolation.c b/src/MEDMEM/INTERPOLATION/create_mesh_interpolation.c new file mode 100644 index 000000000..609a00db4 --- /dev/null +++ b/src/MEDMEM/INTERPOLATION/create_mesh_interpolation.c @@ -0,0 +1,433 @@ +#include +#include + +#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=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=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 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; +} + diff --git a/src/MEDMEM/INTERPOLATION/test_MEDMEM_Interpolation.cxx b/src/MEDMEM/INTERPOLATION/test_MEDMEM_Interpolation.cxx new file mode 100644 index 000000000..5d8112d8e --- /dev/null +++ b/src/MEDMEM/INTERPOLATION/test_MEDMEM_Interpolation.cxx @@ -0,0 +1,56 @@ +#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 : "< fromField (&fromSupport,MED_DRIVER,fromFileName,fieldName); cout<<"OK !"< myInter (fromField,toMesh); + + //FIELD * toField = myInter.interpolate(0,1); + FIELD * toField = myInter.interpolate(1,1); + + cout<<"Creation du driver"<addDriver(MED_DRIVER,toFileName,toField->getName()) ; + + cout<<"toField->getName() = "<getName() <getDescription() = "<getDescription() <getNumberOfComponents() = "<getNumberOfComponents() <getNumberOfValues() = "<getNumberOfValues() <getComponentsNames() = "<getComponentsNames() <getComponentsDescriptions() = "<getComponentsDescriptions()<getMEDComponentsUnits() = "<getMEDComponentsUnits() <getIterationNumber() = "<getIterationNumber() <getTime() = "<getTime() <getOrderNumber() = "<getOrderNumber() <getValueType() = "<getValueType() <write(); + + cout<<"Fin"< +#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 + (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; iTgetNumberOfElements(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; iTgetConnectivity + (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 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(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(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(this))->fillCopy(); + + const med_int * c = CONNECTIVITY::getNeighbourhood(); + + END_OF("void CONNECTIVITYClient::getNeighbourhood()"); + + return c; +} + diff --git a/src/MedClient/src/CONNECTIVITYClient.hxx b/src/MedClient/src/CONNECTIVITYClient.hxx new file mode 100644 index 000000000..9240db5e5 --- /dev/null +++ b/src/MedClient/src/CONNECTIVITYClient.hxx @@ -0,0 +1,62 @@ +#ifndef _CONNECTIVITY_CLIENT_HXX +#define _CONNECTIVITY_CLIENT_HXX + +#include +#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 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 diff --git a/src/MedClient/src/COORDINATEClient.cxx b/src/MedClient/src/COORDINATEClient.cxx new file mode 100644 index 000000000..f5ebf51b0 --- /dev/null +++ b/src/MedClient/src/COORDINATEClient.cxx @@ -0,0 +1,107 @@ +#include "COORDINATEClient.hxx" +#include +#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 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; +} diff --git a/src/MedClient/src/COORDINATEClient.hxx b/src/MedClient/src/COORDINATEClient.hxx new file mode 100644 index 000000000..2f64e4636 --- /dev/null +++ b/src/MedClient/src/COORDINATEClient.hxx @@ -0,0 +1,59 @@ +#ifndef _COORDINATE_CLIENT_HXX +#define _COORDINATE_CLIENT_HXX + +#include +#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 diff --git a/src/MedClient/src/FAMILYClient.cxx b/src/MedClient/src/FAMILYClient.cxx new file mode 100644 index 000000000..a648cd9a2 --- /dev/null +++ b/src/MedClient/src/FAMILYClient.cxx @@ -0,0 +1,83 @@ +#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()"); +} diff --git a/src/MedClient/src/FAMILYClient.hxx b/src/MedClient/src/FAMILYClient.hxx new file mode 100644 index 000000000..c74ef20db --- /dev/null +++ b/src/MedClient/src/FAMILYClient.hxx @@ -0,0 +1,31 @@ +#ifndef _FAMILYCLIENT_HXX +#define _FAMILYCLIENT_HXX + +#include +#include +#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 diff --git a/src/MedClient/src/FIELDClient.hxx b/src/MedClient/src/FIELDClient.hxx new file mode 100644 index 000000000..0582515ef --- /dev/null +++ b/src/MedClient/src/FIELDClient.hxx @@ -0,0 +1,70 @@ +#ifndef _FIELDCLIENT_HXX +#define _FIELDCLIENT_HXX + +#include +#include +#include "MEDMEM_Field.hxx" +#include CORBA_CLIENT_HEADER(MED) + +template +class FIELDClient : virtual public FIELD { + +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 +FIELDClient::FIELDClient(const SALOME_MED::FIELD_ptr F, + SUPPORT * S) : + FIELD(), + 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 +void FIELDClient::blankCopy() +{ + BEGIN_OF("FIELDClient::blankCopy"); + + + END_OF("FIELDClient::blankCopy"); + +} + +template +void FIELDClient::fillCopy() +{ + BEGIN_OF("FIELDClient::fillCopy"); + + END_OF("FIELDClient::fillCopy"); +} + + +template +FIELDClient::~FIELDClient() +{ + BEGIN_OF("FIELDClient::~FIELDClient"); + + END_OF("FIELDClient::~FIELDClient"); +} + +#endif diff --git a/src/MedClient/src/GROUPClient.cxx b/src/MedClient/src/GROUPClient.cxx new file mode 100644 index 000000000..99ec27a1e --- /dev/null +++ b/src/MedClient/src/GROUPClient.cxx @@ -0,0 +1,44 @@ +#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()"); +} diff --git a/src/MedClient/src/GROUPClient.hxx b/src/MedClient/src/GROUPClient.hxx new file mode 100644 index 000000000..fd6d32edd --- /dev/null +++ b/src/MedClient/src/GROUPClient.hxx @@ -0,0 +1,32 @@ +#ifndef _GROUPCLIENT_HXX +#define _GROUPCLIENT_HXX + +#include +#include +#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 diff --git a/src/MedClient/src/MESHClient.cxx b/src/MedClient/src/MESHClient.cxx new file mode 100644 index 000000000..4a530dfe9 --- /dev/null +++ b/src/MedClient/src/MESHClient.cxx @@ -0,0 +1,143 @@ +#include "MESHClient.hxx" +#include +#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(_coordinate); + ASSERT(_coord); + CONNECTIVITYClient *_connect + = dynamic_cast(_connectivity); + ASSERT(_connect); + + _coord->blankCopy(); + _connect->blankCopy(); + + MESSAGE(""); + convertCorbaArray + (_familyNode, + _numberOfNodesFamilies, + IOR_Mesh->getFamilies(MED_NODE), + (void *) (convertFamily), this); + + MESSAGE(""); + convertCorbaArray + (_familyEdge, + _numberOfEdgesFamilies, + IOR_Mesh->getFamilies(MED_EDGE), + (void *) (convertFamily), this); + + MESSAGE(""); + convertCorbaArray + (_familyFace, + _numberOfFacesFamilies, + IOR_Mesh->getFamilies(MED_FACE), + (void *) (convertFamily), this); + + MESSAGE(""); + convertCorbaArray + (_familyCell, + _numberOfCellsFamilies, + IOR_Mesh->getFamilies(MED_CELL), + (void *) (convertFamily), this); + + MESSAGE(""); + convertCorbaArray + (_groupNode, + _numberOfNodesGroups, + IOR_Mesh->getGroups(MED_NODE), + (void *) (convertGroup), this); + + MESSAGE(""); + convertCorbaArray + (_groupEdge, + _numberOfEdgesGroups, + IOR_Mesh->getGroups(MED_EDGE), + (void *) (convertGroup), this); + + MESSAGE(""); + convertCorbaArray + (_groupFace, + _numberOfFacesGroups, + IOR_Mesh->getGroups(MED_FACE), + (void *) (convertGroup), this); + + MESSAGE(""); + convertCorbaArray + (_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 (_coordinate); + ASSERT(_coord); + CONNECTIVITYClient *_connect + = dynamic_cast (_connectivity); + ASSERT(_connect); + + _coord->fillCopy(); + _connect->fillCopy(); + + _complete = true; + + END_OF("MESHClient::fillCopy()"); +} + + +MESHClient::~MESHClient() +{ + BEGIN_OF("MESHClient::~MESHClient()"); + END_OF("MESHClient::~MESHClient()"); +} + diff --git a/src/MedClient/src/MESHClient.hxx b/src/MedClient/src/MESHClient.hxx new file mode 100644 index 000000000..4b268edbb --- /dev/null +++ b/src/MedClient/src/MESHClient.hxx @@ -0,0 +1,30 @@ +#ifndef _MESHCLIENT_HXX +#define _MESHCLIENT_HXX + +#include +#include +#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 + diff --git a/src/MedClient/src/Makefile.in b/src/MedClient/src/Makefile.in new file mode 100644 index 000000000..bad4bec34 --- /dev/null +++ b/src/MedClient/src/Makefile.in @@ -0,0 +1,83 @@ +# 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@ diff --git a/src/MedClient/src/SUPPORTClient.cxx b/src/MedClient/src/SUPPORTClient.cxx new file mode 100644 index 000000000..37ed8d6ef --- /dev/null +++ b/src/MedClient/src/SUPPORTClient.cxx @@ -0,0 +1,134 @@ +#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(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(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(this))->fillCopy(); + const int * n = SUPPORT::getNumberIndex(); + + END_OF("SUPPORTClient::getnumberIndex()"); + return n; +} + diff --git a/src/MedClient/src/SUPPORTClient.hxx b/src/MedClient/src/SUPPORTClient.hxx new file mode 100644 index 000000000..6e03691db --- /dev/null +++ b/src/MedClient/src/SUPPORTClient.hxx @@ -0,0 +1,37 @@ +#ifndef _SUPPORTCLIENT_HXX +#define _SUPPORTCLIENT_HXX + +#include +#include +#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 diff --git a/src/MedClient/src/UtilClient.hxx b/src/MedClient/src/UtilClient.hxx new file mode 100644 index 000000000..d497d3108 --- /dev/null +++ b/src/MedClient/src/UtilClient.hxx @@ -0,0 +1,113 @@ +#ifndef UTILCLIENT_HXX_ +#define UTILCLIENT_HXX_ + +#include +#include + +template +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 +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 +inline void convertCorbaArray (vector & T, int &nT, + const TCorbaSeq & S) +{ + int i, n = S->length(); + SCRUTE(n); + + nT = n; + T.resize(nT); + + for (i=0; i +inline void convertCorbaArray (vector & 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 +inline void convertCorbaArray (vector & 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 +class FIELDClient : public FIELD { + + public: + + FIELDClient(const SALOME_MED::FIELD_ptr S, + MESH * M = NULL); + ~FIELDClient(); + + void blankCopy(); + void fillCopy(); + +}; diff --git a/src/MedClient/test/Makefile.in b/src/MedClient/test/Makefile.in new file mode 100644 index 000000000..586744316 --- /dev/null +++ b/src/MedClient/test/Makefile.in @@ -0,0 +1,39 @@ +# 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@ diff --git a/src/MedClient/test/environ/Makefile.in b/src/MedClient/test/environ/Makefile.in new file mode 100644 index 000000000..c688571ea --- /dev/null +++ b/src/MedClient/test/environ/Makefile.in @@ -0,0 +1,73 @@ +# 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: + diff --git a/src/MedClient/test/environ/csh/Makefile.in b/src/MedClient/test/environ/csh/Makefile.in new file mode 100644 index 000000000..ee46a855f --- /dev/null +++ b/src/MedClient/test/environ/csh/Makefile.in @@ -0,0 +1,43 @@ + +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 diff --git a/src/MedClient/test/environ/csh/init1.in b/src/MedClient/test/environ/csh/init1.in new file mode 100644 index 000000000..e0eb68e16 --- /dev/null +++ b/src/MedClient/test/environ/csh/init1.in @@ -0,0 +1,7 @@ +cd ${SALOME_ROOT_DIR}/bin +pwd +./allkill || true +./killall python || true +./runSession +csh + diff --git a/src/MedClient/test/environ/csh/init2.in b/src/MedClient/test/environ/csh/init2.in new file mode 100644 index 000000000..451835ead --- /dev/null +++ b/src/MedClient/test/environ/csh/init2.in @@ -0,0 +1,11 @@ +#!/bin/csh + +cd ${SALOME_BIN_TESTS} + +while ( `ps | grep omniNames > /dev/null ` ) + sleep 2 +end +sleep 2 + +./csh/runContainer TrucPy +csh diff --git a/src/MedClient/test/environ/csh/init3.in b/src/MedClient/test/environ/csh/init3.in new file mode 100644 index 000000000..388d8bb64 --- /dev/null +++ b/src/MedClient/test/environ/csh/init3.in @@ -0,0 +1,2 @@ +cd ${SALOME_ROOT_DIR}/bin +csh diff --git a/src/MedClient/test/environ/csh/runContainer.in b/src/MedClient/test/environ/csh/runContainer.in new file mode 100644 index 000000000..90fe75670 --- /dev/null +++ b/src/MedClient/test/environ/csh/runContainer.in @@ -0,0 +1,57 @@ +#! /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 + diff --git a/src/MedClient/test/environ/csh/runEnvironTests.in b/src/MedClient/test/environ/csh/runEnvironTests.in new file mode 100644 index 000000000..23d4400bc --- /dev/null +++ b/src/MedClient/test/environ/csh/runEnvironTests.in @@ -0,0 +1,32 @@ +# +[ -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 diff --git a/src/MedClient/test/environ/csh/stopContainer.in b/src/MedClient/test/environ/csh/stopContainer.in new file mode 100644 index 000000000..5d3a362be --- /dev/null +++ b/src/MedClient/test/environ/csh/stopContainer.in @@ -0,0 +1,83 @@ +#! /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 " + 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 diff --git a/src/MedClient/test/environ/runContainer.in b/src/MedClient/test/environ/runContainer.in new file mode 100644 index 000000000..579a99034 --- /dev/null +++ b/src/MedClient/test/environ/runContainer.in @@ -0,0 +1,17 @@ +# + +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 + + diff --git a/src/MedClient/test/environ/runEnvironTests.in b/src/MedClient/test/environ/runEnvironTests.in new file mode 100644 index 000000000..ef3305285 --- /dev/null +++ b/src/MedClient/test/environ/runEnvironTests.in @@ -0,0 +1,17 @@ +# + +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 + + diff --git a/src/MedClient/test/environ/runTestMedCorba.in b/src/MedClient/test/environ/runTestMedCorba.in new file mode 100644 index 000000000..0e33fed11 --- /dev/null +++ b/src/MedClient/test/environ/runTestMedCorba.in @@ -0,0 +1,22 @@ +#! /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 + diff --git a/src/MedClient/test/environ/stopContainer.in b/src/MedClient/test/environ/stopContainer.in new file mode 100644 index 000000000..f09fc1c68 --- /dev/null +++ b/src/MedClient/test/environ/stopContainer.in @@ -0,0 +1,17 @@ +# + +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 + + diff --git a/src/MedClient/test/resources/carre_en_quad4_seg2.med b/src/MedClient/test/resources/carre_en_quad4_seg2.med new file mode 100644 index 000000000..7d7c75370 Binary files /dev/null and b/src/MedClient/test/resources/carre_en_quad4_seg2.med differ diff --git a/src/MedClient/test/resources/maill.0.med b/src/MedClient/test/resources/maill.0.med new file mode 100644 index 000000000..e5a7b130d Binary files /dev/null and b/src/MedClient/test/resources/maill.0.med differ diff --git a/src/MedClient/test/resources/pointe.med b/src/MedClient/test/resources/pointe.med new file mode 100644 index 000000000..430a74bd6 Binary files /dev/null and b/src/MedClient/test/resources/pointe.med differ diff --git a/src/MedClient/test/resources/test_hydro_darcy1a_out.med b/src/MedClient/test/resources/test_hydro_darcy1a_out.med new file mode 100644 index 000000000..df24a1ea6 Binary files /dev/null and b/src/MedClient/test/resources/test_hydro_darcy1a_out.med differ diff --git a/src/MedClient/test/test1/Compo1.py b/src/MedClient/test/test1/Compo1.py new file mode 100644 index 000000000..db73eabd7 --- /dev/null +++ b/src/MedClient/test/test1/Compo1.py @@ -0,0 +1,53 @@ +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 diff --git a/src/MedClient/test/test1/Compo1Py.idl b/src/MedClient/test/test1/Compo1Py.idl new file mode 100644 index 000000000..1035d61ae --- /dev/null +++ b/src/MedClient/test/test1/Compo1Py.idl @@ -0,0 +1,14 @@ +#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(); + }; + +}; diff --git a/src/MedClient/test/test1/Compo1Py.py b/src/MedClient/test/test1/Compo1Py.py new file mode 100644 index 000000000..50dac23a7 --- /dev/null +++ b/src/MedClient/test/test1/Compo1Py.py @@ -0,0 +1,34 @@ +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) + diff --git a/src/MedClient/test/test1/Makefile.in b/src/MedClient/test/test1/Makefile.in new file mode 100644 index 000000000..13ee5d752 --- /dev/null +++ b/src/MedClient/test/test1/Makefile.in @@ -0,0 +1,52 @@ +# 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@ diff --git a/src/MedClient/test/test1/TestMedCorba1.py b/src/MedClient/test/test1/TestMedCorba1.py new file mode 100644 index 000000000..51e414e9d --- /dev/null +++ b/src/MedClient/test/test1/TestMedCorba1.py @@ -0,0 +1,78 @@ +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" diff --git a/src/MedClient/test/test1/TestMedCorba2.py b/src/MedClient/test/test1/TestMedCorba2.py new file mode 100644 index 000000000..04960610c --- /dev/null +++ b/src/MedClient/test/test1/TestMedCorba2.py @@ -0,0 +1,84 @@ +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" diff --git a/src/MedClient/test/test1/TestMedCorba3.py b/src/MedClient/test/test1/TestMedCorba3.py new file mode 100644 index 000000000..a13b7555d --- /dev/null +++ b/src/MedClient/test/test1/TestMedCorba3.py @@ -0,0 +1,105 @@ +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" diff --git a/src/MedClient/test/test1/TestMedCorba4.py b/src/MedClient/test/test1/TestMedCorba4.py new file mode 100644 index 000000000..341db6e7d --- /dev/null +++ b/src/MedClient/test/test1/TestMedCorba4.py @@ -0,0 +1,76 @@ +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" diff --git a/src/MedClient/test/test1/TestMedCorba5.py b/src/MedClient/test/test1/TestMedCorba5.py new file mode 100644 index 000000000..7b5b47da9 --- /dev/null +++ b/src/MedClient/test/test1/TestMedCorba5.py @@ -0,0 +1,85 @@ +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" diff --git a/src/MedClient/test/test2/Compo2.cxx b/src/MedClient/test/test2/Compo2.cxx new file mode 100644 index 000000000..f9abdd2a1 --- /dev/null +++ b/src/MedClient/test/test2/Compo2.cxx @@ -0,0 +1,74 @@ +#ifndef _DEBUG_ +#define _DEBUG_ +#endif + +#include "Compo2.hxx" +#include +#include +#include + +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 &F) +{ + BEGIN_OF("void Compo2::Calcul3(const FIELD *)"); + + 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 *)"); +} diff --git a/src/MedClient/test/test2/Compo2.hxx b/src/MedClient/test/test2/Compo2.hxx new file mode 100644 index 000000000..c296dbb9a --- /dev/null +++ b/src/MedClient/test/test2/Compo2.hxx @@ -0,0 +1,24 @@ +#ifndef __COMPO2 +#define __COMPO2 + +#ifndef SWIG +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_Family.hxx" +#include "MEDMEM_Field.hxx" +#endif + +class Compo2 +{ + + FIELD * _F; + +public: + Compo2(); + ~Compo2(); + + std::string Calcul(const MESH &M); + const FAMILY * Calcul2(const MESH &M); + void Calcul3(const FIELD &S); +}; + +#endif diff --git a/src/MedClient/test/test2/Makefile.in b/src/MedClient/test/test2/Makefile.in new file mode 100644 index 000000000..8b2a5d4e2 --- /dev/null +++ b/src/MedClient/test/test2/Makefile.in @@ -0,0 +1,56 @@ +# 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@ + diff --git a/src/MedClient/test/test2/TestMedCorba6.py b/src/MedClient/test/test2/TestMedCorba6.py new file mode 100644 index 000000000..7b6dc840e --- /dev/null +++ b/src/MedClient/test/test2/TestMedCorba6.py @@ -0,0 +1,69 @@ +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" diff --git a/src/MedClient/test/test2/TestMedCorba7.py b/src/MedClient/test/test2/TestMedCorba7.py new file mode 100644 index 000000000..f0672e41f --- /dev/null +++ b/src/MedClient/test/test2/TestMedCorba7.py @@ -0,0 +1,76 @@ +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" diff --git a/src/MedClient/test/test2/TestMedCorba8.py b/src/MedClient/test/test2/TestMedCorba8.py new file mode 100644 index 000000000..b141b1e62 --- /dev/null +++ b/src/MedClient/test/test2/TestMedCorba8.py @@ -0,0 +1,39 @@ +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" diff --git a/src/MedClient/test/test2/libCompo2.i b/src/MedClient/test/test2/libCompo2.i new file mode 100644 index 000000000..a43ee3d18 --- /dev/null +++ b/src/MedClient/test/test2/libCompo2.i @@ -0,0 +1,10 @@ +%module libCompo2 + +%{ +#include "Compo2.hxx" +%} + +%include "std_string.i" +%include "libMEDClient.i" + +%include "Compo2.hxx"