with AG addings.
--- /dev/null
+# ifndef INTERPOLATION_HXX
+# define INTERPOLATION_HXX
+
+//template < class T> class FIELD;
+//template < int > class Wrapper_Nuage;
+//template < int > class Wrapper_Noeud;
+//template <class ,class ,int ,int > class dTree;
+
+#include <vector>
+#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_InterpolationHighLevelObjects.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Field.hxx"
+
+namespace MEDMEM {
+class MESH;
+
+template <int DIMENSION=3> class INTERPOLATION
+{
+protected:
+
+ FIELD<double> * _fromField;
+ FIELD<double> * _toField;
+ MESH * _fromMesh;
+ MESH * _toMesh;
+
+ Meta_Wrapper<DIMENSION> * _fromWrapper;
+ Meta_Wrapper<DIMENSION> * _toWrapper;
+
+ Meta_Mapping <DIMENSION> * _mapping;
+
+// only used when multi timestep are interpolated
+// but always coherent
+ int _iType;
+ int _isConvexFromMesh;
+
+public :
+
+ void init();
+
+ // Initialize INTERPOLATION in order to get :
+ // 1- the node number in the MESH <fromMesh> which
+ // is the nearest from a given one ( use method : getNearestNode( double * node ) );
+ // 2- the cell number (if exists) in the MESH <fromMesh> which
+ // contains a specified node ( use method : getContainingCell ( double * node) )
+ INTERPOLATION(const MESH & fromMesh );
+ // Initialize INTERPOLATION in order to get :
+ // 1- the complete mapping ( use methode : getMapping() )
+ // 2- the functionalities above
+ INTERPOLATION(const MESH & fromMesh,const MESH & toMesh );
+ // Initialize INTERPOLATION in order to get the interpolation of <field> on <toMesh>
+ // Moreover, all the others functionalities are so available
+ INTERPOLATION(const FIELD<double> & fromField, const MESH & toMesh);
+
+ ~INTERPOLATION( );
+
+ // Get the node number in the MESH <fromMesh> which is the nearest from a given one
+ int getNearestNode ( double * node );
+ // Get the cell number (if exists) in the MESH <fromMesh> which contains a specified node
+ int getContainingCell ( double * node , int beginingCell=0, int flagIsConvexMesh=0 );
+ // Get the complete mapping, defaultly, fromMesh is supposed to be non-convex, if it is false, set flagIsConvexMesh to 1
+ vector<int> getMapping ( int flagIsConvexMesh=0 );
+ // Get the interpolated field toField
+ FIELD<double> * interpolate( /*med_interpolation_type*/ int itype,int flagIsConvexFromMesh=0);
+ // reset the <from> parameters in order not to redo the mapping (if the mesh are identical)
+ // and then get the interpoated field toField
+ // this method is specifictly used on multi-timestep (or order number) fields
+ // it has only to be used after the first step, the interpolation paramaters are the same for every step
+ FIELD<double> * interpolateNextStep(const FIELD <double> &nextFromField ,int & flagNewMapping);
+
+};
+
+template <int DIMENSION> void INTERPOLATION<DIMENSION>::init() {
+
+ const char * LOC = "INTERPOLATION::init(): ";
+
+ BEGIN_OF(LOC);
+ _fromField = ( FIELD<double> * ) NULL;
+ _toField = ( FIELD<double> * ) NULL;
+ _fromMesh = ( MESH * ) NULL;
+ _toMesh = ( MESH * ) NULL;
+ _fromWrapper = ( Meta_Wrapper<DIMENSION> * ) NULL;
+ _toWrapper = ( Meta_Wrapper<DIMENSION> * ) NULL;
+ _mapping = ( Meta_Mapping<DIMENSION> * ) NULL;
+ _iType = UNDEFINED ;
+ _isConvexFromMesh = UNDEFINED ;
+ END_OF(LOC);
+}
+
+
+template <int DIMENSION> INTERPOLATION<DIMENSION>::INTERPOLATION(const MESH & fromMesh ) {
+
+ const char * LOC = "INTERPOLATION::INTERPOLATION(MESH * fromMesh ) : ";
+ BEGIN_OF(LOC);
+
+ init();
+
+ _fromMesh=const_cast<MESH * > (&fromMesh);
+
+ if (! _fromMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromMesh is a NULL pointer !")) ;
+
+ int spaceDimension = _fromMesh->getSpaceDimension();
+ if (spaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _fromMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
+
+ _fromWrapper = new Meta_Wrapper<DIMENSION>(_fromMesh->getNumberOfNodes(),
+ const_cast<double *> (_fromMesh->getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<CONNECTIVITY *> (_fromMesh->getConnectivityptr())
+ );
+
+ _mapping = new Meta_Mapping<DIMENSION> (_fromWrapper);
+
+ END_OF(LOC);
+};
+
+template <int DIMENSION> INTERPOLATION<DIMENSION>::INTERPOLATION(const MESH & fromMesh,const MESH & toMesh ) {
+
+ const char * LOC = "INTERPOLATION::INTERPOLATION(MESH * fromMesh,,const MESH & toMesh) : ";
+ BEGIN_OF(LOC);
+
+ init();
+
+ _fromMesh = const_cast<MESH * > ( &fromMesh );
+ _toMesh = const_cast<MESH * > ( &toMesh );
+
+ if (! _fromMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromMesh is a NULL pointer !")) ;
+ if (! _toMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toMesh is a NULL pointer !")) ;
+
+ int fromSpaceDimension = _fromMesh->getSpaceDimension();
+ int toSpaceDimension = _toMesh->getSpaceDimension();
+
+ if (fromSpaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _fromMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
+ if ( toSpaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _toMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ;
+
+ _fromWrapper = new Meta_Wrapper<DIMENSION>(_fromMesh->getNumberOfNodes(),
+ const_cast<double *> (_fromMesh->getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<CONNECTIVITY *> (_fromMesh->getConnectivityptr())
+ );
+
+ _toWrapper = new Meta_Wrapper<DIMENSION>(_toMesh->getNumberOfNodes(),
+ const_cast<double *> (_toMesh->getCoordinates(MED_FULL_INTERLACE))
+ );
+
+ _mapping = new Meta_Mapping<DIMENSION> (_fromWrapper);
+
+ END_OF(LOC);
+};
+
+template <int DIMENSION> INTERPOLATION<DIMENSION>::INTERPOLATION(const FIELD<double> & fromField,const MESH & toMesh) {
+
+ const char * LOC = "INTERPOLATION(const FIELD<double> & field,const MESH & toMesh) : ";
+ BEGIN_OF(LOC);
+
+ init();
+
+ _toMesh = const_cast<MESH *>(&toMesh);
+ _fromField = const_cast<FIELD<double> *>(&fromField);
+
+ if ( ! _toMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toMesh is a NULL pointer !")) ;
+ if ( ! _fromField ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"field is a NULL pointer !")) ;
+
+ _fromMesh = _fromField->getSupport()->getMesh();
+
+ if ( ! _fromMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromMesh is a NULL pointer !")) ;
+
+ _fromWrapper = new Meta_Wrapper<DIMENSION>(_fromMesh->getNumberOfNodes(),
+ const_cast<double *> (_fromMesh->getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<CONNECTIVITY *> (_fromMesh->getConnectivityptr()),
+ const_cast<FIELD<double> *>(_fromField)
+ );
+
+
+ _toWrapper = new Meta_Wrapper<DIMENSION>(_toMesh->getNumberOfNodes(),
+ const_cast<double *> (_toMesh->getCoordinates(MED_FULL_INTERLACE))
+ );
+
+
+ _mapping = new Meta_Mapping<DIMENSION> (_fromWrapper);
+
+
+ END_OF(LOC);
+};
+
+template <int DIMENSION> INTERPOLATION<DIMENSION>::~INTERPOLATION()
+{
+ if ( _fromWrapper ) delete _fromWrapper ;
+ if ( _toWrapper ) delete _toWrapper ;
+ if ( _mapping ) delete _mapping ;
+};
+
+template <int DIMENSION> int INTERPOLATION<DIMENSION>::getNearestNode( double * node ) {
+
+ const char * LOC = "INTERPOLATION::getNearestNode( double * node ) ";
+
+ BEGIN_OF(LOC);
+
+ if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ;
+
+ return _mapping->Donne_dTree()->trouve_plus_proche_point(Wrapper_Noeud<DIMENSION > (node) );
+
+ END_OF(LOC);
+
+};
+
+template <int DIMENSION> int INTERPOLATION<DIMENSION>::getContainingCell ( double * node , int beginingCell, int flagIsConvexMesh ) {
+
+ const char * LOC = "INTERPOLATION::getContainingCell( double * node ) ";
+
+ BEGIN_OF(LOC);
+
+ if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ;
+
+ _isConvexFromMesh=flagIsConvexMesh;
+
+ _mapping->Cree_Mapping(_toWrapper,_isConvexFromMesh);
+
+ return _mapping->Trouve_Maille_Contenant_Noeud(node,beginingCell,flagIsConvexMesh);
+
+ END_OF(LOC);
+
+};
+
+template <int DIMENSION> vector<int> INTERPOLATION<DIMENSION>::getMapping ( int flagIsConvexMesh ) {
+
+ const char * LOC = "INTERPOLATION::getMapping( ) ";
+
+ BEGIN_OF(LOC);
+
+ if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ;
+ if ( ! _toWrapper ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toWrapper is a NULL pointer !")) ;
+
+ _isConvexFromMesh=flagIsConvexMesh;
+
+ _mapping->Cree_Mapping(_toWrapper,_isConvexFromMesh);
+
+ return _mapping->Get_Mapping();
+
+ END_OF(LOC);
+
+};
+
+template <int DIMENSION> FIELD<double> * INTERPOLATION<DIMENSION>::interpolate(int itype,int flagIsConvexFromMesh) {
+
+ const char * LOC = "INTERPOLATION::interpolate(int itype,int flagIsConvexFromMesh) ";
+
+ 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 !")) ;
+
+ _iType=itype;
+
+ _isConvexFromMesh=flagIsConvexFromMesh;
+
+ _mapping->Cree_Mapping(_toWrapper,_isConvexFromMesh);
+
+ Wrapper_Nuage_Noeud<DIMENSION> * toNodes = _toWrapper->Get_Nuage_Noeuds();
+
+ Wrapper_MED_Field resultat;
+
+ /*
+ cout<<"Mapping"<<endl;
+ _mapping->affiche();
+ cout<<"Mailles"<<endl;
+ _fromWrapper->Get_Maillage()->DONNE_POINTEUR_NUAGEMAILLE()->affiche();
+ cout<<"Noeuds"<<endl;
+ _fromWrapper->Get_Nuage_Noeuds()->affiche();
+ */
+
+ switch (_iType)
+ {
+ case 0 : // INTERPOLATION P0
+ cout<<"Avant ="<<endl;
+ resultat=Meta_Interpolateur< Meta_Calcul_Interpolation_P0<DIMENSION>,DIMENSION >(_mapping,_fromWrapper).Perform_Interpolation(toNodes);
+ break;
+ case 1 : // INTERPOLATION P-Hybride (Interpole avec la fonction d'interpolation naturelle de la maille contenant le point)
+ resultat=Meta_Interpolateur< Meta_Calcul_Interpolation_Hybride<DIMENSION>,DIMENSION >(_mapping,_fromWrapper).Perform_Interpolation(toNodes);
+ break;
+ case 2 : // INTERPOLATION (P/Q) 1 forcée (Interpole avec la fonction élément fini de la maille de degré 1 -meme si la maille est de degré supérieur-)
+ resultat=Meta_Interpolateur< Meta_Calcul_Interpolation_Hybride_P1<DIMENSION>, DIMENSION >(_mapping,_fromWrapper).Perform_Interpolation(toNodes);
+ break;
+ default :
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Interpolation type "<<itype<<" not yet implemented !")) ;
+ }
+
+ cout<<"On a fini l'interpolation"<<endl;
+
+ _toField = new FIELD<double>;
+
+ _toField->setName ( _fromField->getName() );
+ _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);
+
+};
+
+template <int DIMENSION> FIELD<double> * INTERPOLATION<DIMENSION>::interpolateNextStep(const FIELD <double> & nextFromField, int & flagNewMapping) {
+
+ const char * LOC = "INTERPOLATION::interpolateNextStep(int itype,int flagIsConvexFromMesh) ";
+
+ 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 ( ! _fromWrapper ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromWrapper is a NULL pointer !" )) ;
+ if ( ! _fromField ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromField is a NULL pointer !" )) ;
+
+
+ if ( ! _toField ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toField is a NULL pointer, wrong use of interpolateNextStep" )) ;
+ if ( _iType==UNDEFINED ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"_iType is not defined, wrong use of interpolateNextStep" )) ;
+ if ( _isConvexFromMesh==UNDEFINED ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"_isConvexFromMesh is not defined, wrong use of interpolateNextStep" )) ;
+
+ // delete _toField; ????????????????????????????
+
+ // if the mesh are identical, the mapping is the same, if not, the mapping has to be re-calculated
+ if (nextFromField.getSupport()->getMesh()->getName()!=_fromMesh->getName())
+ {
+
+ flagNewMapping=1;
+
+ delete _mapping;
+ delete _fromWrapper;
+
+ _fromField = const_cast<FIELD<double> *>(&nextFromField);
+
+ _fromMesh = _fromField->getSupport()->getMesh();
+
+ _fromWrapper = new Meta_Wrapper<DIMENSION>(_fromMesh->getNumberOfNodes(),
+ const_cast<double *> (_fromMesh->getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<CONNECTIVITY *> (_fromMesh->getConnectivityptr()),
+ const_cast<FIELD<double> *>(_fromField)
+ );
+ _mapping = new Meta_Mapping<DIMENSION> (_fromWrapper);
+
+ _mapping->Cree_Mapping(_toWrapper,_isConvexFromMesh);
+
+ }
+ else
+ {
+
+ flagNewMapping=0;
+
+ _fromField = const_cast<FIELD<double> *>(&nextFromField);
+ _fromWrapper->Change_Champ(const_cast<FIELD<double> *>(_fromField));
+ }
+
+ return interpolate(_iType,_isConvexFromMesh);
+
+};
+
+};
+
+#endif
+
+
--- /dev/null
+#ifndef MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX
+#define MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX
+
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_WrapperConnectivity.hxx"
+#include "MEDMEM_dTree.hxx"
+#include "MEDMEM_WrapperNodes.hxx"
+#include "MEDMEM_WrapperMesh.hxx"
+#include "MEDMEM_WrapperCells.hxx"
+#include "MEDMEM_Mapping.hxx"
+#include "MEDMEM_WrapperField.hxx"
+#include "MEDMEM_InterpolationTools.hxx"
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+template <int DIMENSION> class Meta_Wrapper;
+
+/*********************************************************/
+/* */
+/* Meta_dTree */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Meta_dTree : public dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>
+{
+protected :
+ // PATCH
+ Wrapper_Nuage_Noeud<DIMENSION> * noeuds;
+ // FIN PATCH
+public :
+ // PATCH
+ Meta_dTree():noeuds(NULL) {}
+ ~Meta_dTree() {if (noeuds) delete noeuds;}
+ Meta_dTree(int nbr_noeuds,double *coord):dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>(noeuds=new Wrapper_Nuage_Noeud<DIMENSION>(nbr_noeuds,coord)) {}
+ inline int trouve_plus_proche_point_bourrin(double *node);
+ // FIN PATCH
+ inline int trouve_plus_proche_point(double * node);
+};
+
+/*********************************************************/
+/* */
+/* Meta_Nuage_Maille */
+/* */
+/*********************************************************/
+
+
+class Meta_Nuage_Maille : public Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>
+{
+protected :
+ Wrapper_Med_Connectivity * connectivite_med;
+public :
+ Meta_Nuage_Maille(CONNECTIVITY * connmed);
+ Meta_Nuage_Maille():connectivite_med(NULL) {}
+ ~Meta_Nuage_Maille() {if (connectivite_med) delete connectivite_med;}
+};
+
+/*********************************************************/
+/* */
+/* Meta_Maillage */
+/* */
+/*********************************************************/
+
+
+typedef Wrapper_Maillage<Meta_Nuage_Maille> Meta_Maillage;
+
+/*********************************************************/
+/* */
+/* Meta_Mapping */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Meta_Mapping : public Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>
+{
+public :
+ Meta_Mapping(Meta_Wrapper<DIMENSION> * MW):Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>(MW->Get_Maillage(),MW->Get_Nuage_Noeuds(),NULL) {}
+ Meta_Mapping(Meta_Wrapper<DIMENSION> * MW,Meta_Wrapper<DIMENSION> * TWB):Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>(MW->Get_Maillage(),MW->Get_Nuage_Noeuds(),TWB->Get_Nuage_Noeuds()) {}
+ // PATCH
+ inline void Cree_Mapping(Meta_Wrapper<DIMENSION> * MWB, int flag_convexe) {Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>::Cree_Mapping(MWB->Get_Nuage_Noeuds(),flag_convexe);}
+ inline void Cree_Mapping(int flag_convexe) {Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>::Cree_Mapping(flag_convexe);}
+ inline vector<int> & Get_Mapping() {return Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>::Get_Mapping();}
+ //FIN PATCH
+ inline int Trouve_Maille_Contenant_Noeud(double * node,int num_maille, int flag_convexe=0);
+};
+
+/*********************************************************/
+/* */
+/* Meta_Wrapper */
+/* */
+/*********************************************************/
+
+
+template <int DIMENSION> class Meta_Wrapper
+{
+protected :
+ Wrapper_Nuage_Noeud<DIMENSION> * noeuds ;
+ Meta_Nuage_Maille * mailles ;
+ Meta_Maillage * maillage ;
+ Wrapper_MED_Field * champ ;
+
+ void init( ){noeuds=NULL;mailles=NULL;maillage=NULL;champ=NULL;}
+public :
+ Meta_Wrapper():noeuds(NULL),mailles(NULL),maillage(NULL),champ(NULL){}
+ ~Meta_Wrapper();
+ inline void Construit_Wrapper_Nuage_Noeud ( int nn, double * nodes );
+ inline void Construit_Wrapper_Nuage_Maille ( CONNECTIVITY * connmed );
+ inline void Construit_Wrapper_Maillage ( void );
+ inline void Construit_Wrapper_Champ ( const FIELD<double> * medfield );
+ Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, int flag_maillage=1);
+ Meta_Wrapper(int nn,double *nodes);
+ // defaultly, the connectivity (neighbouhood and so like) is built,
+ // Set flag_mesh to 0 if you don't want these informations to be built
+ Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, const FIELD<double> * c,int flag_mesh=1);
+ // fonctions d'acces sures
+ inline Wrapper_Nuage_Noeud<DIMENSION> * Get_Nuage_Noeuds ( void );
+ inline Meta_Nuage_Maille * Get_Nuage_Mailles ( void );
+ inline Meta_Maillage * Get_Maillage ( void );
+ inline Wrapper_MED_Field * Get_Champ ( void );
+ inline void Change_Champ ( const FIELD<double> * medfield );
+};
+
+/*********************************************************/
+/* */
+/* Meta_Calcul_Interpolation_Hybride */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Meta_Calcul_Interpolation_Hybride : public Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>
+{
+public :
+ Meta_Calcul_Interpolation_Hybride(Meta_Wrapper<DIMENSION> * MW):Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(MW->Get_Nuage_Noeuds(),MW->Get_Nuage_Mailles(),MW->Get_Champ()) {}
+ Valeur<double> operator() (Wrapper_Noeud<DIMENSION> & node, int num_maille){return Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>::operator()(node,num_maille);}
+ Valeur<double> operator() (double * node, int num_maille)
+ {
+ static Wrapper_Noeud<DIMENSION> tmp;
+ tmp.positionne(node);
+ return Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(tmp,num_maille);
+ }
+};
+
+/*********************************************************/
+/* */
+/* Meta_Calcul_Interpolation_Hybride_P1 */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Meta_Calcul_Interpolation_Hybride_P1 : public Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>
+{
+public :
+ Meta_Calcul_Interpolation_Hybride_P1(Meta_Wrapper<DIMENSION> * MW)
+ {
+
+ Wrapper_Nuage_Noeud<DIMENSION> * nn = MW->Get_Nuage_Noeuds();
+ Meta_Nuage_Maille * nm = MW->Get_Nuage_Mailles();
+ Wrapper_MED_Field * c = MW->Get_Champ();
+
+ mailles=nm;
+
+ fonctions[MED_TRIA3 ]=new Calcul_Interpolation_Tria3 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_QUAD4 ]=new Calcul_Interpolation_Quad4 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_TETRA4 ]=new Calcul_Interpolation_Tetra4 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_HEXA8 ]=new Calcul_Interpolation_Hexa8 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_PENTA6 ]=new Calcul_Interpolation_Penta6 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_PYRA5 ]=new Calcul_Interpolation_Pyra5 <Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(nn,nm,c);
+ fonctions[MED_TRIA6 ]=fonctions[MED_TRIA3 ];
+ fonctions[MED_QUAD8 ]=fonctions[MED_QUAD4 ];
+ fonctions[MED_TETRA10]=fonctions[MED_TETRA4 ];
+ fonctions[MED_HEXA20 ]=fonctions[MED_HEXA8 ];
+ fonctions[MED_PENTA15]=fonctions[MED_PENTA6 ];
+ fonctions[MED_PYRA13 ]=fonctions[MED_PYRA5 ];
+ }
+ Valeur<double> operator() (Wrapper_Noeud<DIMENSION> & node, int num_maille){return Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>::operator()(node,num_maille);}
+ Valeur<double> operator() (double * node, int num_maille)
+ {
+ static Wrapper_Noeud<DIMENSION> tmp;
+ tmp.positionne(node);
+ return Calcul_Hybride<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(tmp,num_maille);
+ }
+};
+
+/*********************************************************/
+/* */
+/* Meta_Calcul_Interpolation_P0 */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Meta_Calcul_Interpolation_P0 : public Calcul_Interpolation_P0<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>
+{
+public :
+ Meta_Calcul_Interpolation_P0(Meta_Wrapper<DIMENSION> * MW):Calcul_Interpolation_P0<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(MW->Get_Nuage_Noeuds(),MW->Get_Nuage_Mailles(),MW->Get_Champ()) {}
+ Valeur<double> operator() (Wrapper_Noeud<DIMENSION> & node, int num_maille){return Calcul_Interpolation_P0<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>::operator()(node,num_maille);}
+ Valeur<double> operator() (double * node, int num_maille)
+ {
+ static Wrapper_Noeud<DIMENSION> tmp;
+ tmp.positionne(node);
+ return Calcul_Interpolation_P0<Wrapper_MED_Field,Valeur<double>,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,Meta_Nuage_Maille>(tmp,num_maille);
+ }
+};
+
+/*********************************************************/
+/* */
+/* Meta_Interpolateur */
+/* */
+/*********************************************************/
+
+template <class FONCTEUR, int DIMENSION> class Meta_Interpolateur
+{
+protected :
+ FONCTEUR * fct;
+ Meta_Mapping<DIMENSION> * mapping;
+ Meta_Wrapper<DIMENSION> * fromWrapper;
+public :
+ Meta_Interpolateur():fct(NULL),mapping(NULL),fromWrapper(NULL) {}
+ Meta_Interpolateur(Meta_Mapping<DIMENSION> * map, Meta_Wrapper<DIMENSION> * mw):mapping(map),fromWrapper(mw),fct(new FONCTEUR(mw)){}
+ ~Meta_Interpolateur() {if (fct) delete fct;}
+ Wrapper_MED_Field Perform_Interpolation(Wrapper_Nuage_Noeud<DIMENSION> * toNodes)
+ {
+ int i;
+
+ int ni=0;
+ int ne=0;
+
+ int nbr_composantes = fromWrapper->Get_Champ()->Get_Nbr_Composantes();
+ int nbr_valeurs = toNodes->SIZE();
+
+ double * valeurs=new double[nbr_valeurs*nbr_composantes];
+
+ Wrapper_MED_Field resultat(nbr_valeurs,nbr_composantes,valeurs);
+
+ int nlpp,nmc;
+
+ for (i=0;i<nbr_valeurs;i++)
+ {
+ //cout<<"Interpolation du noeud "<<i<<flush;
+ nmc = (*mapping)[i];
+ //cout<<" | mappé dans la maille "<<nmc<<flush;
+ //cout<<" | coordonnées = "<<flush<<(*toNodes)[i]<<flush;
+ if (nmc>=0)
+ {
+ //cout<<" | valeurs qui va etre assignée = "<<flush<<(*fct)((*toNodes)[i],nmc)<<flush;
+ resultat[i]=(*fct)((*toNodes)[i],nmc);
+ ni++;
+ }
+ else
+ {
+ nlpp = mapping->Get_Noeud_Le_Plus_Proche(i);
+ //cout<<" | et dont le point le plus proche a pour numéro : "<<nlpp<<flush;
+ //cout<<" | valeurs qui va etre assignée = "<<(*fromWrapper->Get_Champ())[nlpp]<<flush;
+ if (nlpp!=UNDEFINED)
+ {
+ resultat[i]=(*fromWrapper->Get_Champ())[nlpp];
+ ne++;
+ }
+ else
+ {
+ cerr<<"Meta_Interpolateur : Le noeud "<<i+1<<" n'a ni maille contenante, ni point le plus proche"<<flush;
+ exit(-1);
+ }
+ }
+ //cout<<" | => OK ! "<<endl;
+ }
+
+ cout<<"Résultat de l'interpolation : "<<endl;
+ cout<<"Nombre de noeuds intérieurs = "<<ni<<endl;
+ cout<<"Nombre de noeuds extérieurs = "<<ne<<endl;
+
+ return resultat;
+
+ }
+};
+
+
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Meta_dTree */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> inline int Meta_dTree<DIMENSION>::trouve_plus_proche_point(double *node)
+ {
+ static Wrapper_Noeud<DIMENSION> nodetmp;
+ nodetmp.positionne(node);
+ return dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>::trouve_plus_proche_point(Wrapper_Noeud<DIMENSION>(nodetmp));
+ }
+// PATCH
+template <int DIMENSION> inline int Meta_dTree<DIMENSION>::trouve_plus_proche_point_bourrin(double *node)
+ {
+ static Wrapper_Noeud<DIMENSION> nodetmp;
+ nodetmp.positionne(node);
+ return dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>::trouve_plus_proche_point_bourrin(Wrapper_Noeud<DIMENSION>(nodetmp));
+ }
+/*********************************************************/
+/* */
+/* Meta_Nuage_Maille */
+/* */
+/*********************************************************/
+
+inline Meta_Nuage_Maille::Meta_Nuage_Maille(CONNECTIVITY * conmed):Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>(connectivite_med=new Wrapper_Med_Connectivity(conmed))
+ {
+ }
+
+/*********************************************************/
+/* */
+/* Meta_Mapping */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> inline int Meta_Mapping<DIMENSION>::Trouve_Maille_Contenant_Noeud(double * node,int num_maille,int flag_convexe)
+ {
+ int interdit=num_maille;
+ int max_loop=100;
+ int nme=0;
+ static Wrapper_Noeud<DIMENSION> nodetmp;
+ nodetmp.positionne(node);
+ return Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>::Trouve_Maille_Contenant_Point_Mth_Co(nodetmp,num_maille,interdit,max_loop,nme,flag_convexe);
+ }
+
+/*********************************************************/
+/* */
+/* Meta_Wrapper */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> Meta_Wrapper<DIMENSION>::~Meta_Wrapper()
+ {
+ if ( noeuds ) delete noeuds ;
+ if ( mailles ) delete mailles ;
+ if ( maillage ) delete maillage ;
+ if ( champ ) delete champ ;
+ }
+template <int DIMENSION> inline void Meta_Wrapper<DIMENSION>::Construit_Wrapper_Nuage_Noeud ( int nn, double * nodes )
+ {
+ if (nodes) noeuds=new Wrapper_Nuage_Noeud<DIMENSION>(nn,nodes);
+ else
+ {
+ cerr<<"Meta_Wrapper : Nuage MED_FULL_INTERLACE vide passé en argument au constructeur"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> inline void Meta_Wrapper<DIMENSION>::Construit_Wrapper_Nuage_Maille ( CONNECTIVITY * connmed )
+ {
+ if (connmed) mailles=new Meta_Nuage_Maille(connmed);
+ else
+ {
+ cerr<<"Meta_Wrapper : CONNECTIVITY vide passée en argument au constructeur"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> inline void Meta_Wrapper<DIMENSION>::Construit_Wrapper_Maillage ( void )
+ {
+ if (mailles==NULL)
+ {
+ cerr<<"Meta_Wrapper : Le nuage de maille n'a pas été initialisé !"<<endl;
+ exit(-1);
+ }
+ if (noeuds==NULL)
+ {
+ cerr<<"Meta_Wrapper : Le nuage de noeuds n'a pas été initialisé !"<<endl;
+ exit(-1);
+ }
+ maillage=new Meta_Maillage(mailles,noeuds->SIZE());
+ }
+template <int DIMENSION> inline void Meta_Wrapper<DIMENSION>::Construit_Wrapper_Champ ( const FIELD<double> * medfield )
+ {
+ if (medfield) champ=new Wrapper_MED_Field(medfield);
+ else
+ {
+ cerr<<"Meta_Wrapper : FIELD MED vide passé en argument au constructeur"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> inline void Meta_Wrapper<DIMENSION>::Change_Champ ( const FIELD<double> * medfield )
+ {
+ if (medfield)
+ {
+ if (champ) delete champ;
+ champ=new Wrapper_MED_Field(medfield);
+ }
+ else
+ {
+ cerr<<"Meta_Wrapper : FIELD MED vide passé en argument Change_Champ"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> Meta_Wrapper<DIMENSION>::Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, int flag_maillage)
+ {
+ init();
+ Construit_Wrapper_Nuage_Noeud(nn,nodes);
+ Construit_Wrapper_Nuage_Maille(connmed);
+ if (flag_maillage) Construit_Wrapper_Maillage();
+ }
+template <int DIMENSION> Meta_Wrapper<DIMENSION>::Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, const FIELD<double> * c,int flag_maillage)
+ {
+ init();
+ Construit_Wrapper_Nuage_Noeud(nn,nodes);
+ Construit_Wrapper_Nuage_Maille(connmed);
+ if (flag_maillage) Construit_Wrapper_Maillage();
+ Construit_Wrapper_Champ(c);
+ }
+template <int DIMENSION> Meta_Wrapper<DIMENSION>::Meta_Wrapper(int nn,double *nodes)
+ {
+ init();
+ Construit_Wrapper_Nuage_Noeud(nn,nodes);
+ }
+template <int DIMENSION> inline Wrapper_Nuage_Noeud<DIMENSION> * Meta_Wrapper<DIMENSION>::Get_Nuage_Noeuds ( void )
+ {
+ if (noeuds) return noeuds;
+ else
+ {
+ cerr<<"Meta_Wrapper : Nuage noeuds demandé alors qu'il n'est pas construit !"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> inline Meta_Nuage_Maille * Meta_Wrapper<DIMENSION>::Get_Nuage_Mailles ( void )
+ {
+ if (mailles) return mailles ;
+ else
+ {
+ cerr<<"Meta_Wrapper : Nuage mailles demandé alors qu'il n'est pas construit !"<<endl;
+ exit(-1);
+ }
+ }
+template <int DIMENSION> inline Meta_Maillage * Meta_Wrapper<DIMENSION>::Get_Maillage ( void )
+ {
+ if (maillage) return maillage ;
+ else
+ {
+ cerr<<"Meta_Wrapper : Connectivitée maillage demandée alors qu'elle n'est pas construite !"<<endl;
+ exit(-1);
+ }
+ }
+
+template <int DIMENSION> inline Wrapper_MED_Field * Meta_Wrapper<DIMENSION>::Get_Champ ( void )
+ {
+ if (champ) return champ;
+ else
+ {
+ cerr<<"Meta_Wrapper : Champ demandé alors qu'il n'est pas construit !"<<endl;
+ exit(-1);
+ }
+ }
+
+#endif
--- /dev/null
+#ifndef MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX
+
+#define MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_WrapperConnectivity.hxx"
+#include "MEDMEM_dTree.hxx"
+#include "MEDMEM_WrapperNodes.hxx"
+#include "MEDMEM_WrapperMesh.hxx"
+#include "MEDMEM_WrapperCells.hxx"
+#include "MEDMEM_Mapping.hxx"
+
+// DECLARATIONS
+
+template <int DIMENSION> class Meta_dTree : public dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>
+{
+protected :
+ Wrapper_Nuage_Noeud<DIMENSION> * nuagetmp;
+public :
+ Meta_dTree(int nn,double * fullinterlace);
+ ~Meta_dTree() {if ((etat==DTREE_RACINE)&&(nuagetmp)) delete nuagetmp;}
+ inline int trouve_plus_proche_point(double *node);
+};
+
+class Meta_Nuage_Maille : public Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>
+{
+protected :
+ Wrapper_Med_Connectivity * connectivite_med;
+public :
+ Meta_Nuage_Maille(CONNECTIVITY * connmed);
+ Meta_Nuage_Maille():Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>(connectivite_med=new Wrapper_Med_Connectivity) {}
+ ~Meta_Nuage_Maille() {if (connectivite_med) delete connectivite_med;}
+};
+
+
+typedef Wrapper_Maillage<Meta_Nuage_Maille> Meta_Maillage;
+
+template <int DIMENSION> class Meta_Mapping : public Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>
+{
+protected :
+ Wrapper_Nuage_Noeud<DIMENSION> * wrapping_nuage_source;
+ Wrapper_Nuage_Noeud<DIMENSION> * wrapping_nuage_cible;
+public :
+ Meta_Mapping(Meta_Maillage * mb,double * noeudssource,int ns,double * noeudscible,int nc);
+ ~Meta_Mapping() {if (wrapping_nuage_source) delete wrapping_nuage_source;if (wrapping_nuage_cible) delete wrapping_nuage_cible;}
+ inline int Trouve_Maille_Contenant_Noeud(double * node,int num_maille, int flag_convexe=0);
+ double donne_valeur_interpolee_P1(double * node,vector<double> vals);
+};
+
+// CODE
+
+template <int DIMENSION> Meta_dTree<DIMENSION>::Meta_dTree(int nn,double * fullinterlace)
+:dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>
+(nuagetmp=new Wrapper_Nuage_Noeud<DIMENSION>(nn,fullinterlace))
+ {
+ }
+
+template <int DIMENSION> inline int Meta_dTree<DIMENSION>::trouve_plus_proche_point(double *node)
+ {
+ static Wrapper_Noeud<DIMENSION> nodetmp;
+ nodetmp.positionne(node);
+ return dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>::trouve_plus_proche_point(Wrapper_Noeud<DIMENSION>(nodetmp));
+ }
+
+//*
+Meta_Nuage_Maille::Meta_Nuage_Maille(CONNECTIVITY * conmed):Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>(connectivite_med=new Wrapper_Med_Connectivity(conmed))
+ {
+ }
+//*/
+
+template <int DIMENSION> Meta_Mapping<DIMENSION>::Meta_Mapping(Meta_Maillage * mb,double * noeudssource,int ns,double * noeudscible,int nc)
+:Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>
+(mb,
+wrapping_nuage_source=new Wrapper_Nuage_Noeud<DIMENSION>(ns,noeudssource),
+wrapping_nuage_cible=new Wrapper_Nuage_Noeud<DIMENSION>(nc,noeudscible))
+ {
+ }
+
+template <int DIMENSION> inline int Meta_Mapping<DIMENSION>::Trouve_Maille_Contenant_Noeud(double * node,int num_maille,int flag_convexe)
+ {
+ int interdit=num_maille;
+ int max_loop=100;
+ int nme=0;
+ static Wrapper_Noeud<DIMENSION> nodetmp;
+ nodetmp.positionne(node);
+ return Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>::Trouve_Maille_Contenant_Point_Mth_Co(nodetmp,num_maille,interdit,max_loop,nme,flag_convexe);
+ }
+template <int DIMENSION> double Meta_Mapping<DIMENSION>::donne_valeur_interpolee_P1(double * node,vector<double> vals)
+ {
+ int num_maille_contenant=Trouve_Maille_Contenant_Noeud(node,0);
+ double valeur_interpol=0;
+ vector<double> valeurs=CB->Calcule_Coord_Baryc(num_maille_contenant,node);
+ int i;
+ int num_som;
+ for (i=0;i<valeurs.size();i++)
+ {
+ cout<<"Lambda(M):"<<i<<" = "<<valeurs[i]<<endl;
+ num_som=mailles_back->DONNE_SOMMET_MAILLE(num_maille_contenant,i);
+ valeur_interpol+=vals[num_som]*valeurs[i];
+ }
+
+ return valeur_interpol;
+ }
+
+#endif
--- /dev/null
+#ifndef MEDMEM_INTERPOLATION_TOOLS_HXX
+#define MEDMEM_INTERPOLATION_TOOLS_HXX
+
+#include "MEDMEM_define.hxx"
+
+#define _TEMPLATE_ template <class CHAMP,class VALEURCHAMP,class NUAGENOEUD, class NOEUD, class NUAGEMAILLE>
+#define _PARAM_ CHAMP,VALEURCHAMP,NUAGENOEUD,NOEUD,NUAGEMAILLE
+
+// ces macros définissent pour une face carrée plane la fonction projection sur cette face, non normalisée, la numérotation est dans le cas d'un hexaedre
+#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)))
+// des macros définissent pour une face triangulaire orientée vers l'extérieur de la maille la fonction de projection, non normalisée ( =(12^13).1M )
+#define face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x,y,z) ( ((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1))*(x-x1)+((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1))*(y-y1)+((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))*(z-z1) )
+#define projection(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0,x,y,z) (face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x,y,z)/face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0))
+
+// DECLARATION
+
+_TEMPLATE_ class Calcul_Interpolation
+{
+protected :
+ NUAGENOEUD * noeuds;
+ NUAGEMAILLE * mailles;
+ CHAMP * champ;
+public :
+ Calcul_Interpolation():noeuds(NULL),mailles(NULL),champ(NULL) {}
+ Calcul_Interpolation(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):noeuds(nn),mailles(nm),champ(c) {}
+ ~Calcul_Interpolation() {}
+ virtual VALEURCHAMP operator() (const NOEUD & n, int num_maille) {cerr<<"APPEL OPERATOR() DE LA CLASSE MERE CALCUL_INTERPOLATION => EXIT(-1)"<<endl;exit(-1);}
+};
+
+_TEMPLATE_ class Calcul_Interpolation_P0;
+
+_TEMPLATE_ class Calcul_Interpolation_Tria3;
+_TEMPLATE_ class Calcul_Interpolation_Tria6;
+_TEMPLATE_ class Calcul_Interpolation_Quad4;
+_TEMPLATE_ class Calcul_Interpolation_Quad8;
+_TEMPLATE_ class Calcul_Interpolation_Tetra4;
+_TEMPLATE_ class Calcul_Interpolation_Tetra10;
+_TEMPLATE_ class Calcul_Interpolation_Hexa8;
+_TEMPLATE_ class Calcul_Interpolation_Hexa20;
+_TEMPLATE_ class Calcul_Interpolation_Penta6;
+_TEMPLATE_ class Calcul_Interpolation_Penta15;
+_TEMPLATE_ class Calcul_Interpolation_Pyra5;
+_TEMPLATE_ class Calcul_Interpolation_Pyra13;
+
+_TEMPLATE_ class Calcul_Hybride
+{
+protected :
+ NUAGEMAILLE * mailles;
+ map<int,Calcul_Interpolation<_PARAM_> *> fonctions;
+public :
+ Calcul_Hybride():mailles(NULL) {}
+ Calcul_Hybride(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c);
+ ~Calcul_Hybride() {}
+ VALEURCHAMP operator() (const NOEUD & n, int num_maille);
+};
+
+//CODE
+
+_TEMPLATE_ Calcul_Hybride<_PARAM_>::Calcul_Hybride(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):mailles(nm)
+ {
+ fonctions[MED_TRIA3 ]=new Calcul_Interpolation_Tria3 <_PARAM_>(nn,nm,c);
+ fonctions[MED_TRIA6 ]=new Calcul_Interpolation_Tria6 <_PARAM_>(nn,nm,c);
+ fonctions[MED_QUAD4 ]=new Calcul_Interpolation_Quad4 <_PARAM_>(nn,nm,c);
+ fonctions[MED_QUAD8 ]=new Calcul_Interpolation_Quad8 <_PARAM_>(nn,nm,c);
+ fonctions[MED_TETRA4 ]=new Calcul_Interpolation_Tetra4 <_PARAM_>(nn,nm,c);
+ fonctions[MED_TETRA10]=new Calcul_Interpolation_Tetra10<_PARAM_>(nn,nm,c);
+ fonctions[MED_HEXA8 ]=new Calcul_Interpolation_Hexa8 <_PARAM_>(nn,nm,c);
+ fonctions[MED_HEXA20 ]=new Calcul_Interpolation_Hexa20 <_PARAM_>(nn,nm,c);
+ fonctions[MED_PENTA6 ]=new Calcul_Interpolation_Penta6 <_PARAM_>(nn,nm,c);
+ fonctions[MED_PENTA15]=new Calcul_Interpolation_Penta15<_PARAM_>(nn,nm,c);
+ fonctions[MED_PYRA5 ]=new Calcul_Interpolation_Pyra5 <_PARAM_>(nn,nm,c);
+ fonctions[MED_PYRA13 ]=new Calcul_Interpolation_Pyra13 <_PARAM_>(nn,nm,c);
+ }
+
+_TEMPLATE_ VALEURCHAMP Calcul_Hybride<_PARAM_>::operator() (const NOEUD & n, int num_maille)
+ {
+ return fonctions[(*mailles)[num_maille].DONNE_TYPE_MED_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)[num_maille][0];
+ int num1=(*mailles)[num_maille][1];
+ int num2=(*mailles)[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());
+
+ retour=(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)[num_maille][0];
+ int num1 =(*mailles)[num_maille][1];
+ int num2 =(*mailles)[num_maille][2];
+ int num01=(*mailles)[num_maille][3];
+ int num12=(*mailles)[num_maille][4];
+ int num20=(*mailles)[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)[num_maille][0];
+ int num1=(*mailles)[num_maille][1];
+ int num2=(*mailles)[num_maille][2];
+ int num3=(*mailles)[num_maille][3];
+
+ double x0=(*noeuds)[num0][0];
+ double y0=(*noeuds)[num0][1];
+ double x1=(*noeuds)[num1][0];
+ double y1=(*noeuds)[num1][1];
+ double x2=(*noeuds)[num2][0];
+ double y2=(*noeuds)[num2][1];
+ double x3=(*noeuds)[num3][0];
+ double y3=(*noeuds)[num3][1];
+
+ VALEURCHAMP v0=(*champ)[num0];
+ VALEURCHAMP v1=(*champ)[num1];
+ VALEURCHAMP v2=(*champ)[num2];
+ VALEURCHAMP v3=(*champ)[num3];
+
+ double x=n[0];
+ double y=n[1];
+
+
+ double mu0=-((x3*(y1-y2)+x1*(y2-y3)+x2*(y3-y1))*x*y+(x2*y2*(y1-y3)+x3*(-y1+y2)*y3+x1*y1*(y3-y2))*x+(x2*x3*(y2-y3)+x1*(x2*(y1-y2)+x3*(y3-y1)))*y+(x2*x3*y1*(y3-y2)+x1*(x3*y2*(y1-y3)+x2*(y2-y1)*y3)));
+ double mu1=(x0*(y2-y3)+x2*(y3-y0)+x3*(y0-y2))*x*y+(x3*y3*(y2-y0)+x0*(-y2+y3)*y0+x2*y2*(y0-y3))*x+(x3*x0*(y3-y0)+x2*(x3*(y2-y3)+x0*(y0-y2)))*y+(x2*x0*y2*(y0-y2)+x2*(x0*y2*(y2-y0)+x3*(y3-y2)*y0));
+ double mu2=-((x1*(y3-y0)+x3*(y0-y1)+x0*(y1-y3))*x*y+(x0*y0*(y3-y1)+x1*(-y3+y0)*y1+x3*y3*(y1-y0))*x+(x0*x1*(y0-y1)+x3*(x0*(y3-y0)+x1*(y1-y3)))*y+(x3*x1*y3*(y1-y2)+x3*(x1*y2*(y3-y1)+x0*(y0-y3)*y1)));
+ double mu3=(x2*(y0-y1)+x0*(y1-y2)+x1*(y2-y0))*x*y+(x1*y1*(y0-y2)+x2*(-y0+y1)*y2+x0*y0*(y2-y1))*x+(x1*x2*(y1-y2)+x0*(x1*(y0-y1)+x2*(y2-y0)))*y+(x0*x2*y0*(y2-y2)+x0*(x2*y2*(y0-y2)+x1*(y1-y0)*y2));
+
+ double delta=(y0-y2)*(y1-y3)*(x0*x2+x1*x3)-(x1*x2+x0*x3)*(y1-y2)*(y0-y3)-(x0*x1+x2*x3)*(y0-y1)*(y2-y3);
+
+ /*
+ cout<<" ### Pour ( "<<x<<" , "<<y<<" )"<<endl;
+ cout<<" ### delta = "<<delta<<endl;
+ cout<<" ### Mu0 = "<<mu0<<endl;
+ cout<<" ### Mu1 = "<<mu1<<endl;
+ cout<<" ### Mu2 = "<<mu2<<endl;
+ cout<<" ### Mu3 = "<<mu3<<endl;
+ //*/
+ VALEURCHAMP retour(v0.SIZE()); //
+
+ retour=(mu0*v0+mu1*v1+mu2*v2+mu3*v3)/delta;
+
+ return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Quad8 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Quad8(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ cerr<<"Interpolation Q2 pas encore implémentée"<<endl;
+ exit(-1);
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Tetra4 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Tetra4(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ int num0=(*mailles)[num_maille][0];
+ int num1=(*mailles)[num_maille][1];
+ int num2=(*mailles)[num_maille][2];
+ int num3=(*mailles)[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=face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x,y,z)/face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0);
+ double lambda1=face(x0,y0,z0,x2,y2,z2,x3,y3,z3,x,y,z)/face(x0,y0,z0,x2,y2,z2,x3,y3,z3,x1,y1,z1);
+ double lambda2=face(x1,y1,z1,x0,y0,z0,x3,y3,z3,x,y,z)/face(x1,y1,z1,x0,y0,z0,x3,y3,z3,x2,y2,z2);
+ double lambda3=face(x1,y1,z1,x2,y2,z2,x0,y0,z0,x,y,z)/face(x1,y1,z1,x2,y2,z2,x0,y0,z0,x3,y3,z3);
+
+ VALEURCHAMP retour(v0.SIZE()); //
+
+ retour=(lambda0*v0+lambda1*v1+lambda2*v2+lambda3*v3);
+
+ 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)[num_maille][0];
+ int num1 =(*mailles)[num_maille][1];
+ int num2 =(*mailles)[num_maille][2];
+ int num3 =(*mailles)[num_maille][3];
+ int num01=(*mailles)[num_maille][4];
+ int num02=(*mailles)[num_maille][6];
+ int num03=(*mailles)[num_maille][7];
+ int num12=(*mailles)[num_maille][5];
+ int num13=(*mailles)[num_maille][8];
+ int num23=(*mailles)[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=face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x,y,z)/face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0);
+ double lambda1=face(x0,y0,z0,x2,y2,z2,x3,y3,z3,x,y,z)/face(x0,y0,z0,x2,y2,z2,x3,y3,z3,x1,y1,z1);
+ double lambda2=face(x1,y1,z1,x0,y0,z0,x3,y3,z3,x,y,z)/face(x1,y1,z1,x0,y0,z0,x3,y3,z3,x2,y2,z2);
+ double lambda3=face(x1,y1,z1,x2,y2,z2,x0,y0,z0,x,y,z)/face(x1,y1,z1,x2,y2,z2,x0,y0,z0,x3,y3,z3);
+
+ /*
+ cout<<" ### Pour ( "<<x<<" , "<<y<<" , "<<z<<" )"<<endl;
+ cout<<" ### Lambda0 = "<<lambda0<<endl;
+ cout<<" ### Lambda1 = "<<lambda1<<endl;
+ cout<<" ### Lambda2 = "<<lambda2<<endl;
+ cout<<" ### Lambda3 = "<<lambda3<<endl;
+ cout<<" ### Controle = "<<(lambda0+lambda1+lambda2+lambda3)<<endl;
+ //*/
+
+ VALEURCHAMP retour(v0.SIZE()); //
+
+ retour=2*(lambda0*lambda0*v0+
+ lambda1*lambda1*v1+
+ lambda2*lambda2*v2+
+ lambda3*lambda3*v3+
+ 2*(lambda0*lambda1*v01+
+ lambda0*lambda2*v02+
+ lambda0*lambda3*v03+
+ lambda1*lambda2*v12+
+ lambda1*lambda3*v13+
+ lambda2*lambda3*v23))+
+ (-1.0)*(lambda0*v0+lambda1*v1+lambda2*v2+lambda3*v3);
+
+ return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Hexa8 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Hexa8(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+
+ // Tres probablement numériquement mauvais, à revoir
+
+ int num0=(*mailles)[num_maille][0];
+ int num1=(*mailles)[num_maille][1];
+ int num2=(*mailles)[num_maille][2];
+ int num3=(*mailles)[num_maille][3];
+ int num4=(*mailles)[num_maille][4];
+ int num5=(*mailles)[num_maille][5];
+ int num6=(*mailles)[num_maille][6];
+ int num7=(*mailles)[num_maille][7];
+
+
+ double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2];
+ double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2];
+ double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2];
+ double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2];
+ double x4=(*noeuds)[num4][0];double y4=(*noeuds)[num4][1];double z4=(*noeuds)[num4][2];
+ double x5=(*noeuds)[num5][0];double y5=(*noeuds)[num5][1];double z5=(*noeuds)[num5][2];
+ double x6=(*noeuds)[num6][0];double y6=(*noeuds)[num6][1];double z6=(*noeuds)[num6][2];
+ double x7=(*noeuds)[num7][0];double y7=(*noeuds)[num7][1];double z7=(*noeuds)[num7][2];
+
+
+ VALEURCHAMP v0=(*champ)[num0];
+ VALEURCHAMP v1=(*champ)[num1];
+ VALEURCHAMP v2=(*champ)[num2];
+ VALEURCHAMP v3=(*champ)[num3];
+ VALEURCHAMP v4=(*champ)[num4];
+ VALEURCHAMP v5=(*champ)[num5];
+ VALEURCHAMP v6=(*champ)[num6];
+ VALEURCHAMP v7=(*champ)[num7];
+
+ double x=n[0];
+ double y=n[1];
+ double z=n[2];
+
+ // double mu0=face1256(x,y,z)*face2367(x,y,z)*face4567(x,y,z)/(face1256(x0,y0,z0)*face2367(x0,y0,z0)*face4567(x0,y0,z0));
+ // double mu1=face0347(x,y,z)*face2367(x,y,z)*face4567(x,y,z)/(face0347(x1,y1,z1)*face2367(x1,y1,z1)*face4567(x1,y1,z1));
+ // double mu2=face0347(x,y,z)*face0145(x,y,z)*face4567(x,y,z)/(face0347(x2,y2,z2)*face0145(x2,y2,z2)*face4567(x2,y2,z2));
+ // double mu3=face1256(x,y,z)*face0145(x,y,z)*face4567(x,y,z)/(face1256(x3,y3,z3)*face0145(x3,y3,z3)*face4567(x3,y3,z3));
+ // double mu4=face1256(x,y,z)*face2367(x,y,z)*face0123(x,y,z)/(face1256(x4,y4,z4)*face2367(x4,y4,z4)*face0123(x4,y4,z4));
+ // double mu5=face0347(x,y,z)*face2367(x,y,z)*face0123(x,y,z)/(face0347(x5,y5,z5)*face2367(x5,y5,z5)*face0123(x5,y5,z5));
+ // double mu6=face0347(x,y,z)*face0145(x,y,z)*face0123(x,y,z)/(face0347(x6,y6,z6)*face0145(x6,y6,z6)*face0123(x6,y6,z6));
+ // double mu7=face1256(x,y,z)*face0145(x,y,z)*face0123(x,y,z)/(face1256(x7,y7,z7)*face0145(x7,y7,z7)*face0123(x7,y7,z7));
+
+ double mu0=projection(x1,y1,z1,x2,y2,z2,x6,y6,z6,x0,y0,z0,x,y,z)*projection(x2,y2,z2,x3,y3,z3,x7,y7,z7,x0,y0,z0,x,y,z)*projection(x4,y4,z4,x5,y5,z5,x6,y6,z6,x0,y0,z0,x,y,z);
+ double mu1=projection(x0,y0,z0,x3,y3,z3,x7,y7,z7,x1,y1,z1,x,y,z)*projection(x2,y2,z2,x3,y3,z3,x7,y7,z7,x1,y1,z1,x,y,z)*projection(x4,y4,z4,x5,y5,z5,x6,y6,z6,x1,y1,z1,x,y,z);
+ double mu2=projection(x0,y0,z0,x3,y3,z3,x7,y7,z7,x2,y2,z2,x,y,z)*projection(x0,y0,z0,x1,y1,z1,x5,y5,z5,x2,y2,z2,x,y,z)*projection(x4,y4,z4,x5,y5,z5,x6,y6,z6,x2,y2,z2,x,y,z);
+ double mu3=projection(x1,y1,z1,x2,y2,z2,x6,y6,z6,x3,y3,z3,x,y,z)*projection(x0,y0,z0,x1,y1,z1,x5,y5,z5,x3,y3,z3,x,y,z)*projection(x4,y4,z4,x6,y6,z6,x7,y7,z7,x3,y3,z3,x,y,z);
+ double mu4=projection(x2,y2,z2,x6,y6,z6,x5,y5,z5,x4,y4,z4,x,y,z)*projection(x2,y2,z2,x3,y3,z3,x7,y7,z7,x4,y4,z4,x,y,z)*projection(x0,y0,z0,x1,y1,z1,x2,y2,z2,x4,y4,z4,x,y,z);
+ double mu5=projection(x3,y3,z3,x7,y7,z7,x4,y4,z4,x5,y5,z5,x,y,z)*projection(x2,y2,z2,x3,y3,z3,x6,y6,z6,x5,y5,z5,x,y,z)*projection(x0,y0,z0,x1,y1,z1,x2,y2,z2,x5,y5,z5,x,y,z);
+ double mu6=projection(x3,y3,z3,x7,y7,z7,x4,y4,z4,x6,y6,z6,x,y,z)*projection(x1,y1,z1,x5,y5,z5,x4,y4,z4,x6,y6,z6,x,y,z)*projection(x0,y0,z0,x1,y1,z1,x2,y2,z2,x6,y6,z6,x,y,z);
+ double mu7=projection(x2,y2,z2,x6,y6,z6,x5,y5,z5,x7,y7,z7,x,y,z)*projection(x1,y1,z1,x5,y5,z5,x4,y4,z4,x7,y7,z7,x,y,z)*projection(x0,y0,z0,x1,y1,z1,x3,y3,z3,x7,y7,z7,x,y,z);
+
+ VALEURCHAMP retour(v0.SIZE()); //
+
+ retour=(mu0*v0+mu1*v1+mu2*v2+mu3*v3+mu4*v4+mu5*v5+mu6*v6+mu7*v7);
+
+ return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Hexa20 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Hexa20(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ cerr<<"Interpolation H2 pasencore implémentée"<<endl;
+ exit(-1);
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Penta6 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Penta6(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ int num0=(*mailles)[num_maille][0];
+ int num1=(*mailles)[num_maille][1];
+ int num2=(*mailles)[num_maille][2];
+ int num3=(*mailles)[num_maille][3];
+ int num4=(*mailles)[num_maille][4];
+ int num5=(*mailles)[num_maille][5];
+
+ double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2];
+ double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2];
+ double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2];
+ double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2];
+ double x4=(*noeuds)[num4][0];double y4=(*noeuds)[num4][1];double z4=(*noeuds)[num4][2];
+ double x5=(*noeuds)[num5][0];double y5=(*noeuds)[num5][1];double z5=(*noeuds)[num5][2];
+
+ VALEURCHAMP v0=(*champ)[num0];
+ VALEURCHAMP v1=(*champ)[num1];
+ VALEURCHAMP v2=(*champ)[num2];
+ VALEURCHAMP v3=(*champ)[num3];
+ VALEURCHAMP v4=(*champ)[num4];
+ VALEURCHAMP v5=(*champ)[num5];
+
+ double x=n[0];
+ double y=n[1];
+ double z=n[2];
+
+ double mu0=face(x1,y1,z1,x2,y2,z2,x5,y5,z5,x,y,z)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x,y,z)/(face(x1,y1,z1,x2,y2,z2,x5,y5,z5,x0,y0,z0)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x0,y0,z0));
+ double mu1=face(x0,y0,z0,x2,y2,z2,x5,y5,z5,x,y,z)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x,y,z)/(face(x0,y0,z0,x2,y2,z2,x5,y5,z5,x1,y1,z1)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x1,y1,z1));
+ double mu2=face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x,y,z)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x,y,z)/(face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x2,y2,z2)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x2,y2,z2));
+ double mu3=face(x1,y1,z1,x2,y2,z2,x5,y5,z5,x,y,z)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x,y,z)/(face(x1,y1,z1,x2,y2,z2,x5,y5,z5,x3,y3,z3)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x3,y3,z3));
+ double mu4=face(x0,y0,z0,x2,y2,z2,x5,y5,z5,x,y,z)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x,y,z)/(face(x0,y0,z0,x2,y2,z2,x5,y5,z5,x4,y4,z4)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x4,y4,z4));
+ double mu5=face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x,y,z)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x,y,z)/(face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x5,y5,z5)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x5,y5,z5));
+
+ VALEURCHAMP retour(v0.SIZE()); //
+
+ retour=(mu0*v0+mu1*v1+mu2*v2+mu3*v3+mu4*v4+mu5*v5);
+
+ return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Penta15 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Penta15(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ cerr<<"Interpolation Pe2 pasencore implémentée"<<endl;
+ exit(-1);
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Pyra5 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Pyra5(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ // NON TESTE
+ int num0=(*mailles)[num_maille][0];
+ int num1=(*mailles)[num_maille][1];
+ int num2=(*mailles)[num_maille][2];
+ int num3=(*mailles)[num_maille][3];
+ int num4=(*mailles)[num_maille][4];
+
+ double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2];
+ double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2];
+ double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2];
+ double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2];
+ double x4=(*noeuds)[num4][0];double y4=(*noeuds)[num4][1];double z4=(*noeuds)[num4][2];
+
+ VALEURCHAMP v0=(*champ)[num0];
+ VALEURCHAMP v1=(*champ)[num1];
+ VALEURCHAMP v2=(*champ)[num2];
+ VALEURCHAMP v3=(*champ)[num3];
+ VALEURCHAMP v4=(*champ)[num4];
+
+ double x=n[0];
+ double y=n[1];
+ double z=n[2];
+
+ double mu0=face(x1,y1,z1,x2,y2,z2,x4,y4,z4,x,y,z)*face(x2,y2,z2,x3,y3,z3,x4,y4,z4,x,y,z)/(face(x1,y1,z1,x2,y2,z2,x4,y4,z4,x0,y0,z0)*face(x2,y2,z2,x3,y3,z3,x4,y4,z4,x0,y0,z0));
+ double mu1=face(x0,y0,z0,x3,y3,z3,x4,y4,z4,x,y,z)*face(x2,y2,z2,x3,y3,z3,x4,y4,z4,x,y,z)/(face(x0,y0,z0,x3,y3,z3,x4,y4,z4,x1,y1,z1)*face(x2,y2,z2,x3,y3,z3,x4,y4,z4,x1,y1,z1));
+ double mu2=face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x,y,z)*face(x0,y0,z0,x3,y3,z3,x4,y4,z4,x,y,z)/(face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x2,y2,z2)*face(x0,y0,z0,x3,y3,z3,x4,y4,z4,x2,y2,z2));
+ double mu3=face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x,y,z)*face(x1,y1,z1,x2,y2,z2,x4,y4,z4,x,y,z)/(face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x3,y3,z3)*face(x1,y1,z1,x2,y2,z2,x4,y4,z4,x3,y3,z3));
+ double mu4=face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x,y,z)/face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x4,y4,z4);
+
+ VALEURCHAMP retour(v0.SIZE()); //
+
+ retour=(mu0*v0+mu1*v1+mu2*v2+mu3*v3+mu4*v4);
+
+ return retour; //
+ }
+};
+_TEMPLATE_ class Calcul_Interpolation_Pyra13 : public Calcul_Interpolation<_PARAM_>
+{
+public : Calcul_Interpolation_Pyra13(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {}
+public : VALEURCHAMP operator() (const NOEUD & n, int num_maille)
+ {
+ cerr<<"Interpolation Py2 pasencore implémentée"<<endl;
+ exit(-1);
+ }
+};
+
+#undef _TEMPLATE_
+#undef _PARAM_
+
+#endif
--- /dev/null
+#ifndef MEDMEM_MAPPING_HXX
+#define MEDMEM_MAPPING_HXX
+
+#include "MEDMEM_MappingTools.hxx"
+#include "MEDMEM_dTree.hxx"
+
+#define NBR_MAX_MAILLES_EXAMINEES 100
+
+#ifndef NBR_FACES_MAX
+#define NBR_FACES_MAX 6
+#endif
+
+#define _TEMPLATE_ template <class MAILLAGE, class NUAGEMAILLE, class NUAGENOEUD, class NOEUD, int DIMENSION>
+#define _MAPPING_ Mapping<MAILLAGE,NUAGEMAILLE,NUAGENOEUD,NOEUD,DIMENSION>
+
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Classe Mapping */
+/* */
+/*********************************************************/
+
+// ATTENTION LE NUAGE DE NOEUD EST SUPPOSE NON REDONDANT ET AUCUNE VERIFICATION N'EST FAITE !
+
+template <class MAILLAGE, class NUAGEMAILLE, class NUAGENOEUD, class NOEUD, int DIMENSION> class Mapping
+{
+protected :
+ MAILLAGE * maillage_back;
+ NUAGEMAILLE * mailles_back;
+ NUAGENOEUD * noeuds_back;
+ NUAGENOEUD * noeuds_front;
+ Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,DIMENSION> * CB;
+ dTree<NOEUD,NUAGENOEUD,DIMENSION> * my_dTree;
+ vector<int> resultat_mapping;
+ vector<int> point_le_plus_proche;
+
+public :
+
+ Mapping():maillage_back(NULL),mailles_back(NULL),noeuds_back(NULL),noeuds_front(NULL),CB(NULL),my_dTree(NULL) {}
+ Mapping(MAILLAGE * mb,NUAGENOEUD * nb,NUAGENOEUD * nf); // le dTree est crée à l'initialisation, par contre, le mapping lui meme doit etre invoqué
+ ~Mapping() {if (CB) delete CB;if (my_dTree) delete my_dTree;}
+ dTree<NOEUD,NUAGENOEUD,DIMENSION> * Donne_dTree() {return my_dTree;}
+ int Donne_Directions(int num_maille,const NOEUD &n,int etat_face[NBR_FACES_MAX]);
+ // Méthode interne de localisation
+ int Trouve_Maille_Contenant_Point_Mth_Co(const NOEUD &n,int num_maille,int num_maille_interdit,int max_loop,int &nbr_mailles_examinees,int flag_convexe);
+ void Cree_Mapping(int flag_convexe=0); // SUPPOSE NON CONVEXE PAR DEFAUT
+ void Cree_Mapping(NUAGENOEUD * nf, int flag_convexe=0); // SUPPOSE NON CONVEXE PAR DEFAUT
+ inline int operator[](int i) const {return resultat_mapping[i];} // Renvoie la valeur mappé, si le mapping a été fait, sinon, n'importe quoi
+ inline vector<int> & Get_Mapping() {return resultat_mapping;} // Renvoie le vector contenant le mapping
+ inline int Get_Noeud_Le_Plus_Proche(int i) const {return point_le_plus_proche[i];} // Invoque la méthode de d-Tree qui donne le noeud le plus proche
+ inline int Exist_dTree() const {return (my_dTree);} // Teste si le dTree existe
+ void affiche()
+ {
+ for (int i=0;i<resultat_mapping.size();i++) cout<<"Noeud "<<i<<" de noeud plus proche "<<point_le_plus_proche[i]<<" mappé dans maille "<<resultat_mapping[i]<<endl;
+ }
+};
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// 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 (resultat_mapping.size()==0)
+ {
+ if (!noeuds_front)
+ {
+ cerr<<"Mapping : Pas de noeuds à mapper !"<<endl;
+ exit(-1);
+ }
+
+ int i,j,k;
+ int nbr_noeuds=noeuds_front->SIZE();
+ int num_maille_depart;
+ int nma=0;
+ resultat_mapping = vector<int>(nbr_noeuds,UNDEFINED);
+ point_le_plus_proche = vector<int>(nbr_noeuds,UNDEFINED);
+
+ // noeuds_back->affiche();
+
+ for (i=0;i<nbr_noeuds;i++)
+ {
+ point_le_plus_proche[i]=my_dTree->trouve_plus_proche_point((*noeuds_front)[i]);
+ num_maille_depart=maillage_back->DONNE_PREMIERE_MAILLE_CONTENANT(point_le_plus_proche[i]);
+ resultat_mapping[i]=Trouve_Maille_Contenant_Point_Mth_Co((*noeuds_front)[i],num_maille_depart,num_maille_depart,NBR_MAX_MAILLES_EXAMINEES,nma,flag_convexe);
+ }
+ }
+
+ else
+ {
+ cout<<"Le mapping semble déja existé, interrogation sur l'existant"<<endl;
+ }
+
+ }
+_TEMPLATE_ _MAPPING_::Mapping(MAILLAGE * mb,NUAGENOEUD * nb,NUAGENOEUD * nf):maillage_back(mb),noeuds_back(nb),noeuds_front(nf),my_dTree(NULL)
+ {
+
+ if (!maillage_back)
+ {
+ cerr<<"Mapping : constructeur appelé avec Maillage Vide"<<endl;
+ exit(-1);
+ }
+
+ if (!noeuds_back)
+ {
+ cerr<<"Mapping : constructeur appelé avec Nuage Noeuds Vide"<<endl;
+ exit(-1);
+ }
+
+ mailles_back=maillage_back->DONNE_POINTEUR_NUAGEMAILLE();
+
+ CB=new Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,DIMENSION>(mailles_back,noeuds_back);
+
+ // TEST REDONDANCE
+ /*
+ int nnb=noeuds_back->SIZE();
+ if (nnb<20000)
+ {
+ cout<<"MAPPING : VERIFICATION REDONDANCES DANS NUAGE NOEUD BACK"<<endl;
+ noeuds_back->affiche();
+ int i,j;
+ vector<int> redondance(nnb,0);
+ for (i=0;i<nnb;i++)
+ {
+ for (j=i+1;j<nnb;j++) if ((*noeuds_back)[i]==(*noeuds_back)[j])
+ {
+ cerr<<"Le Noeud "<<j<<" est identique au Noeud "<<i<<endl;
+ exit(-1);
+ }
+ }
+ cout<<"FIN TEST VERIFICATION REDONDANCES"<<endl;
+ }
+ // FIN TEST */
+
+ my_dTree=new dTree<NOEUD,NUAGENOEUD,DIMENSION>(noeuds_back);
+
+ }
+// Renvoie :
+// 1 si le point est intérieur
+// -1 si le point est extérieur à la maille via uniquement des faces qui ne sont pas au bord
+// -2 si le point est extérieur à la maille par au moins une face de bord
+// Et modifie etat_face de telle sorte que :
+// etat_face[i] = -1 s'il n'existe pas de voisin via la face i
+// etat_face[i] = 0 si le point est intérieur via la face i et que le voisin i existe
+// etat_face[i] = 1 si le point est extérieur via la face i et que le voisin i existe
+_TEMPLATE_ int _MAPPING_::Donne_Directions(int num_maille,const NOEUD &n,int etat_face[NBR_FACES_MAX])
+ {
+ vector<double> ef=CB->Donne_Pseudo_Coord_Baryc(num_maille,n);
+ int etat_int=VRAI;
+ int etat_ext_bord=FAUX;
+ int tf,tv,tb;
+ int nbr_faces=(*mailles_back)[num_maille].DONNE_NBR_FACES();
+ for (int i=0;i<nbr_faces;i++)
+ {
+ tf=(ef[i]<0);
+ tv=(maillage_back->DONNE_VOISIN_DE_MAILLE(num_maille,i)==UNDEFINED);
+ tb=(maillage_back->EST_AU_BORD_FACE_DE_MAILLE(num_maille,i));
+ if (tf)
+ {
+ etat_int=FAUX;
+ if (tb) etat_ext_bord=VRAI;
+ }
+ if (tv) etat_face[i]=-1;
+ else
+ {
+ if (tf) etat_face[i]=1;
+ else etat_face[i]=0;
+ }
+ }
+ if (etat_int) return 1;
+ if (etat_ext_bord) return -2;
+ return -1;
+ }
+_TEMPLATE_ int _MAPPING_::Trouve_Maille_Contenant_Point_Mth_Co(const NOEUD &n,int num_maille,int num_maille_interdit,int max_loop,int &nbr_mailles_examinees,int flag_convexe)
+ {
+
+ int etat_face[NBR_FACES_MAX];
+ int i,tmp,nbr_rnd;
+ int indirection[NBR_FACES_MAX];
+ int ind_reel;
+ int num_reel;
+ int new_num=UNDEFINED;
+
+ int test=Donne_Directions(num_maille,n,etat_face);
+
+ int nbr_faces=maillage_back->DONNE_NBR_FACES_MAILLE(num_maille);
+
+ for (i=0;i<nbr_faces;i++) indirection[i]=i;
+
+ nbr_mailles_examinees=0;
+
+ while (nbr_mailles_examinees<max_loop)
+ {
+ if (test==1)
+ {
+ return num_maille;
+ }
+ if ((test==-2)&&(flag_convexe))
+ {
+ return 2*UNDEFINED;
+ }
+ nbr_mailles_examinees++;
+ for (i=0;i<nbr_faces;i++)
+ {
+ tmp=indirection[i];
+ nbr_rnd=rand()%nbr_faces;
+ indirection[i]=indirection[nbr_rnd];
+ indirection[nbr_rnd]=tmp;
+ }
+ for (i=0;(i<nbr_faces)&&(new_num==UNDEFINED);i++)
+ {
+ ind_reel=indirection[i];
+ num_reel=maillage_back->DONNE_VOISIN_DE_MAILLE(num_maille,ind_reel);
+ if ((etat_face[ind_reel]==1)&&(num_reel!=num_maille_interdit))
+ {
+ new_num=num_reel;
+ }
+ }
+ for (i=0;(i<nbr_faces)&&(new_num==UNDEFINED);i++)
+ {
+ ind_reel=indirection[i];
+ num_reel=maillage_back->DONNE_VOISIN_DE_MAILLE(num_maille,ind_reel);
+ if ((etat_face[ind_reel]==0)&&(num_reel!=num_maille_interdit))
+ {
+ new_num=num_reel;
+ }
+ }
+ if (new_num==UNDEFINED)
+ {
+ new_num=num_maille_interdit;
+ }
+ num_maille_interdit=num_maille;
+ num_maille=new_num;
+ new_num=UNDEFINED;
+ test=Donne_Directions(num_maille,n,etat_face);
+ }
+ return UNDEFINED;
+ }
+
+#undef _TEMPLATE_
+#undef _MAPPING_
+
+#endif
--- /dev/null
+#ifndef COORDONNEES_BARYCENTRIQUES_HPP
+#define COORDONNEES_BARYCENTRIQUES_HPP
+
+#define _TEMPLATE_SPE_ template <class NUAGEMAILLE, class NUAGENOEUD, class NOEUD>
+#define _COORDBARYC_ Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,DIMENSION>
+#define _COORDBARY_2D_ Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,2>
+#define _COORDBARY_3D_ Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,3>
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Classe Coordonnees_Barycentriques */
+/* */
+/*********************************************************/
+
+// C'est la définition de la classe générique template qui n'est utilisée qu'à travers ses spécialisations
+// vu que le nombre de spécialisations a faire est petit (nombre de dimensions utilisée, 3 pour MED)
+// et vu que l'acces a ces classes doit etre rapide, car ce sont des classes de calcul
+// la technique de spécialisation, plus lourde, mais plus rapide, a été préférée aux techniques d'héritage
+
+template <class NUAGEMAILLE, class NUAGENOEUD, class NOEUD, int DIMENSION> class Coordonnees_Barycentriques
+{
+// TEMPLATE GENERIQUE VIDE OBLIGE DE PASSER PAR UNE SPECIALISATION
+};
+
+/*********************************************************/
+/* */
+/* Spécialisation 2D */
+/* */
+/*********************************************************/
+
+_TEMPLATE_SPE_ class _COORDBARY_2D_
+{
+protected :
+ NUAGEMAILLE * mailles;
+ NUAGENOEUD * sommets;
+
+ vector<int> etat_coord_baryc;
+ vector< vector< vector<double> > > coord_baryc;
+
+public :
+
+ Coordonnees_Barycentriques():mailles(NULL),sommets(NULL) {}
+ Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n);
+ ~Coordonnees_Barycentriques() {}
+ // donne les pseudos coordonnées barycentriques de M dans ma maille de numéro global num_maille dans mailles
+ // la pseudo coordonnées barycentrique par rapport a une face est la distance normalisée a cette face,
+ // dans le cas d'une face triangulaire, c'est la coordonnées ba
+ vector<double> Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M);
+ vector<double> Calcule_Base_Coord_Baryc(const vector<int> &simplexe_base);
+ vector<double> Calcule_Coord_Baryc(int num_maille, const NOEUD & M);
+};
+
+/*********************************************************/
+/* */
+/* Spécialisation 3D */
+/* */
+/*********************************************************/
+
+
+_TEMPLATE_SPE_ class _COORDBARY_3D_
+{
+protected :
+ NUAGEMAILLE * mailles;
+ NUAGENOEUD * sommets;
+
+ vector<int> etat_coord_baryc;
+ vector< vector< vector<double> > > coord_baryc;
+
+public :
+
+ Coordonnees_Barycentriques():mailles(NULL),sommets(NULL) {}
+ Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n);
+ ~Coordonnees_Barycentriques() {}
+ vector<double> Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M);
+ vector<double> Calcule_Base_Coord_Baryc(const vector<int> &simplexe_base);
+ vector<double> Calcule_Coord_Baryc(int num_maille, const NOEUD & M);
+};
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+_TEMPLATE_SPE_ _COORDBARY_2D_::Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n):mailles(m),sommets(n)
+ {
+ cout<<"Creation des Coordonnées Barycentriques : "<<flush;
+ int nbr_mailles=mailles->SIZE();
+ etat_coord_baryc=vector<int>(nbr_mailles,FAUX);
+ coord_baryc=vector< vector< vector<double> > >(nbr_mailles);
+ cout<<"OK ! "<<endl;
+ }
+
+_TEMPLATE_SPE_ vector<double> _COORDBARY_2D_::Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M)
+ {
+ int i,j,nbr_faces;
+ if (etat_coord_baryc[num_maille]==FAUX)
+ {
+ nbr_faces=(*mailles).DONNE_NBR_FACES();
+
+ coord_baryc[num_maille]=vector< vector<double> >(nbr_faces);
+
+ for (i=0;i<nbr_faces;i++)
+ {
+ vector<int> simplexe_base=(*mailles).DONNE_SIMPLEXE_BASE(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);
+ }
+
+_TEMPLATE_SPE_ vector<double> _COORDBARY_2D_::Calcule_Base_Coord_Baryc(const vector<int> &simplexe_base)
+ {
+ const vector<int> &ref=simplexe_base;
+ vector<double> retour(3);
+ int i,j;
+
+ double x0=(*sommets)[ref[0]][0];
+ double y0=(*sommets)[ref[0]][1];
+ double x1=(*sommets)[ref[1]][0];
+ double y1=(*sommets)[ref[1]][1];
+ double x2=(*sommets)[ref[2]][0];
+ double y2=(*sommets)[ref[2]][1];
+
+ double delta=(x1*y2-x2*y1)+(x2*y0-x0*y2)+(x0*y1-x1*y0);
+
+ retour[0]=(y1-y2)/delta;
+ retour[1]=(x2-x1)/delta;
+ retour[2]=(x1*y2-x2*y1)/delta;
+
+ return retour;
+ }
+
+_TEMPLATE_SPE_ vector<double> _COORDBARY_2D_::Calcule_Coord_Baryc(int num_maille, const NOEUD & M)
+ {
+ int i,j;
+ vector<double> coord_baryc_M(3,0);
+ for (i=0;i<3;i++)
+ {
+ for (j=0;j<2;j++) coord_baryc_M[i]+=coord_baryc[num_maille][i][j]*M[j];
+ coord_baryc_M[i]+=coord_baryc[num_maille][i][2];
+ }
+ return coord_baryc_M;
+ }
+
+_TEMPLATE_SPE_ _COORDBARY_3D_::Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n):mailles(m),sommets(n)
+ {
+ cout<<"Creation des Coordonnées Barycentriques : "<<flush;
+ int nbr_mailles=mailles->SIZE();
+ etat_coord_baryc=vector<int>(nbr_mailles,FAUX);
+ coord_baryc=vector< vector< vector<double> > >(nbr_mailles);
+ cout<<"OK ! "<<endl;
+ }
+
+_TEMPLATE_SPE_ vector<double> _COORDBARY_3D_::Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M)
+ {
+ int i,j,nbr_faces;
+ if (etat_coord_baryc[num_maille]==FAUX)
+ {
+ nbr_faces=(*mailles)[num_maille].DONNE_NBR_FACES();
+
+ coord_baryc[num_maille]=vector< vector<double> >(nbr_faces);
+
+ type_retour simplexe_base;
+
+ for (i=0;i<nbr_faces;i++)
+ {
+ (*mailles)[num_maille].DONNE_SIMPLEXE_BASE(i,simplexe_base);
+ coord_baryc[num_maille][i]=Calcule_Base_Coord_Baryc(vector<int>(&simplexe_base.quoi[0],&simplexe_base.quoi[simplexe_base.combien]));
+ etat_coord_baryc[num_maille]=VRAI;
+ }
+ }
+ return Calcule_Coord_Baryc(num_maille,M);
+ }
+
+
+_TEMPLATE_SPE_ vector<double> _COORDBARY_3D_::Calcule_Base_Coord_Baryc(const vector<int> &simplexe_base)
+ {
+ const vector<int> &ref=simplexe_base;
+ vector<double> retour(4);
+ int i,j;
+
+ double x0=(*sommets)[ref[0]][0];
+ double y0=(*sommets)[ref[0]][1];
+ double z0=(*sommets)[ref[0]][2];
+ double x1=(*sommets)[ref[1]][0];
+ double y1=(*sommets)[ref[1]][1];
+ double z1=(*sommets)[ref[1]][2];
+ double x2=(*sommets)[ref[2]][0];
+ double y2=(*sommets)[ref[2]][1];
+ double z2=(*sommets)[ref[2]][2];
+ double x3=(*sommets)[ref[3]][0];
+ double y3=(*sommets)[ref[3]][1];
+ double z3=(*sommets)[ref[3]][2];
+
+ double delta1=((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1));
+ double delta2=((x3-x1)*(z2-z1)-(x2-x1)*(z3-z1));
+ double delta3=((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1));
+
+ double delta=delta1*(x0-x1)+delta2*(y0-y1)+delta3*(z0-z1);
+
+ retour[0]=delta1/delta;
+ retour[1]=delta2/delta;
+ retour[2]=delta3/delta;
+ retour[3]=-(delta1*x1+delta2*y1+delta3*z1)/delta;
+
+ return retour;
+ }
+
+_TEMPLATE_SPE_ vector<double> _COORDBARY_3D_::Calcule_Coord_Baryc(int num_maille, const NOEUD & M)
+ {
+ int i,j;
+ int nbr_faces=coord_baryc[num_maille].size();
+ vector<double> coord_baryc_M(nbr_faces,0);
+ for (i=0;i<nbr_faces;i++)
+ {
+ for (j=0;j<3;j++) coord_baryc_M[i]+=coord_baryc[num_maille][i][j]*M[j];
+ coord_baryc_M[i]+=coord_baryc[num_maille][i][3];
+ }
+ return coord_baryc_M;
+ }
+
+//*/
+
+#undef _TEMPLATE_SPE_
+// template <class NUAGEMAILLE, class NUAGENOEUD, class NOEUD, int DIMENSION>
+#undef _COORDBARYC_
+// Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,DIMENSION>
+#undef _COORDBARY_2D_
+// Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,2>
+#undef _COORDBARY_3D_
+// Coordonnees_Barycentriques<NUAGEMAILLE,NUAGENOEUD,NOEUD,3>
+
+#endif
--- /dev/null
+#ifndef WRAPPERS_CELLS_HXX
+#define WRAPPERS_CELLS_HXX
+
+#include "stdio.h"
+#include "stdlib.h"
+
+#include <typeinfo>
+
+#include <vector>
+#include <map>
+
+#ifndef FAUX
+#define FAUX 0
+#endif
+
+#ifndef VRAI
+#define VRAI 1
+#endif
+
+#ifndef UNDEFINED
+#define UNDEFINED -1
+#endif
+
+#include "MEDMEM_define.hxx"
+
+#define MAXNBR 10
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Equivalence num modele local => MED */
+/* */
+/*********************************************************/
+
+#define NBR_MODELES_MAILLES_DEFINIS 15
+static int Equivalence_Local_MED[NBR_MODELES_MAILLES_DEFINIS] = { MED_POINT1 ,
+ MED_SEG2 , MED_SEG3,
+ MED_TRIA3 , MED_TRIA6 , MED_QUAD4 , MED_QUAD8 ,
+ MED_TETRA4 , MED_TETRA10 , MED_HEXA8 , MED_HEXA20 , MED_PYRA5 , MED_PYRA13 , MED_PENTA6 , MED_PENTA15 };
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Base */
+/* */
+/*********************************************************/
+
+// classe mere des connectivités cannoniques
+// N'a aucune méthode virtuelle pour éviter les pertes de temps
+// Ce sont les constructeurs des classes dérivées qui renseignent les attributs spécifiques
+// un simplexe de base est constitué par un sommet de la maille qui n'est pas contenu dans la face démandée et par trois points de cette face
+// Ce simplexe est utilisé dans le calcul des fonctions barycentriques
+// LES MAILLES SONT DONC ET PAR CONSEQUENT DES MAILLES A FACES PLANES
+// Une face est une face P1, c'est a dire contenant uniquement les sommets, par les noeuds milieux
+// Ces faces sont utilisées pour le calcul de connexité
+
+
+class Connectivite_Canonique_Base
+{
+protected :
+ int type ;
+ int nbr_noeuds ;
+ int nbr_faces ;
+ vector<int> premier_noeud ;
+ vector< vector<int> > simplexe_base ;
+ vector< vector<int> > face ;
+public :
+ inline int DONNE_NBR_NOEUDS() const { return nbr_noeuds; }
+ inline int DONNE_NBR_FACES() const { return nbr_faces; }
+ inline const vector<int> & DONNE_SIMPLEXE_BASE(int num_face) const { return simplexe_base[num_face]; }
+ inline const vector<int> & DONNE_FACE(int num_face) const { return face[num_face]; }
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const { return premier_noeud[num_face]; }
+ friend class Wrapper_Maille;
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_* */
+/* */
+/*********************************************************/
+
+// définies dans la partie CODE
+// les constructeurs construisent tous les tableaux de connectivités nécessaires en fonction du MODELE MED
+
+//class Connectivite_Canonique_Point1 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Seg2 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Seg3 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Tria3 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Tria6 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Quad4 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Quad8 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Tetra4 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Tetra10 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Hexa8 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Hexa20 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Pyra5 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Pyra13 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Penta6 : public Connectivite_Canonique_Base;
+//class Connectivite_Canonique_Penta15 : public Connectivite_Canonique_Base;
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Generale */
+/* */
+/*********************************************************/
+
+// Cette classe contient toutes les connectivités canoniques, elle est utilisée dans Wrapper_Nuage_Maille
+
+class Connectivite_Generale
+{
+protected :
+ vector<Connectivite_Canonique_Base *> AllConn;
+public :
+ Connectivite_Generale();
+ ~Connectivite_Generale();
+ // Renvoie la connectivite locale de la maille de numero local de modele i, dont l'equivalent MED est Equivalence_Local_MED[i]
+ Connectivite_Canonique_Base * operator[](int i) const {return AllConn[i];}
+};
+
+/*********************************************************/
+/* */
+/* Structure type_retour */
+/* */
+/*********************************************************/
+
+// c'est une structure de type petit tableau statique, pour accelerer les acces et eviter les allocations dynamiques
+
+struct type_retour
+ {
+ int quoi[MAXNBR];
+ int combien;
+ };
+
+/*********************************************************/
+/* */
+/* Fonction Comparaison_Informe(...) */
+/* */
+/*********************************************************/
+
+// renvoie vrai si v1 et v2 contiennent la meme chose et sont de meme tailles, faux sinon
+
+inline int Comparaison_Informe(const type_retour &v1,const type_retour &v2);
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille */
+/* */
+/*********************************************************/
+
+// c'est le wrapper maille sur int[]
+// cette classe n'est pas dérivée, tous les types de mailles sont stockées sous cette forme
+// la variable qui définit les type est la Connectivité_Canonique_Base, qui est toujours polymorphée en un type spécifique
+
+
+class Wrapper_Maille
+{
+protected :
+
+ // la référence du premier sommet
+ int * sommets;
+ // la connectivité canonique, toujours polymorphée
+ Connectivite_Canonique_Base * modele;
+
+public :
+ Wrapper_Maille():sommets(NULL) {}
+ ~Wrapper_Maille() {}
+
+ // sorte de transtypeur, cette méthode prend une référence vers un premier sommet et un modele canonique et renvoie *this en tant que wrapper sur ces données
+ inline const Wrapper_Maille & positionne(int * pos, Connectivite_Canonique_Base * mod){sommets=pos;modele=mod;return *this;}
+ // méthodes de la politique (les numéros renvoyés sont des numéros GLOBAUX, calculés à partir de l'indirection fournie par la connectivité canonique
+ // par contre les numéros de face fournis sont des numéros locaux
+ // renvoie le numéro global du sommet de numéro local i
+ inline int operator[](int i) const {return sommets[i];}
+ inline int DONNE_NBR_NOEUDS() const;
+ inline int DONNE_NBR_FACES() const;
+ inline void DONNE_SIMPLEXE_BASE(int num_face,type_retour & simplexe) const;
+ inline void DONNE_FACE(int num_face,type_retour & face) const;
+ inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const;
+ // pour une face, donne, s'il existe, le numéro local de face équivalente, -1 sinon
+ inline int DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(const type_retour & sommets_face) const;
+ // donne le numéro local de modele
+ inline int DONNE_TYPE_MAILLE() const;
+ // donne le numéro MED de modele
+ inline int DONNE_TYPE_MED_MAILLE() const;
+};
+
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Nuage_Maille */
+/* */
+/*********************************************************/
+
+// Classe de Wrapping sur un nuage de maille donné sous forme SKYLINE
+// voir la classe Wrapper_Med_Connectivity dans MEDMEM_Wrapper_Connectivity.hxx pour la politique de classe
+
+template <class FORME_SKYLINE> class Wrapper_Nuage_Maille
+{
+protected :
+ // pointeur sur une forme skyline
+ FORME_SKYLINE * mailles;
+ // toutes les connectivités canoniques
+ Connectivite_Generale ConnGen;
+ int nbr_mailles;
+ // ATTENTION, c'est le type en numero local de modele, pour éviter une map, le numéro de modele MED correponsdant est donné par Equivalence_Local_MED
+ vector<int> types;
+ // pointeur dans mailles du premier sommet de chaque maille (évite les calculs du au nombres éventuellement différents de sommets par maille)
+ vector< int * > premier_pointeur;
+ // maille_courante, est un Wrapper_Maille déja instancié utilisé par l'opérateur [] pour accelerer les acces
+ Wrapper_Maille maille_courante;
+public :
+ Wrapper_Nuage_Maille():mailles(NULL) {}
+ // le constructeur renseigne types et premier_pointeur, instantie ConnGenn et positionne maille_courante sur la premiere maille
+ Wrapper_Nuage_Maille(FORME_SKYLINE * fs);
+ ~Wrapper_Nuage_Maille() {}
+ // Méthodes de la politique
+ // positionne maille_courante sur la maille de numéro global i et renvoie maille_courante
+ inline const Wrapper_Maille & operator[](int i);
+ inline int SIZE() {return nbr_mailles;}
+ void affiche();
+};
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Fonction Comparaison_Informe(...) */
+/* */
+/*********************************************************/
+
+// effectue le test (v1 et v2 ont meme taille)&&(chaque élément de v1 est dans v2)
+// c'est une égalité forte si on est sur que v1 et v2 n'ont pas de doublets,
+// ce qui est le cas pour les mailles et les simplexes
+
+int Comparaison_Informe(const type_retour &v1,const type_retour &v2)
+ {
+ int t1=v1.combien;
+ int t2=v2.combien;
+ if (t1!=t2) return FAUX;
+ int i1,i2;
+ int test;
+ for (i1=0;i1<t1;i1++)
+ {
+ test=1;
+ for (i2=0;(i2<t2)&&(test);i2++)
+ {
+ if (v1.quoi[i1]==v2.quoi[i2]) test=0;
+ }
+ if (test) return FAUX;
+ }
+ return VRAI;
+ }
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Maille */
+/* */
+/*********************************************************/
+
+inline int Wrapper_Maille::DONNE_NBR_NOEUDS() const
+ {
+ return modele->DONNE_NBR_NOEUDS();
+ }
+inline int Wrapper_Maille::DONNE_NBR_FACES() const
+ {
+ return modele->DONNE_NBR_FACES();
+ }
+inline void Wrapper_Maille::DONNE_SIMPLEXE_BASE(int num_face,type_retour & simplexe) const
+ {
+ const vector<int> & simplexelocal=modele->DONNE_SIMPLEXE_BASE(num_face);
+ simplexe.combien=simplexelocal.size();
+ for (int i=0;i<simplexe.combien;i++) simplexe.quoi[i]=sommets[simplexelocal[i]];
+ }
+inline void Wrapper_Maille::DONNE_FACE(int num_face,type_retour & face) const
+ {
+ const vector<int> & facelocal=modele->DONNE_FACE(num_face);
+ face.combien=facelocal.size();
+ for (int i=0;i<face.combien;i++) face.quoi[i]=sommets[facelocal[i]];
+ }
+inline int Wrapper_Maille::DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const
+ {
+ return sommets[modele->DONNE_PREMIER_NOEUD_DE_FACE(num_face)];
+ }
+inline int Wrapper_Maille::DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(const type_retour & sommets_face) const
+ {
+ type_retour face_loc;
+ int num_face;
+ int taille_face_exam;
+ int test=FAUX;
+ for (num_face=0;num_face<DONNE_NBR_FACES();num_face++)
+ {
+ DONNE_FACE(num_face,face_loc);
+ if (Comparaison_Informe(face_loc,sommets_face)) return num_face;
+ }
+ return UNDEFINED;
+ }
+inline int Wrapper_Maille::DONNE_TYPE_MAILLE() const
+ {
+ return modele->type;
+ }
+inline int Wrapper_Maille::DONNE_TYPE_MED_MAILLE() const
+ {
+ return Equivalence_Local_MED[modele->type];
+ }
+
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Nuage_Maille */
+/* */
+/*********************************************************/
+
+template <class FORME_SKYLINE> Wrapper_Nuage_Maille<FORME_SKYLINE>::Wrapper_Nuage_Maille(FORME_SKYLINE * fs):mailles(fs)
+ {
+ int i;
+ map<int,int> Equivalence_MED_Local;
+ // calcule la map de convertion des types med en numéro local, pour accelerer l'acces
+ for (i=0;i<NBR_MODELES_MAILLES_DEFINIS;i++) Equivalence_MED_Local[Equivalence_Local_MED[i]]=i;
+ nbr_mailles=mailles->SIZE();
+ types.resize(nbr_mailles);
+ premier_pointeur.resize(nbr_mailles);
+ for (i=0;i<nbr_mailles;i++)
+ {
+ types[i]=Equivalence_MED_Local[mailles->DONNE_TYPE_MAILLE(i)];
+ premier_pointeur[i]=mailles->DONNE_PREMIER_POINTEUR(i);
+ }
+ maille_courante.positionne(premier_pointeur[0],ConnGen[types[0]]);
+ }
+template <class FORME_SKYLINE> const Wrapper_Maille & Wrapper_Nuage_Maille<FORME_SKYLINE>::operator[](int i)
+ {
+ return maille_courante.positionne(premier_pointeur[i],ConnGen[types[i]]);
+ }
+template <class FORME_SKYLINE> void Wrapper_Nuage_Maille<FORME_SKYLINE>::affiche()
+ {
+ int i,j;
+ for (i=0;i<nbr_mailles;i++)
+ {
+ cout<<"Maille "<<i<<" MED "<<Equivalence_Local_MED[types[i]]<<" : "<<flush;
+ for (j=0;j<(*this)[i].DONNE_NBR_NOEUDS();j++) cout<<(*this)[i][j]<<" "<<flush;
+ cout<<endl;
+ }
+ }
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Point1 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Point1 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Point1()
+ {
+
+ type=0;
+
+ nbr_noeuds = 1;
+ nbr_faces = 0;
+
+ premier_noeud = vector<int>(0);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ }
+ ~Connectivite_Canonique_Point1() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Seg2 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Seg2 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Seg2()
+ {
+
+ type=1;
+
+ int pn[2] = {0,1};
+ int sb[4] = {1,0,0,1};
+ int fa[2] = {0,1};
+ int po[3] = {0,1,2};
+
+ nbr_noeuds = 2;
+ nbr_faces = 2;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[2*i],&sb[2*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Seg2() {}
+};
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Seg3 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Seg3 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Seg3()
+ {
+
+ type=2;
+
+ int pn[2] = {0,1};
+ int sb[4] = {1,0,0,1};
+ int fa[2] = {0,1};
+ int po[3] = {0,1,2};
+
+ nbr_noeuds = 3;
+ nbr_faces = 2;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[2*i],&sb[2*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Seg3() {}
+};
+
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Tria3 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Tria3 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Tria3()
+ {
+
+ type=3;
+
+ int pn[3] = {0,1,2};
+ int sb[9] = {2,0,1,0,1,2,1,2,0};
+ int fa[6] = {0,1,1,2,2,0};
+ int po[4] = {0,2,4,6};
+ nbr_noeuds = 3;
+ nbr_faces = 3;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[3*i],&sb[3*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Tria3() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Tria6 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Tria6 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Tria6()
+ {
+
+ type=4;
+
+ int pn[3] = {0,1,2};
+ int sb[9] = {2,0,1,0,1,2,1,2,0};
+ int fa[6] = {0,1,1,2,2,0};
+ int po[4] = {0,2,4,6};
+ nbr_noeuds = 6;
+ nbr_faces = 3;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[3*i],&sb[3*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Tria6() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Quad4 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Quad4 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Quad4()
+ {
+
+ type=5;
+
+ int pn[4] = {0,1,2,3};
+ int sb[12] = {2,0,1,3,1,2,0,2,3,1,0,2};
+ int fa[8] = {0,1,1,2,2,3,3,0};
+ int po[5] = {0,2,4,6,8};
+ nbr_noeuds = 4;
+ nbr_faces = 4;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[3*i],&sb[3*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Quad4() {}
+};
+
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Quad8 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Quad8 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Quad8()
+ {
+
+ type=6;
+
+ int pn[4] = {0,1,2,3};
+ int sb[12] = {2,0,1,3,1,2,0,2,3,1,0,2};
+ int fa[8] = {0,1,1,2,2,3,3,0};
+ int po[5] = {0,2,4,6,8};
+ nbr_noeuds = 8;
+ nbr_faces = 4;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[3*i],&sb[3*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Quad8() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Tetra4 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Tetra4 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Tetra4()
+ {
+
+ type=7;
+
+ int pn[4] = {0,0,1,2};
+ int sb[16] = {3,0,1,2,2,0,3,1,0,1,3,2,1,2,3,0};
+ int fa[12] = {0,1,2,0,3,1,1,3,2,2,3,0};
+ int po[5] = {0,3,6,9,12};
+ nbr_noeuds = 4;
+ nbr_faces = 4;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[4*i],&sb[4*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Tetra4() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Tetra10 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Tetra10 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Tetra10()
+ {
+
+ type=8;
+
+ int pn[4] = {0,0,1,2};
+ int sb[16] = {3,0,1,2,2,0,3,1,0,1,3,2,1,2,3,0};
+ int fa[12] = { 0,1,2, 0,3,1, 1,3,2, 2,3,0};
+ int po[5] = {0,3,6,9,12};
+
+ nbr_noeuds = 10;
+ nbr_faces = 4;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[4*i],&sb[4*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Tetra10() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Hexa8 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Hexa8 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Hexa8()
+ {
+
+ type=9;
+
+ int pn[6] = {0,4,0,1,2,3};
+ int sb[24] = {5,0,1,2,0,7,6,5,3,0,4,5,4,1,5,6,1,2,6,3,2,3,7,0};
+ int fa[24] = {0,1,2,3,4,5,6,7,0,4,5,1,1,5,6,2,2,6,7,3,3,7,4,0};
+ int po[7] = {0,4,8,12,16,20,24};
+ nbr_noeuds = 8;
+ nbr_faces = 6;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[4*i],&sb[4*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Hexa8() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Hexa20 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Hexa20 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Hexa20()
+ {
+
+ type=10;
+
+ int pn[6] = {0,4,0,1,2,3};
+ int sb[24] = {5,0,1,2,0,7,6,5,3,0,4,5,4,1,5,6,1,2,6,3,2,3,7,0};
+ int fa[24] = {0,1,2,3,4,5,6,7,0,4,5,1,1,5,6,2,2,6,7,3,3,7,4,0};
+ int po[7] = {0,4,8,12,16,20,24};
+ nbr_noeuds = 20;
+ nbr_faces = 6;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[4*i],&sb[4*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Hexa20() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Pyra5 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Pyra5 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Pyra5()
+ {
+
+ type=11;
+
+ int pn[5] = {0,0,1,2,3};
+ int sb[20] = {4,0,1,2,3,0,4,1,0,1,4,2,1,2,4,3,2,0,3,4};
+ int fa[16] = {0,1,2,3,0,4,1,1,4,2,2,4,3,3,4,0};
+ int po[6] = {0,4,7,10,13,16};
+ nbr_noeuds = 5;
+ nbr_faces = 5;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[4*i],&sb[4*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Pyra5() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Pyra13 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Pyra13 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Pyra13()
+ {
+
+ type=12;
+
+ int pn[5] = {0,0,1,2,3};
+ int sb[20] = {4,0,1,2,3,0,4,1,0,1,4,2,1,2,4,3,2,0,3,4};
+ int fa[16] = {0,1,2,3,0,4,1,1,4,2,2,4,3,3,4,0};
+ int po[6] = {0,4,7,10,13,16};
+ nbr_noeuds = 13;
+ nbr_faces = 5;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[4*i],&sb[4*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Pyra13() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Penta6 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Penta6 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Penta6()
+ {
+
+ type=13;
+
+ int pn[5] = {0,3,0,1,2};
+ int sb[20] = {3,0,1,2,2,3,4,5,5,0,3,1,0,1,4,2,1,2,5,0};
+ int fa[18] = {0,1,2,3,4,5,0,3,4,1,1,4,5,2,2,5,3,1};
+ int po[6] = {0,3,6,10,14,18};
+ nbr_noeuds = 6;
+ nbr_faces = 5;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[4*i],&sb[4*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Penta6() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Canonique_Penta15 */
+/* */
+/*********************************************************/
+
+class Connectivite_Canonique_Penta15 : public Connectivite_Canonique_Base
+{
+public :
+ Connectivite_Canonique_Penta15()
+ {
+
+ type=14;
+
+ int pn[5] = {0,3,0,1,2};
+ int sb[20] = {3,0,1,2,2,3,4,5,5,0,3,1,0,1,4,2,1,2,5,0};
+ int fa[18] = {0,1,2,3,4,5,0,3,4,1,1,4,5,2,2,5,3,1};
+ int po[6] = {0,3,6,10,14,18};
+ nbr_noeuds = 15;
+ nbr_faces = 5;
+
+
+ premier_noeud = vector<int>(&pn[0],&pn[nbr_faces]);
+
+ simplexe_base = vector< vector<int> >(nbr_faces);
+ face = vector< vector<int> >(nbr_faces);
+
+ int i;
+
+ for (i=0;i<nbr_faces;i++) simplexe_base[i]=vector<int>(&sb[4*i],&sb[4*(i+1)]);
+ for (i=0;i<nbr_faces;i++) face[i]=vector<int>(&fa[po[i]],&fa[po[i+1]]);
+
+ }
+ ~Connectivite_Canonique_Penta15() {}
+};
+
+/*********************************************************/
+/* */
+/* Classe Connectivite_Generale */
+/* */
+/*********************************************************/
+
+inline Connectivite_Generale::Connectivite_Generale():AllConn(NBR_MODELES_MAILLES_DEFINIS)
+ {
+ // l'ordre est important, il dépend de la relation entre numéro local et modele et numéro MED
+ AllConn[ 0]=new Connectivite_Canonique_Point1 ();
+ AllConn[ 1]=new Connectivite_Canonique_Seg2 ();
+ AllConn[ 2]=new Connectivite_Canonique_Seg3 ();
+ AllConn[ 3]=new Connectivite_Canonique_Tria3 ();
+ AllConn[ 4]=new Connectivite_Canonique_Tria6 ();
+ AllConn[ 5]=new Connectivite_Canonique_Quad4 ();
+ AllConn[ 6]=new Connectivite_Canonique_Quad8 ();
+ AllConn[ 7]=new Connectivite_Canonique_Tetra4 ();
+ AllConn[ 8]=new Connectivite_Canonique_Tetra10 ();
+ AllConn[ 9]=new Connectivite_Canonique_Hexa8 ();
+ AllConn[10]=new Connectivite_Canonique_Hexa20 ();
+ AllConn[11]=new Connectivite_Canonique_Pyra5 ();
+ AllConn[12]=new Connectivite_Canonique_Pyra13 ();
+ AllConn[13]=new Connectivite_Canonique_Penta6 ();
+ AllConn[14]=new Connectivite_Canonique_Penta15 ();
+ }
+inline Connectivite_Generale::~Connectivite_Generale()
+ {
+ for (int i=0;i<AllConn.size();i++) delete AllConn[i];
+ }
+
+
+#endif
--- /dev/null
+#ifndef MEDMEM_WRAPPER_CONNECTIVITY_HXX
+#define MEDMEM_WRAPPER_CONNECTIVITY_HXX
+
+#include "MEDMEM_Connectivity.hxx"
+
+#include <vector>
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ET CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Wrapper_Med_Connectivity */
+/* */
+/*********************************************************/
+
+// obligé de faire de la recopie car MED n'utilise pas la numérotation standart C
+
+class Wrapper_Med_Connectivity
+{
+protected :
+ int * mailles;
+ int nbr_mailles;
+ vector<int> types;
+ vector< int* > premier_pointeur;
+
+public :
+ ~Wrapper_Med_Connectivity() {if (mailles) delete [] mailles;}
+ Wrapper_Med_Connectivity():mailles(NULL) {}
+ Wrapper_Med_Connectivity(CONNECTIVITY * maillesmed)
+ {
+ const med_int * tab_sommets_mailles=maillesmed->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS);
+ const med_int * med_connectivite=maillesmed->getConnectivityIndex(MED_FULL_INTERLACE,MED_CELL);
+ const med_int * med_index=maillesmed->getValueIndex(MED_FULL_INTERLACE);
+ nbr_mailles=maillesmed->getNumberOf(MED_CELL,MED_ALL_ELEMENTS);
+ int size=med_index[nbr_mailles]-med_index[0];
+ types.resize(nbr_mailles);
+ premier_pointeur.resize(nbr_mailles);
+ mailles=new int[size];
+ int i;
+ for (i=0;i<size;i++)
+ {
+ mailles[i]=tab_sommets_mailles[i]-1;
+ }
+ for (i=0;i<nbr_mailles;i++)
+ {
+ types[i]=maillesmed->getElementType(MED_CELL,i+1); // A VERIFIER : le +1
+ premier_pointeur[i]=&mailles[med_index[i]-1]; // A VERIFIER : la formule
+ }
+ }
+ // Méthodes de la politique
+ inline int SIZE() {return nbr_mailles;}
+ inline int DONNE_TYPE_MAILLE(int i) {return types[i];}
+ inline int * DONNE_PREMIER_POINTEUR(int i) {return premier_pointeur[i];}
+};
+
+
+#endif
--- /dev/null
+#ifndef MEDMEM_WRAPPER_FIELD_HXX
+#define MEDMEM_WRAPPER_FIELD_HXX
+
+#include "MEDMEM_Field.hxx"
+
+#include <vector>
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ET CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Template Arithmétiques de Valdhuizen */
+/* */
+/*********************************************************/
+
+// permet de faire des opérations algébriques sur des Wrappers_MED_Field sans faire d'allocations inutiles
+// voir les articles de Valdhuizen pour la compréhension du processus
+
+template <class TYPE> class Valeur;
+
+struct Plus
+{
+public :
+ static double apply(double a,double b) {return a+b;}
+};
+
+struct Multiply
+{
+public :
+ static double apply(double a,double b) {return a*b;}
+};
+
+
+template <typename Left,typename Op, typename Right> struct X
+{
+ Left left;
+ Right right;
+ X(Left l,Right r):left(l),right(r){}
+ double operator[](int i)
+ {
+ return Op::apply(left[i],right[i]);
+ }
+};
+
+template <typename Right> struct X<double,Multiply,Right>
+{
+ double left;
+ Right right;
+ X(double l,Right r):left(l),right(r){}
+ double operator[](int i)
+ {
+ return Multiply::apply(left,right[i]);
+ }
+};
+
+template <typename TYPE> X< Valeur<TYPE>,Plus,Valeur<TYPE> > operator+(Valeur<TYPE> v1,Valeur<TYPE> v2)
+{
+return X< Valeur<TYPE>,Plus,Valeur<TYPE> >(v1,v2);
+}
+
+template <typename TYPE> X< double,Multiply,Valeur<double> > operator*(TYPE sca,Valeur<TYPE> v)
+{
+return X< TYPE,Multiply,Valeur<TYPE> >(sca,v);
+}
+
+template <typename TYPE,typename L, typename O, typename R> X< Valeur<TYPE>,Plus,X<L,O,R> > operator+(Valeur<TYPE> v,X<L,O,R> expression)
+{
+return X< Valeur<TYPE>,Plus,X<L,O,R> >(v,expression);
+}
+
+template <typename TYPE,typename L, typename O, typename R> X< X<L,O,R>,Plus,Valeur<TYPE> > operator+(X<L,O,R> expression,Valeur<TYPE> v)
+{
+return X< X<L,O,R>,Plus,Valeur<TYPE> >(expression,v);
+}
+
+template <typename Ll, typename Ol, typename Rl,typename Lr, typename Or, typename Rr> X< X<Ll,Ol,Rl>,Plus, X<Lr,Or,Rr> > operator+(X<Ll,Ol,Rl> el, X<Lr,Or,Rr> er )
+{
+return X< X<Ll,Ol,Rl>,Plus,X<Lr,Or,Rr> >(el,er);
+}
+
+template <typename L, typename O, typename R> X< double,Multiply,X<L,O,R> > operator*(double sca,X<L,O,R> expression)
+{
+return X< double,Multiply,X<L,O,R> >(sca,expression);
+}
+
+template <typename Left,typename Op,typename Right> X< double,Multiply,X<Left,Op,Right> > operator/(X<Left,Op,Right> l,double x)
+{
+return X< double,Multiply,X<Left,Op,Right> >(((double) 1/x),l);
+}
+
+/*********************************************************/
+/* */
+/* Classe Valeur */
+/* */
+/*********************************************************/
+
+// Problèmes : les constructeurs par copie ne sont pas satisfaisants
+// Valeur est symboliquement l'argument d'une classe formelle Vecteur<Valeur>
+// elle peut etre un réel ou un pointeur sur réel, simulant un vecteur de vecteur
+
+template <class TYPE> class Valeur
+{
+protected :
+ TYPE * valeurs;
+ int nbr_valeurs;
+ int a_detruire;
+public :
+ Valeur():valeurs(NULL),a_detruire(0){}
+ Valeur(TYPE * val,int nv):valeurs(val),nbr_valeurs(nv),a_detruire(0){} // A VERIFIER
+ Valeur(int n):nbr_valeurs(n),a_detruire(1)
+ {
+ valeurs=new TYPE[nbr_valeurs];
+ }
+ template <typename Left,typename Op,typename Right> Valeur(X<Left,Op,Right> expression)
+ {
+ for (int i=0;i<nbr_valeurs;i++) valeurs[i]=expression[i];
+ }
+ template <typename Left,typename Op,typename Right> void operator=(X<Left,Op,Right> expression)
+ {
+ for (int i=0;i<nbr_valeurs;i++) valeurs[i]=expression[i];
+ }
+ void operator=(Valeur v)
+ {
+ for (int i=0;i<nbr_valeurs;i++) valeurs[i]=v[i];
+ }
+ Valeur(const Valeur &v):nbr_valeurs(v.nbr_valeurs)
+ {
+ if (v.a_detruire)
+ {
+ a_detruire=1;
+ valeurs=new TYPE[nbr_valeurs];
+ for (int i=0;i<nbr_valeurs;i++) valeurs[i]=v.valeurs[i];
+ }
+ else
+ {
+ a_detruire=0;
+ valeurs=v.valeurs;
+ }
+ }
+ ~Valeur(){if (a_detruire) delete [] valeurs;}
+ TYPE operator[](int i){return valeurs[i];}
+ int SIZE() const {return nbr_valeurs;}
+ double NormeAbs()
+ {
+ int i;
+ double tmp=0;
+ for (i=0;i<nbr_valeurs;i++) tmp+=fabs(valeurs[i]);
+ return tmp;
+ }
+
+};
+
+template <class TYPE> ostream &operator<<(ostream &os,Valeur<TYPE> v)
+ {
+ os<<"("<<flush;
+ for (int i=0;i<v.SIZE();i++) os<<" "<<v[i]<<flush;
+ os<<" ) "<<flush;
+ return os;
+ }
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_MED_Field */
+/* */
+/*********************************************************/
+
+// c'est la classe de Wrapping sur un objet FIELD<double> MEDMEMOIRE
+
+class Wrapper_MED_Field
+{
+protected :
+ int nbr_valeurs;
+ int nbr_composantes;
+ double * valeurs;
+public :
+ Wrapper_MED_Field():valeurs(NULL){}
+ Wrapper_MED_Field(int nv, int nc, double * v):nbr_valeurs(nv),nbr_composantes(nc),valeurs(v)
+ {
+ }
+ Wrapper_MED_Field(const FIELD<double> * medfield)
+ {
+ nbr_valeurs=medfield->getNumberOfValues();
+ nbr_composantes=medfield->getNumberOfComponents();
+ valeurs=const_cast<double *>(medfield->getValue(MED_FULL_INTERLACE));
+ }
+ ~Wrapper_MED_Field(){}
+ inline Valeur<double> operator[](int i)
+ {
+ return Valeur<double>(&valeurs[nbr_composantes*i],nbr_composantes);
+ }
+ double * Get_Valeurs() {return valeurs;}
+ inline int Get_Nbr_Valeurs() const {return nbr_valeurs;}
+ inline int Get_Nbr_Composantes() const {return nbr_composantes;}
+ friend ostream & operator<<(ostream &os, Wrapper_MED_Field);
+};
+
+inline ostream & operator<<(ostream &os, Wrapper_MED_Field wmf)
+{
+for (int i=0;i<wmf.nbr_valeurs;i++) os<<"Wrapper_MED_Field["<<i<<"] = "<<wmf[i]<<endl;
+return os;
+}
+
+#endif
--- /dev/null
+#ifndef MEDMEM_WRAPPER_MESH_HXX
+#define MEDMEM_WRAPPER_MESH_HXX
+
+#include "MEDMEM_WrapperCells.hxx"
+
+#include "stdio.h"
+#include "stdlib.h"
+
+#include <vector>
+
+#ifndef UNDEFINED
+#define UNDEFINED -1
+#endif
+
+#ifndef FAUX
+#define FAUX 0
+#endif
+
+#ifndef VRAI
+#define VRAI 1
+#endif
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Wrapper_Maillage */
+/* */
+/*********************************************************/
+
+// cette classe est à la fois un wrapper sur un nuage de maille et une classe d'algorithme
+// elle s'occupe de construire les liens de connexités minimums du nuage de maille
+// pour le transformer en maillage suffisament riche pour etre utilisé par les algorithmes de connexités
+// et autres méthodes nécessitant des informations de connexité sur un maillage
+
+// la version utilisée dans MEDMEMOIRE est dé-templatifiée dans MEDMEM_InterpolationHighLevelObject.hxx
+
+template <class NUAGEMAILLE> class Wrapper_Maillage
+{
+protected :
+ // référence vers le nuage de maille,
+ // voir la classe Wrapper_Nuage_Maille dans MEDMEM_WrapperCells.hxx pour la politique
+ NUAGEMAILLE * mailles;
+
+ int nbr_noeuds;
+
+ // liste des numéros globaux de faces contenues dans une maille
+ vector< vector<int> > faces_contenues;
+ // liste des numéros globaux de mailles qui contiennent un noeud
+ vector< vector<int> > mailles_contenant_noeud;
+ // liste des numéros globaux de mailles voisines d'une maille donnée via une face
+ // l'ordre du voisin dans la liste implique par quelle face dans le tableau faces_contenues il est voisin
+ vector< vector<int> > voisins_de_maille;
+
+ // liste des numéros globaux de faces qui sont au bord du maillage
+ // Ce sont les faces qui n'ont qu'une seule maille de rattachement
+ vector<int> face_au_bord;
+ // liste des numéros globaux de mailles qui sont au bord
+ // ce sont les mailles qui ont une face sans voisin
+ vector<int> maille_au_bord;
+
+ // Méthode privée
+ // construit le tableau mailles_contenant_noeud
+ 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 int DONNE_PREMIERE_MAILLE_CONTENANT(int num_noeud) const;
+ inline NUAGEMAILLE * DONNE_POINTEUR_NUAGEMAILLE();
+
+};
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+template <class NUAGEMAILLE> int Wrapper_Maillage<NUAGEMAILLE>::DONNE_PREMIERE_MAILLE_CONTENANT(int num_noeud) const
+ {
+ return mailles_contenant_noeud[num_noeud][0];
+ }
+template <class NUAGEMAILLE> int Wrapper_Maillage<NUAGEMAILLE>::DONNE_VOISIN_DE_MAILLE(int num_maille,int num_face) const
+ {
+ return voisins_de_maille[num_maille][num_face];
+ }
+template <class NUAGEMAILLE> int Wrapper_Maillage<NUAGEMAILLE>::EST_AU_BORD_FACE_DE_MAILLE(int num_maille,int num_face) const
+ {
+ return face_au_bord[faces_contenues[num_maille][num_face]];
+ }
+template <class NUAGEMAILLE> int Wrapper_Maillage<NUAGEMAILLE>::DONNE_NBR_FACES_MAILLE(int num_maille)
+ {
+ return (*mailles)[num_maille].DONNE_NBR_FACES();
+ }
+template <class NUAGEMAILLE> NUAGEMAILLE * Wrapper_Maillage<NUAGEMAILLE>::DONNE_POINTEUR_NUAGEMAILLE()
+ {
+ return mailles;
+ }
+template <class NUAGEMAILLE> void Wrapper_Maillage<NUAGEMAILLE>::Construit_Contenant_Noeud()
+ {
+ int nbr_noeuds_maille;
+ int num,num_noeud,num_maille;
+
+ mailles_contenant_noeud.resize(nbr_noeuds);
+
+ // parcours le tableau des mailles, puis les sommets de chaque maille
+ // et utilise un push_back pour renseigner mailles_contenant_noeud
+
+ for (num_maille=0;num_maille<mailles->SIZE();num_maille++)
+ {
+ nbr_noeuds_maille=(*mailles)[num_maille].DONNE_NBR_NOEUDS();
+ for (num_noeud=0;num_noeud<nbr_noeuds_maille;num_noeud++)
+ {
+ num=(*mailles)[num_maille][num_noeud];
+ mailles_contenant_noeud[num].push_back(num_maille);
+ }
+ }
+
+ }
+template <class NUAGEMAILLE> Wrapper_Maillage<NUAGEMAILLE>::Wrapper_Maillage(NUAGEMAILLE * fs,int nn)
+ {
+
+ if (fs) mailles=fs;
+ else
+ {
+ cerr<<"Wrapper_Maillage : Nuage mailles vide passé en argument"<<endl;
+ exit(-1);
+ }
+
+ int i,j,k;
+ int num_local_face;
+ int ind_num_noeud,num_noeud;
+ int num_maille;
+ int ind_num_maille_sec,num_maille_sec;
+ int num_local_sec;
+ int flag_existence;
+ int nbr_mailles=mailles->SIZE();
+ int nbr_formants=0;
+ int approx_nbr_formants=0;
+ int tmp;
+ int num_loc;
+
+ nbr_noeuds=nn;
+
+ voisins_de_maille.resize(nbr_mailles);
+ faces_contenues.resize(nbr_mailles);
+ maille_au_bord.resize(nbr_mailles,UNDEFINED);
+
+ type_retour sommets_face;
+
+ Construit_Contenant_Noeud();
+
+ // mise a taille des tableaux et calcul d'une approximation du nombre de faces
+ // on postule que le nombre de faces réel est le dixieme de la somme du nombre de faces par maille sur toutes les mailles
+ // on calcule cette approximation pour éviter les allocations fréquentes dues aux push_back pour des petits tableaux
+
+ for (num_maille=0;num_maille<nbr_mailles;num_maille++)
+ {
+ tmp=(*mailles)[num_maille].DONNE_NBR_FACES();
+ voisins_de_maille[num_maille]=vector<int>(tmp,UNDEFINED);
+ faces_contenues[num_maille]=vector<int>(tmp,UNDEFINED);
+ approx_nbr_formants+=tmp;
+ }
+
+ face_au_bord.reserve(approx_nbr_formants/10);
+
+ // algorithme principal
+
+ // REMARQUE : les faces sont numérotées mais ne sont pas construites ni stockées
+
+ int flag_interm;
+
+ // on parcourt en premier lieu le nuage de maille (linéaire, en Nombre de Maille)
+
+ for (num_maille=0;num_maille<nbr_mailles;num_maille++)
+ {
+
+ // pour chaque maille, dite primaire, on parcourt ensuite ses faces (borné, par 8)
+
+ for (num_local_face=0;num_local_face<(*mailles)[num_maille].DONNE_NBR_FACES();num_local_face++)
+ {
+ num_noeud=(*mailles)[num_maille].DONNE_PREMIER_NOEUD_DE_FACE(num_local_face);
+ flag_existence=0;
+ (*mailles)[num_maille].DONNE_FACE(num_local_face,sommets_face);
+ flag_interm=0;
+
+ // pour chaque face, dite primaire, on prend le premier noeud, et on parcourt les mailles qui contiennent ce noeud tant qu'on n'a pas trouvé de voisin
+ // (borné, par un coefficient qui dépend de l'anisotropie du maillage, le nombre maximum de maille qui contient un sommet)
+
+ for (ind_num_maille_sec=0;(flag_existence==0)&&(ind_num_maille_sec<mailles_contenant_noeud[num_noeud].size());ind_num_maille_sec++)
+ {
+ num_maille_sec=mailles_contenant_noeud[num_noeud][ind_num_maille_sec];
+
+ // on teste ensuite si cette maille secondaire a un numéro plus élevé que la maille primaire, dans le cas contraire,
+ // ça veut dire qu'elle a déja été traitée ou sera traitée ultérieurement
+
+ if (num_maille_sec>num_maille)
+ {
+ flag_interm=1;
+
+ // pour cette maille secondaire on regarde si elle contient la face primaire
+ // (borné, par 8*4=32)
+
+ num_loc=(*mailles)[num_maille_sec].DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(sommets_face);
+ if (num_loc>UNDEFINED)
+ {
+
+ // et dans ce cas, la maille secondaire est voisine de la maille primaire, on met à jour les tableaux
+ // si on voulait construire le tableau des faces, c'est ici qu'il faudrait le faire -1-
+
+ // MESSAGE("La maille "<<num_maille<<" a pour voisin la maille "<<num_maille_sec<<" via la face "<<nbr_formants);
+ face_au_bord.push_back(FAUX);
+ faces_contenues[num_maille][num_local_face]=nbr_formants;
+ voisins_de_maille[num_maille][num_local_face]=num_maille_sec;
+ faces_contenues[num_maille_sec][num_loc]=nbr_formants;
+ voisins_de_maille[num_maille_sec][num_loc]=num_maille;
+ flag_existence=1;
+ nbr_formants++;
+ }
+ }
+ }
+ }
+ }
+
+ // Construction de la connexité des mailles de bord
+ // A ce stade, on n'a que la connexité du voisinage des mailles, et les faces de bord n'ont pas été numérotées
+
+ int ind_num_cont,test_bord,nbr_faces_bord=0;
+
+ // on parcourt les mailles
+
+ for (num_maille=0;num_maille<nbr_mailles;num_maille++)
+ {
+ test_bord=0;
+
+ // on examine les faces de cette maille dans la numérotation globale faces_contenues
+
+ for (ind_num_cont=0;ind_num_cont<faces_contenues[num_maille].size();ind_num_cont++)
+ {
+
+ // On regarde si tous les numéros globaux des faces sont définis
+
+ if (faces_contenues[num_maille][ind_num_cont]==UNDEFINED)
+ {
+
+ // si un seul numéro n'est pas défini, la maille est au bord
+ // si on voulait construire le tableau des faces, c'est ici qu'il faudrait le faire -2-
+
+ // MESSAGE("La maille "<<num_maille<<" est au bord via sa face "<<ind_num_cont);
+ test_bord=1;
+ faces_contenues[num_maille][ind_num_cont]=nbr_formants;
+ maille_au_bord[num_maille]=VRAI;
+ face_au_bord.push_back(VRAI);
+ nbr_faces_bord++;
+ nbr_formants++;
+ }
+ }
+
+ // dans le cas contraire, tous les numéros sont définis, la maille n'est pas au bord
+
+ if (test_bord==0)
+ {
+ maille_au_bord[num_maille]=FAUX;
+ }
+ }
+
+ // Vérification de la connectivité
+ // on regarde si tous les numéros globaux sont définis
+ // si ce n'est pas le cas, c'est que le nuage de maille est mal défini
+
+
+ int verif=0;
+ int nf,nbf=0;
+ for (i=0;i<nbr_mailles;i++)
+ {
+ nf=0;
+ for (j=0;j<faces_contenues[i].size();j++)
+ {
+ if (faces_contenues[i][j]==UNDEFINED) verif++;
+ if (voisins_de_maille[i][j]==UNDEFINED) nf++;
+ }
+ if (maille_au_bord[i]==UNDEFINED) cerr<<"Maille "<<i<<" non completement construite"<<endl;
+ if (nf==faces_contenues[i].size()) nbf++;
+ }
+
+
+ MESSAGE("IL Y A "<<verif<<" PROBLEMES A LA SUITE DE LA CONSTRUCTION DE CONNEXITE");
+ MESSAGE("Nombre de mailles : "<<nbr_mailles);
+ MESSAGE("Approximation du nombre de faces : "<<approx_nbr_formants);
+ MESSAGE("Nombre réel de faces de bord : "<<nbr_faces_bord);
+ MESSAGE("Nombre réel total de faces : "<<nbr_formants);
+ MESSAGE("Nombre de Mailles Isolées : "<<nbf);
+ }
+
+#endif
--- /dev/null
+
+#ifndef MEDMEM_WRAPPER_NODES_HXX
+#define MEDMEM_WRAPPER_NODES_HXX
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Classe Wrapper_Noeud */
+/* */
+/*********************************************************/
+
+template <int DIMENSION> class Wrapper_Noeud
+{
+protected :
+ double * coordonnees;
+public :
+ Wrapper_Noeud():coordonnees(NULL)
+ {
+ }
+ Wrapper_Noeud(double * coord):coordonnees(coord)
+ {
+ }
+ ~Wrapper_Noeud()
+ {
+ }
+ void positionne(double *place)
+ {
+ coordonnees=place;
+ }
+ const double & operator[] (int i) const
+ {
+ return coordonnees[i];
+ }
+ double operator[] (int i)
+ {
+ return coordonnees[i];
+ }
+ friend double DistanceInf(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B)
+ {
+ double max=0;
+ double tmp;
+ for (int i=0;i<DIMENSION;i++)
+ {
+ tmp=fabs(A[i]-B[i]);
+ if (tmp>max) max=tmp;
+ }
+ return max;
+ }
+ friend double DistanceL2(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B)
+ {
+ double tmp,somme=0;
+ for (int i=0;i<DIMENSION;i++)
+ {
+ tmp=(A[i]-B[i]);
+ somme+=tmp*tmp;
+ }
+ return sqrt(somme);
+ }
+ friend int operator==(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B)
+ {
+ for (int i=0;i<DIMENSION;i++) if (A[i]!=B[i]) return 1;
+ return 0;
+ }
+ friend ostream & operator<<(ostream &os,const Wrapper_Noeud<DIMENSION> &A)
+ {
+ os<<"( "<<flush;
+ for (int i=0;i<DIMENSION;i++) os<<A[i]<<" "<<flush;
+ os<<")"<<flush;
+ return os;
+ }
+ };
+
+/*********************************************************/
+/* */
+/* Classe Nuage_Wrapper_Noeud */
+/* */
+/*********************************************************/
+
+
+template <int DIMENSION> class Wrapper_Nuage_Noeud
+ {
+ protected :
+ int nbr_noeuds;
+ double * noeuds;
+ Wrapper_Noeud<DIMENSION> show;
+ public :
+ Wrapper_Nuage_Noeud():nbr_noeuds(0),noeuds(NULL) {}
+ Wrapper_Nuage_Noeud(int nn, double *n):nbr_noeuds(nn),noeuds(n),show(noeuds) {}
+ ~Wrapper_Nuage_Noeud() {}
+ Wrapper_Noeud<DIMENSION> & operator [] (int i)
+ {
+ show.positionne((double *) &noeuds[DIMENSION*i]);
+ return show;
+ }
+ int size() const {return nbr_noeuds;}
+ int SIZE() const {return nbr_noeuds;}
+ void affiche()
+ {
+ int i,j;
+ for (i=0;i<nbr_noeuds;i++)
+ {
+ cout<<"Noeud "<<i<<" : "<<flush;
+ for (j=0;j<DIMENSION;j++) cout<<noeuds[i*DIMENSION+j]<<" "<<flush;
+ cout<<endl;
+ }
+ }
+ };
+
+
+#endif
--- /dev/null
+#ifndef MEDMEM_DTREE_HXX
+#define MEDMEM_DTREE_HXX
+
+#include "MEDMEM_dTreeSommet.hxx"
+
+#define DTREE_FANTOME -1
+#define DTREE_RACINE 0
+#define DTREE_TERMINAL 1
+#define DTREE_COURANT 2
+// etat_descendance
+#define DTREE_NON_CALCULE -1
+#define DTREE_AUCUNE 0
+#define DTREE_VALIDE 1
+// val min nbr noeud
+#define DTREE_NBR_MIN_NOEUDS 2
+#define DTREE_NBR_MAX_DESC 8
+// pour meilleu re lecture
+#define _TEMPLATE_ template <class NOEUD,class NUAGENOEUD,int DIMENSION,int NBR_NOEUDS_PAR_CASE>
+#define _DTREE_ dTree<NOEUD,NUAGENOEUD,DIMENSION,NBR_NOEUDS_PAR_CASE>
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// DECLARATIONS ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+/*********************************************************/
+/* */
+/* Calcul Statique de Puissance */
+/* */
+/*********************************************************/
+
+// Permet de Calculer 2^n de façon statique
+
+template < int DIMENSION > struct DeuxPuissance
+ {
+ enum { valeur = 2 * DeuxPuissance<DIMENSION-1>::valeur } ;
+ };
+
+template <> struct DeuxPuissance<0>
+ {
+ enum { valeur = 1 } ;
+ };
+
+/*********************************************************/
+/* */
+/* DTREE */
+/* */
+/*********************************************************/
+
+// Construit un d-Tree sur un nuage de noeud et pour un noeud donné donne lequel des noeuds du nuage est le plus proche
+
+// # Bugs connus :
+// - Problemes avec points sur les faces des hypercubes ?
+// - Plantage sauvage si le point est plus loin de l'hypercube père que le diametre Linf de celui-ci.
+// # Politique de classe :
+// - NOEUD : voir dans MEDMEM_WrapperNodes.hxx la classe Wrapper_Noeud<..>
+// - NUAGENOEUD : typiquement, c'est vector<NOEUD> en rédefinissant NUAGENOEUD<...>::SIZE()=vector<...>::size()
+// Remarques :
+// - NBR_NOEUDS_PAR_CASE ne doit pas être modifié sauf peut-être dans le cas où l'utilisateur veut utiliser des d-Tree parallèles
+// ou utilise des nuages de noeud trop grands
+
+template <class NOEUD,class NUAGENOEUD,int DIMENSION,int NBR_NOEUDS_PAR_CASE=DTREE_NBR_MIN_NOEUDS> class dTree
+{
+protected :
+ // types
+ typedef _DTREE_ * Ptr_dTree;
+ // Static Const
+ static const int nbr_descendants=DeuxPuissance<DIMENSION>::valeur;
+ // champs
+ NUAGENOEUD * nuage;
+ Ptr_dTree descendant[nbr_descendants];
+ // numéro des noeuds contenus
+ vector<int> * noeud_contenu;
+ int etat;
+ int niveau;
+ dTree * pere;
+ // extrémités de l'hypercube du dTree
+ Sommet_dTree<DIMENSION> coord_max;
+ Sommet_dTree<DIMENSION> coord_min;
+public :
+
+ void init();
+ dTree();
+ // Ce constructeur est le seul constructeur utilisateur, il construit le père puis tous les descendants
+ dTree(NUAGENOEUD *n);
+ // Ce Constructeur est utilisé par le précédent, pour un pere donné, avec deux extrémités données,
+ // il instantie un dTree sans en calculer les noeuds contenus
+ dTree(const Sommet_dTree<DIMENSION> &A,const Sommet_dTree<DIMENSION> &B,dTree *mypere);
+ dTree(const dTree &F);
+ ~dTree();
+ // Renvoie les numéros de noeuds contenus dans le dTree
+ void Get_Noeuds_Filtre(vector<int> &tmp);
+ // renvoie les extrémités
+ Sommet_dTree<DIMENSION> Get_Max() const;
+ Sommet_dTree<DIMENSION> Get_Min() const;
+ // renvoie vrai si P est dans le dTree
+ int is_in_dTree(NOEUD P) const;
+ // calcule la distance topologique locale de P au dTree
+ double calcule_distance(NOEUD P) const;
+ dTree & operator = (const dTree & F);
+ // retourne le sommet du dTree codé par l'entier selecteur (voir explications dans le code)
+ Sommet_dTree<DIMENSION> donne_sommet(int selecteur) const;
+ int a_des_fils() const;
+ // renvoi une reference sur le dTree terminal descendant de this contenant P
+ dTree * trouve_dTree_contenant(NOEUD P) const;
+ // renvoie le point le plus proche de P dans this par la méthode exhaustive brutale
+ int trouve_plus_proche_point_bourrin(NOEUD P) const;
+ // renvoie le point le plus proche de p dans this par la méthode dtree
+ int trouve_plus_proche_point(NOEUD P) const;
+ // renvoie un numéro de point contenu dans this
+ int trouve_un_point() const;
+ // méthode récursive utilisée par trouve_plus_proche_point
+ int tppp_rec(NOEUD P,double &delta,int &flag) const;
+ // dit si P est d-proche de l'hypercube de this
+ int Localise_Point(NOEUD P,double d) const;
+ // utilisé par le constructeur pour créer tout la filiation du dTree
+ void cree_filiation();
+ // méthodes de mesure
+ int Get_Nbr_Descendants_Non_Vides() const;
+ int Get_Nbr_Descendants_Vides() const;
+ int Get_Profondeur_Max() const;
+};
+
+
+//////////////////////////////////////////////////////////////////
+/// ///
+/// CODE ///
+/// ///
+//////////////////////////////////////////////////////////////////
+
+_TEMPLATE_ void _DTREE_::init()
+ {
+ int i;
+ nuage=NULL;
+ noeud_contenu=NULL;
+ etat=DTREE_FANTOME;
+ for (i=0;i<nbr_descendants;i++) descendant[i]=NULL;
+ niveau=-1;
+ pere=NULL;
+ }
+_TEMPLATE_ _DTREE_::dTree()
+ {
+ init();
+ coord_max=0.0;
+ coord_min=0.0;
+ }
+_TEMPLATE_ _DTREE_::dTree(NUAGENOEUD *n)
+ {
+ int i,j;
+ double tmp;
+
+ if (n==NULL)
+ {
+ cerr<<"DTREE : Nuage vide !"<<endl;
+ exit(-1);
+ }
+
+ init();
+ nuage=n;
+ etat=DTREE_RACINE;
+ noeud_contenu=new vector<int>(nuage->size());
+ niveau=0;
+
+ // calcule les extrémités du dTree pere
+ for (i=0;i<DIMENSION;i++)
+ {
+ coord_max[i]=(*nuage)[0][i];
+ coord_min[i]=(*nuage)[0][i];
+ }
+ (*noeud_contenu)[0]=0;
+ for (i=1;i<nuage->size();i++)
+ {
+ (*noeud_contenu)[i]=i;
+ for (j=0;j<DIMENSION;j++)
+ {
+ if ((*nuage)[i][j]>coord_max[j]) coord_max[j]=(*nuage)[i][j];
+ if ((*nuage)[i][j]<coord_min[j]) coord_min[j]=(*nuage)[i][j];
+ }
+ }
+ for (j=0;j<DIMENSION;j++)
+ {
+ tmp=(coord_max[j]-coord_min[j])*0.01;
+ coord_max[j]+=tmp;
+ coord_min[j]-=tmp;
+ }
+
+ // méthode récursive qui construit la filiation
+ cree_filiation();
+
+ }
+_TEMPLATE_ _DTREE_::dTree(const Sommet_dTree<DIMENSION> &A,const Sommet_dTree<DIMENSION> &B,dTree *mypere)
+ {
+ if (mypere!=NULL)
+ {
+
+ int i,j;
+ double tmp;
+
+ init();
+
+ pere=mypere;
+ nuage=pere->nuage;
+ niveau=pere->niveau+1;
+
+ etat=DTREE_COURANT;
+
+ noeud_contenu=new vector<int>;
+ noeud_contenu->reserve((pere->noeud_contenu->size())/nbr_descendants);
+
+ for (i=0;i<DIMENSION;i++)
+ {
+ coord_max[i]=(*nuage)[0][i];
+ coord_min[i]=(*nuage)[0][i];
+ }
+
+ for (i=0;i<DIMENSION;i++)
+ {
+ if (A[i]>B[i])
+ {
+ coord_max[i]=A[i];
+ coord_min[i]=B[i];
+ }
+ else
+ {
+ coord_min[i]=A[i];
+ coord_max[i]=B[i];
+ }
+ }
+ }
+ else
+ {
+ cerr<<"DTREE : Construction de descendance sans père !"<<endl;
+ exit(-1);
+ }
+ }
+_TEMPLATE_ _DTREE_::dTree(const _DTREE_ &F)
+ {
+ // Pas Super Top Moumoute ... Recopie de pointeurs et pas de contenus, merdique
+ int i,j;
+ init();
+ for (i=0;i<nbr_descendants;i++) descendant[i]=F.descendant[i];
+ noeud_contenu=F.noeud_contenu;
+ etat=F.etat;
+ niveau=F.niveau;
+ pere=F.pere;
+ coord_max=F.coord_max;
+ coord_min=F.coord_min;
+ }
+_TEMPLATE_ _DTREE_::~dTree()
+ {
+ int i;
+ nuage=NULL;
+ pere=NULL;
+ // cout<<*this<<endl;
+ if (noeud_contenu)
+ {
+ delete noeud_contenu;
+ }
+ for (i=0;i<nbr_descendants;i++) if (descendant[i])
+ {
+ delete descendant[i];
+ }
+ }
+_TEMPLATE_ void _DTREE_::Get_Noeuds_Filtre(vector<int> &tmp)
+ {
+ int i;
+ switch (etat)
+ {
+ case DTREE_RACINE : int pourlefunlecompilolesttropcon;
+ case DTREE_COURANT :
+ for (i=0;i<nbr_descendants;i++) descendant[i]->Get_Noeuds_Filtre(tmp);
+ case DTREE_TERMINAL :
+ if (noeud_contenu->size()>0)
+ {
+ for (i=0;i<NBR_NOEUDS_PAR_CASE;i++) tmp.push_back((*noeud_contenu)[i]);
+ }
+ default :
+ cerr<<"DTREE : dTree Non Valide dans Rempli_Noeuds_Filtre"<<endl;
+ exit(-1);
+ }
+ }
+_TEMPLATE_ Sommet_dTree<DIMENSION> _DTREE_::Get_Max() const
+ {
+ return coord_max;
+ }
+_TEMPLATE_ Sommet_dTree<DIMENSION> _DTREE_::Get_Min() const
+ {
+ return coord_min;
+ }
+_TEMPLATE_ int _DTREE_::is_in_dTree(NOEUD P) const
+ {
+ int test;
+ for (int i=0;i<DIMENSION;i++)
+ {
+ test=((coord_min[i]<=P[i])&&(P[i]<=coord_max[i]));
+ if (!test) return 0;
+ }
+ return 1;
+
+ }
+// calcule la distance Linf d'un point exterieur, si le point est interieur, le resultat sera erroné
+_TEMPLATE_ double _DTREE_::calcule_distance(NOEUD P) const
+ {
+ double min=fabs(coord_max[0]-P[0]);
+ double tmp;
+ int i;
+ for (i=0;i<DIMENSION;i++)
+ {
+ tmp=fabs(coord_max[i]-P[i]);
+ if (min>tmp) min=tmp;
+ tmp=fabs(coord_min[i]-P[i]);
+ if (min>tmp) min=tmp;
+ }
+ return min;
+ }
+_TEMPLATE_ _DTREE_ & _DTREE_::operator = (const _DTREE_ & F)
+ {
+ // Pas Super Top Moumoute ... Recopie de pointeurs et pas de contenus, merdique
+ int i,j;
+ init();
+ for (i=0;i<nbr_descendans;i++) descendant[i]=F.descendant[i];
+ noeud_contenu=F.noeud_contenu;
+ etat=F.etat;
+ niveau=F.niveau;
+ pere=F.pere;
+ coord_max=F.coord_max;
+ coord_min=F.coord_min;
+ }
+// selecteur doit etre lu comme un nombre en base 2
+// il specifie les coordonnes de reference du sommet dont on veut les coordonnees reelles
+// ex : en dim 3 : coord_min=0+0*2+0*4=0
+// coord_max=1+1*2*1*4=7
+// donc les unites pour x, les 2aines pour y, les 4aines pour z
+_TEMPLATE_ Sommet_dTree<DIMENSION> _DTREE_::donne_sommet(int selecteur) const
+ {
+ Sommet_dTree<DIMENSION> p;
+ int i;
+ int residu=selecteur;
+ int reste;
+ for (i=0;i<DIMENSION;i++)
+ {
+ reste=residu%2;
+ if (reste==0) p[i]=coord_min[i]; else p[i]=coord_max[i];
+ residu=(residu-reste)/2;
+ }
+ return p;
+ }
+_TEMPLATE_ int _DTREE_::a_des_fils() const
+ {
+ if ((etat==DTREE_COURANT)||(etat=DTREE_RACINE)) return 1;
+ else return 0;
+ }
+_TEMPLATE_ _DTREE_ * _DTREE_::trouve_dTree_contenant(NOEUD P) const
+ {
+ Sommet_dTree<DIMENSION> B(coord_min,coord_max);
+ int i;
+ if ((etat==DTREE_RACINE)&&(!is_in_dTree(P))) return NULL; // Le noeud est extérieur a l'dTree
+ else if (etat==DTREE_TERMINAL) return (dTree *) this; // Le noeud est dans *this qui est terminal
+
+ for (i=0;i<nbr_descendants;i++)
+ {
+ Sommet_dTree<DIMENSION> A=donne_sommet(i);
+ int test,j;
+ for (j=0;j<DIMENSION;j++)
+ {
+ if (A[j]<=B[j]) test=((A[j]<=P[j])&&(P[j]<=B[j]));
+ else test=((A[j]>=P[j])&&(P[j]>=B[j]));
+ if (!test) break;
+ }
+
+ if (test) return descendant[i]->trouve_dTree_contenant(P); // Propagation
+ }
+ }
+// si de le dTree n'est pas TERMINAL, scanne tous les points du nuage du pere pour trouver le point le plus proche
+// sinon scanne uniquement les points contenus dans le dTree
+_TEMPLATE_ int _DTREE_::trouve_plus_proche_point_bourrin(NOEUD P) const
+ {
+ int i;
+ int num_sol=0;
+ double min;
+ double tmp;
+ if (etat!=DTREE_TERMINAL)
+ {
+ min=DistanceL2(P,(*nuage)[0]);
+ for (i=1;i<nuage->size();i++)
+ {
+ tmp=DistanceL2(P,(*nuage)[i]);
+ if (tmp<min)
+ {
+ num_sol=i;
+ min=tmp;
+ }
+ }
+ return num_sol;
+ }
+ else
+ {
+ if (noeud_contenu->size()!=0)
+ {
+ num_sol=(*noeud_contenu)[0];
+ min=DistanceL2(P,(*nuage)[num_sol]);
+ for (i=1;i<noeud_contenu->size();i++)
+ {
+ tmp=DistanceL2(P,(*nuage)[(*noeud_contenu)[i]]);
+ if (tmp<min)
+ {
+ num_sol=(*noeud_contenu)[i];
+ min=tmp;
+ }
+ }
+ return num_sol;
+ }
+ else return DTREE_FANTOME;
+ }
+ }
+// Fonction de pilotage de la recursion, lance les tests preliminaires et invoque la recursion
+_TEMPLATE_ int _DTREE_::trouve_plus_proche_point(NOEUD P) const
+ {
+
+ if (etat==DTREE_FANTOME)
+ {
+ cerr<<"DTREE : TROUVE PLUS PROCHE POINT : L'octree n'est pas construit !"<<endl;
+ exit(-1);
+ }
+ dTree *ref=trouve_dTree_contenant(P);
+ double delta;
+
+ if (ref!=NULL)
+ {
+ // Le point est intérieur
+
+ if (ref->pere!=NULL)
+ {
+ delta=DistanceInf((ref->pere->coord_max),(ref->pere->coord_min));
+ }
+ else
+ {
+ cerr<<"DTREE : TROUVE PLUS PROCHE POINT : l'octree contenant le noeud n'a pas de pere !"<<endl;
+ exit(-1);
+ }
+ }
+ else
+ {
+ // Le point est extérieur
+
+ delta=DistanceL2(P,(*nuage)[0]);
+ }
+
+ int flag=0;
+ int retour;
+
+ retour=tppp_rec(P,delta,flag);
+
+ return retour;
+ }
+_TEMPLATE_ int _DTREE_::trouve_un_point() const
+ {
+ if (noeud_contenu!=NULL)
+ {
+ if (noeud_contenu->size()>0) return (*(noeud_contenu))[0];
+ }
+ else
+ {
+ int i;
+ for (i=0;i<nbr_descendants;i++)
+ {
+ return descendant[i]->trouve_un_point();
+ }
+ }
+ }
+// partie recursive de trouve_plus_proche_point
+// change le flag en 1 si un point plus proche est trouvé
+// adapte automatiquement la distance delta de filtrage
+_TEMPLATE_ int _DTREE_::tppp_rec(NOEUD P,double &delta,int &flag) const
+ {
+ if (Localise_Point(P,delta)==0)
+ {
+
+ // La distance du point à l'octree est plus grande que delta
+
+ return DTREE_FANTOME;
+ }
+ int num_Ptmp;
+ double dtmp;
+ if (etat==DTREE_TERMINAL)
+ {
+ if (noeud_contenu->size()>0)
+ {
+ num_Ptmp=trouve_plus_proche_point_bourrin(P);
+ dtmp=DistanceL2((*nuage)[num_Ptmp],P);
+ if (dtmp<=delta)
+ {
+
+ // Le point le plus proche minimise delta, c'est un bon candidat, on l'envoie !
+
+ delta=dtmp;
+ flag=1;
+ return num_Ptmp;
+ }
+
+ // Le point le plus proche ne minimise pas delta
+
+ // ===========> peut etre rajouter exit(-1); ??????????
+ return DTREE_FANTOME;
+ }
+ else
+ {
+
+ // L'octree qui contient P ne contient aucun point
+
+ return DTREE_FANTOME;
+ }
+ }
+ int i;
+ int num_sol=DTREE_FANTOME;
+ for (i=0;i<nbr_descendants;i++)
+ {
+ num_Ptmp=descendant[i]->tppp_rec(P,delta,flag);
+ if ((num_Ptmp!=DTREE_FANTOME)&&(flag==1))
+ {
+
+ // On a trouvé un point qui minimise delta dans une branche
+
+ num_sol=num_Ptmp;
+ }
+ }
+ // A ce stade, on a trouvé un point qui minimise tous les deltas, c'est donc le point le plus proche
+ // REMARQUE : cette affirmation est à la base de l'algorithme par dTree mais est loin d'étre évidente
+
+ return num_sol;
+ }
+
+// renvoie 1 si la distance L inf du noeud a l'octree est plus petite que d, 0 sinon
+_TEMPLATE_ int _DTREE_::Localise_Point(NOEUD P,double d) const
+ {
+ int i;
+ for (i=0;i<DIMENSION;i++)
+ {
+ if (P[i]>coord_max[i]+d) return 0;
+ if (P[i]<coord_min[i]-d) return 0;
+ }
+ return 1;
+ }
+
+// Méthode de construction du dTree par propagation
+_TEMPLATE_ void _DTREE_::cree_filiation()
+ {
+ if (etat!=DTREE_RACINE)
+ {
+ niveau=pere->niveau+1;
+ }
+ else
+ {
+ niveau=0;
+ }
+
+ if (noeud_contenu->size()<=NBR_NOEUDS_PAR_CASE)
+ {
+ etat=DTREE_TERMINAL;
+ }
+ else
+ {
+ int i,num_loc,test;
+
+ Sommet_dTree<DIMENSION> centre(coord_max,coord_min);
+
+ for (i=0;i<nbr_descendants;i++)
+ {
+ descendant[i]=new dTree(centre,donne_sommet(i),this);
+ }
+
+ for (num_loc=0;num_loc<noeud_contenu->size();num_loc++)
+ {
+ int indice=(*noeud_contenu)[num_loc];
+ NOEUD & courant=(*nuage)[indice];
+ test=1;
+ for (i=0;(test)&&(i<nbr_descendants);i++)
+ {
+ if (descendant[i]->is_in_dTree(courant))
+ {
+ descendant[i]->noeud_contenu->push_back(indice);
+ test=0;
+ }
+ }
+ }
+
+ delete noeud_contenu;
+ noeud_contenu=NULL;
+
+ for (i=0;i<nbr_descendants;i++) descendant[i]->cree_filiation();
+ }
+ }
+_TEMPLATE_ int _DTREE_::Get_Nbr_Descendants_Non_Vides() const
+ {
+ int i;
+ int ndnv=0;
+ switch (etat)
+ {
+ case DTREE_RACINE : int pourlefunlecompilolesttropcon;
+ case DTREE_COURANT :
+ for (i=0;i<nbr_descendants;i++) ndnv+=descendant[i]->Get_Nbr_Descendants_Non_Vides();
+ return ndnv;
+ case DTREE_TERMINAL :
+ if (noeud_contenu->size()>0) return 1;
+ else return 0;
+ default :
+ cerr<<"dTree Non Valide dans Get_Nbr_Descendants_Non_Vides"<<endl;
+ return -1;
+ }
+ }
+_TEMPLATE_ int _DTREE_::Get_Nbr_Descendants_Vides() const
+ {
+ int i;
+ int ndnv=0;
+ switch (etat)
+ {
+ case DTREE_RACINE : int pourlefunlecompilolesttropcon;
+ case DTREE_COURANT :
+ for (i=0;i<nbr_descendants;i++) ndnv+=descendant[i]->Get_Nbr_Descendants_Vides();
+ return ndnv;
+ case DTREE_TERMINAL :
+ if (noeud_contenu->size()==0) return 1;
+ else return 0;
+ default :
+ cerr<<"dTree Non Valide dans Get_Nbr_Descendants_Non_Vides"<<endl;
+ return -1;
+ }
+ }
+_TEMPLATE_ int _DTREE_::Get_Profondeur_Max() const
+ {
+ int i;
+ int prof=0;
+ int tmp;
+ switch (etat)
+ {
+ case DTREE_RACINE : int pourlefunlecompilolesttropcon;
+ case DTREE_COURANT :
+ for (i=0;i<nbr_descendants;i++)
+ {
+ tmp=descendant[i]->Get_Profondeur_Max();
+ if (tmp>prof) prof=tmp;
+ }
+ return prof;
+ case DTREE_TERMINAL : return niveau;
+ default :
+ cerr<<"dTree Non Valide dans Get_Nbr_Descendants_Non_Vides"<<endl;
+ return -1;
+ }
+ }
+
+#undef _TEMPLATE_
+#undef _DTREE_
+
+
+#endif
--- /dev/null
+#ifndef SOMMET_HPP
+#define SOMMET_HPP
+
+
+// La classe qui suit sert UNIQUEMENT pour les sommets du dTree
+
+template <int DIMENSION> class Sommet_dTree
+{
+protected :
+ double coord[DIMENSION];
+public :
+ Sommet_dTree()
+ {
+ }
+ Sommet_dTree(double *c)
+ {
+ for (int i=0;i<DIMENSION;i++) coord[i]=c[i];
+ }
+ Sommet_dTree(double c)
+ {
+ for (int i=0;i<DIMENSION;i++) coord[i]=c;
+ }
+ Sommet_dTree(const Sommet_dTree & SO)
+ {
+ for (int i=0;i<DIMENSION;i++) coord[i]=SO.coord[i];
+ }
+ Sommet_dTree(const Sommet_dTree &s1,const Sommet_dTree &s2)
+ {
+ for (int i=0;i<DIMENSION;i++) coord[i]=0.5*(s1[i]+s2[i]);
+ }
+ ~Sommet_dTree()
+ {
+ }
+ const double operator[](int i) const
+ {
+ return coord[i];
+ }
+ double & operator[](int i)
+ {
+ return coord[i];
+ }
+ Sommet_dTree & operator=(const Sommet_dTree &f)
+ {
+ for (int i=0;i<DIMENSION;i++) coord[i]=f.coord[i];return *this;
+ }
+ friend double DistanceInf(const Sommet_dTree<DIMENSION> &A,const Sommet_dTree<DIMENSION> &B)
+ {
+ double max=0;
+ double tmp;
+ for (int i=0;i<DIMENSION;i++)
+ {
+ tmp=fabs(A[i]-B[i]);
+ if (tmp>max) max=tmp;
+ }
+ return max;
+ }
+};
+
+#endif
--- /dev/null
+# MED MEDMEM : MED files in memory
+#
+# 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
+# Module : MED
+
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:$(srcdir):$(srcdir)/tests
+
+MACHINE=PCLINUX
+
+@COMMENCE@
+
+
+EXPORT_PYSCRIPTS = \
+
+
+EXPORT_HEADERS = \
+MEDMEM_dTree.hxx\
+MEDMEM_dTreeSommet.hxx\
+MEDMEM_InterpolationHighLevelObjects.hxx\
+MEDMEM_Interpolation.hxx\
+MEDMEM_InterpolationTools.hxx\
+MEDMEM_Mapping.hxx\
+MEDMEM_MappingTools.hxx\
+MEDMEM_WrapperCells.hxx\
+MEDMEM_WrapperConnectivity.hxx\
+MEDMEM_WrapperField.hxx\
+MEDMEM_WrapperMesh.hxx\
+MEDMEM_WrapperNodes.hxx
+
+
+# Libraries targets
+
+LIB=
+LIB_SRC =
+
+
+# Executables targets
+BIN =
+BIN_SRC =
+BIN_SERVER_IDL =
+BIN_CLIENT_IDL =
+
+TEST_PROGS = \
+test_MEDMEM_InterpolationFlipBack\
+test_MEDMEM_InterpolationFromMesh_toMesh\
+test_MEDMEM_InterpolationRecopieMaillage\
+test_MEDMEM_InterpolationSansRecopieMaillage\
+test_MEDMEM_InterpolationTimeStep\
+UseCasedTree\
+UseCaseInterpolationts\
+UseCaseInterpolationwots\
+UseCaseMapping\
+UseCaseWrapper_Maillage
+
+
+
+
+CPPFLAGS+=-U_DEBUG_ $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I../
+CXXFLAGS+=-U_DEBUG_ -ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome
+#LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lSalomeLoggerServer -L${KERNEL_ROOT_DIR}/lib/salome
+LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lSALOMELocalTrace -L${KERNEL_ROOT_DIR}/lib/salome
+
+#LDFLAGSFORBIN+=$(MED2_LIBS) $(HDF5_LIBS) -L../.libs -lmedmem -lSalomeLoggerServer -L${KERNEL_ROOT_DIR}/lib/salome
+LDFLAGSFORBIN+=$(MED2_LIBS) $(HDF5_LIBS) -L../.libs -lmedmem -lSALOMELocalTrace -L${KERNEL_ROOT_DIR}/lib/salome
+
+LIBSFORBIN=
+
+LDFLAGS=
+
+LIBS=
+
+# build create_mesh :
+bin: create_mesh_interpolation
+
+create_mesh_interpolation: %: %.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(MED2_LIBS) $(HDF5_LIBS) $<
+
+@CONCLUDE@
--- /dev/null
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Interpolation.hxx"
+
+#include <deque>
+
+#include "stdio.h"
+
+main () {
+
+ const char * fromFileName = "ResultatSyrthes.med";
+ const char * toFileName = "MaillageAster.med";
+ const char * resultFileName = "ResultatInterpolation.med";
+
+ const char * fromFieldName = "THERDEP_TEMP____________________";
+
+ const char * fromMeshName = "MA";
+ const char * toMeshName = "MAILLAGE_IDEAS";
+ int handle;
+
+ try {
+
+
+ MED fromMED(MED_DRIVER,fromFileName);
+
+ fromMED.updateSupport();
+
+ MESH toMesh(MED_DRIVER,toFileName,toMeshName);
+
+ deque<DT_IT_> pasDeTemps=fromMED.getFieldIteration (fromFieldName);
+
+ deque<DT_IT_>::const_iterator currentStep;
+
+ INTERPOLATION<3> * myInter ;
+ FIELD<double> * toField ;
+ int flagNewMapping = 1;
+
+ for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++)
+ {
+ FIELD_ * fromField_ = fromMED.getField(fromFieldName,(*currentStep).dt,(*currentStep).it) ;
+
+ FIELD<double> * fromField = dynamic_cast<FIELD<double> *>(fromField_);
+
+ fromField->getSupport()->getMesh()->read();
+
+ fromField->read();
+
+ if (currentStep==pasDeTemps.begin())
+ {
+ myInter = new INTERPOLATION<3>(*fromField,toMesh) ;
+
+ toField = myInter->interpolate(1,1);
+ }
+ else
+ {
+ toField = myInter->interpolateNextStep(*fromField,flagNewMapping);
+ }
+
+ toField->addDriver(MED_DRIVER,resultFileName,toField->getName());
+
+ toField->write();
+
+ if (flagNewMapping==1)
+ {
+ handle = toMesh.addDriver(MED_DRIVER,resultFileName,toMesh.getName()) ;
+
+ toMesh.write(handle);
+ }
+ }
+
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+}
--- /dev/null
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Interpolation.hxx"
+
+#include "stdio.h"
+
+using namespace MEDMEM;
+
+main () {
+
+ const char * fromFileName = "fromMesh.med";
+ const char * toFileName = "toMesh.med";
+ const char * fieldName = "fieldnodedouble";
+
+ const char * fromMeshName = "fromMesh";
+ const char * toMeshName = "toMesh";
+
+ const int flagConvex = 1;
+ const int interpolationType = 1;
+
+ try {
+
+ MESH fromMesh (MED_DRIVER,fromFileName,fromMeshName);
+ SUPPORT fromSupport (&fromMesh,"XsupportX",MED_NODE);
+ FIELD<double> fromField (&fromSupport,MED_DRIVER,fromFileName,fieldName);
+ MESH toMesh (MED_DRIVER,toFileName,toMeshName);
+
+ INTERPOLATION<3> myInter (fromField,toMesh);
+
+ FIELD<double> * toField = myInter.interpolate(interpolationType,flagConvex);
+
+ toField->addDriver(MED_DRIVER,toFileName,toField->getName()) ;
+
+ toField->write();
+
+
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+}
--- /dev/null
+#include "stdio.h"
+#include "stdlib.h"
+
+#include <iostream.h>
+
+#include "MEDMEM_InterpolationHighLevelObjects.hxx"
+
+int main (void)
+{
+int i;
+
+const int DIMENSION = 3;
+
+const int isConvexFromMesh = 1;
+
+const char * fromFileName = "fromMesh.med";
+const char * fromMeshName = "fromMesh";
+
+MESH * fromMesh = new MESH(MED_DRIVER,fromFileName,fromMeshName);
+
+const char * toFileName = "toMesh.med";
+const char * toMeshName = "toMesh";
+
+MESH * toMesh = new MESH(MED_DRIVER,toFileName,toMeshName);
+
+Meta_Wrapper<DIMENSION> * fromWrapper = new Meta_Wrapper<DIMENSION>
+ (
+ fromMesh->getNumberOfNodes(),
+ const_cast<double *> (fromMesh->getCoordinates(MED_FULL_INTERLACE)),
+ const_cast<CONNECTIVITY *> (fromMesh->getConnectivityptr())
+ );
+
+Meta_Wrapper<DIMENSION> * toWrapper = new Meta_Wrapper<DIMENSION>
+ (
+ toMesh->getNumberOfNodes(),
+ const_cast<double *> (toMesh->getCoordinates(MED_FULL_INTERLACE))
+ );
+
+Meta_Mapping<DIMENSION> * mapping = new Meta_Mapping<DIMENSION> (fromWrapper,toWrapper);
+
+mapping->Cree_Mapping(isConvexFromMesh);
+
+vector<int> vectormapping = mapping->Get_Mapping();
+
+for (i=0;i<vectormapping.size();i++)
+ {
+ cout<<"Le noeud "<<i<<" de "<<toMeshName<<" est contenu dans la maille "<<vectormapping[i]<<" de "<<fromMeshName<<endl;
+ }
+
+}
--- /dev/null
+#include "stdio.h"
+#include "stdlib.h"
+
+#include <iostream.h>
+
+#include "MEDMEM_InterpolationHighLevelObjects.hxx"
+
+int main (void)
+{
+int i,j;
+
+const char * fromFileName = "fromMesh.med";
+const char * fromMeshName = "fromMesh";
+
+MESH fromMesh(MED_DRIVER,fromFileName,fromMeshName);
+
+Meta_Nuage_Maille * nuagemailles = new Meta_Nuage_Maille(const_cast<CONNECTIVITY *> (fromMesh.getConnectivityptr()));
+
+int nbr_noeuds = fromMesh.getNumberOfNodes();
+
+Meta_Maillage * maillage = new Meta_Maillage(nuagemailles,nbr_noeuds);
+
+int nbr_mailles = maillage->DONNE_POINTEUR_NUAGEMAILLE()->SIZE();
+
+int nbr_faces;
+
+for (i=0;i<nbr_mailles;i++)
+ {
+ cout<<"Voisins de la maille "<<i<<" : "<<flush;
+ nbr_faces=maillage->DONNE_NBR_FACES_MAILLE(i);
+ for (j=0;j<nbr_faces;j++) cout<<"["<<maillage->DONNE_VOISIN_DE_MAILLE(i,j)<<"]-("<<maillage->EST_AU_BORD_FACE_DE_MAILLE(i,j)<<") "<<flush;
+ cout<<endl;
+ }
+
+}
+
--- /dev/null
+#include "stdio.h"
+#include "stdlib.h"
+
+#include <iostream.h>
+
+#include "MEDMEM_InterpolationHighLevelObjects.hxx"
+
+#define affiche(NOEUD) cout<<flush;for (int iii=0;iii<DIMENSION;iii++) cout<<NOEUD[iii]<<" "<<flush;
+
+int main (void)
+{
+int i;
+
+const int DIMENSION = 3;
+const int NBR_NOEUDS = 8;
+const int NBR_INC = 3;
+
+double noeuds[DIMENSION*NBR_NOEUDS] = { 0,0,0,
+ 1,0,0,
+ 0,1,0,
+ 0,0,1,
+ 1,1,0,
+ 1,0,1,
+ 0,1,1,
+ 1,1,1 };
+
+double noeuds_inconnus[DIMENSION*NBR_INC] = { 2 ,2 ,2 ,
+ 0.2,0.2,0.2,
+ 0 ,0.9,0.9 };
+
+double * tmp1, * tmp2;
+
+for (i=0;i<NBR_NOEUDS;i++)
+ {
+ cout<<"Noeud["<<i<<"] = ";
+ tmp1=&noeuds[DIMENSION*i];
+ affiche(tmp1);
+ cout<<endl;
+ }
+
+Meta_dTree<DIMENSION> Octree(NBR_NOEUDS,noeuds);
+
+for (i=0;i<NBR_INC;i++)
+ {
+ cout<<"Noeud le plus proche de ";
+ tmp1=&noeuds_inconnus[DIMENSION*i];
+ affiche(tmp1);
+ cout<<" : ";
+ tmp2=&noeuds[DIMENSION*Octree.trouve_plus_proche_point(tmp1)];
+ affiche(tmp2);
+ cout<<" ; Vérification par méthode bourrin : ";
+ tmp2=&noeuds[DIMENSION*Octree.trouve_plus_proche_point_bourrin(tmp1)];
+ affiche(tmp2);
+ cout<<endl;
+ }
+
+}
+
--- /dev/null
+#include <med.h>
+#include <string.h>
+
+#define MED_NOPG 1 /* -> pas de point de Gauss */
+#define MED_NOPFL "" /* -> pas de profils utilisateur */
+#define MED_NOPFLi " " /* Variable Interne */
+#define MED_NOPF 0 /* -> pas de profils pour _MEDdataseNnumEcrire */
+#define MED_NOPDT -1 /* rem: pas de pas de temps negatifs */
+#define MED_NONOR -1 /* rem: pas de n°ordre negatif */
+#define MED_DIM1 1 /* PAS */
+
+#define MED_ALL 0
+
+/*****************************************************************************************************/
+
+void affiche_noeuds(med_float * nodes,int nnpl)
+ {
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int i;
+
+ for (i=0;i<nbr_nodes;i++) printf("Noeud %d : ( %4.5f ; %4.5f ; %4.5f )\n",i,nodes[3*i],nodes[3*i+1],nodes[3*i+2]);
+
+ }
+
+
+void cree_nodes(med_float * coord_nodes,int nnpl, int flag)
+ {
+ int i,j,k;
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int num_noeud;
+ int diviseur=nnpl-1+flag;
+
+ /*coord_nodes=(med_float *) malloc(3*nbr_nodes*sizeof(med_float));*/
+
+ for (i=0;i<nnpl;i++) for (j=0;j<nnpl;j++) for (k=0;k<nnpl;k++)
+ {
+ num_noeud=i+nnpl*j+nnpl*nnpl*k;
+
+ if (3*num_noeud >=3*nbr_nodes) {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);}
+ if (3*num_noeud+1>=3*nbr_nodes) {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);}
+ if (3*num_noeud+2>=3*nbr_nodes) {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);}
+
+ coord_nodes[3*num_noeud ]= (double) (i+flag)/diviseur;
+ coord_nodes[3*num_noeud+1]= (double) (j+flag)/diviseur;
+ coord_nodes[3*num_noeud+2]= (double) (k+flag)/diviseur;
+ }
+
+ affiche_noeuds(coord_nodes,nnpl);
+
+ }
+void cree_num_nodes(med_int * num_nodes,int nnpl)
+ {
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int i;
+ /*num_nodes=(med_int *) malloc(nbr_nodes*sizeof(med_int));*/
+ for (i=0;i<nbr_nodes;i++) num_nodes[i]=i+1;//nbr_nodes+i;
+ }
+void cree_Hexa8(med_int * conn_hexa8, int nnpl,med_int * num_nodes)
+ {
+ int i,j,k;
+ int i0,j0,k0,i1,j1,k1;
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int num_hexa8;
+
+ /*conn_hexa8=(med_int *) malloc(8*nbr_hexa8*sizeof(med_int));*/
+
+ for (i=0;i<nnpl-1;i++) for (j=0;j<nnpl-1;j++) for (k=0;k<nnpl-1;k++)
+ {
+ i0=i;j0=j;k0=k;
+ i1=i+1;j1=j+1;k1=k+1;
+
+ num_hexa8=i+(nnpl-1)*j+(nnpl-1)*(nnpl-1)*k;
+
+ if (8*num_hexa8 >=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+1>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+2>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+3>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+4>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+5>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+6>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+ if (8*num_hexa8+7>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
+
+ conn_hexa8[8*num_hexa8 ] = num_nodes[ i0+nnpl*j1+nnpl*nnpl*k1 ];
+ conn_hexa8[8*num_hexa8+1] = num_nodes[ i0+nnpl*j0+nnpl*nnpl*k1 ];
+ conn_hexa8[8*num_hexa8+2] = num_nodes[ i1+nnpl*j0+nnpl*nnpl*k1 ];
+ conn_hexa8[8*num_hexa8+3] = num_nodes[ i1+nnpl*j1+nnpl*nnpl*k1 ];
+ conn_hexa8[8*num_hexa8+4] = num_nodes[ i0+nnpl*j1+nnpl*nnpl*k0 ];
+ conn_hexa8[8*num_hexa8+5] = num_nodes[ i0+nnpl*j0+nnpl*nnpl*k0 ];
+ conn_hexa8[8*num_hexa8+6] = num_nodes[ i1+nnpl*j0+nnpl*nnpl*k0 ];
+ conn_hexa8[8*num_hexa8+7] = num_nodes[ i1+nnpl*j1+nnpl*nnpl*k0 ];
+
+
+ }
+
+ for (num_hexa8=0;num_hexa8<nbr_hexa8;num_hexa8++)
+ {
+ printf("Maille numéro %4d :",num_hexa8);
+ printf("%4d ",conn_hexa8[8*num_hexa8 ]);
+ printf("%4d ",conn_hexa8[8*num_hexa8+1]);
+ printf("%4d ",conn_hexa8[8*num_hexa8+2]);
+ printf("%4d ",conn_hexa8[8*num_hexa8+3]);
+ printf("%4d ",conn_hexa8[8*num_hexa8+4]);
+ printf("%4d ",conn_hexa8[8*num_hexa8+5]);
+ printf("%4d ",conn_hexa8[8*num_hexa8+6]);
+ printf("%4d ",conn_hexa8[8*num_hexa8+7]);
+ printf("\n");
+ }
+ }
+void cree_noms_mailles(char * noms, int nnpl)
+ {
+ int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int i;
+ char pnom[MED_TAILLE_PNOM+1]="hexa ";
+
+ /*noms=(char *) malloc((nbr_hexa8*MED_TAILLE_PNOM+1)*sizeof(char));*/
+
+ for (i=0;i<nbr_hexa8;i++) strncpy(&noms[i*MED_TAILLE_PNOM],pnom,MED_TAILLE_PNOM);
+
+ noms[nbr_hexa8*MED_TAILLE_PNOM]='\n';
+
+ }
+void cree_num_mailles(med_int * num_mailles,int nnpl)
+ {
+ int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int i;
+
+ /*num_mailles=(med_int *) malloc(nbr_hexa8*sizeof(med_int));*/
+
+ for (i=0;i<nbr_hexa8;i++) num_mailles[i]=i+1;
+ }
+void cree_fam_nodes(med_int * fam,int nnpl)
+ {
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int i;
+
+ /*fam=(med_int *) malloc(nbr_nodes*sizeof(med_int));*/
+
+ for (i=0;i<nbr_nodes;i++) fam[i]=0;
+ }
+void cree_fam_mailles(med_int * fam,int nnpl)
+ {
+ int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int i;
+
+ /*fam=(med_int *) malloc(nbr_hexa8*sizeof(med_int));*/
+
+ for (i=0;i<nbr_hexa8;i++) fam[i]=0;
+ }
+void cree_valeurs_champ_node(med_float * val,int nnpl)
+ {
+ int i,j,k;
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int num_noeud;
+ int diviseur=3*(nnpl-1);
+
+ /*val=(med_float *) malloc(nbr_nodes*sizeof(med_float));*/
+
+ for (i=0;i<nnpl;i++) for (j=0;j<nnpl;j++) for (k=0;k<nnpl;k++)
+ {
+ num_noeud=i+nnpl*j+nnpl*nnpl*k;
+ val[num_noeud] = (med_float) (i+j+k)/diviseur;
+ }
+ for (num_noeud=0;num_noeud<nbr_nodes;num_noeud++) printf("Valeur Scalaire noeud %5d : %4.5f\n",num_noeud,val[num_noeud]);
+ }
+void cree_valeurs_champ_vector_node(med_float * val,int nnpl)
+ {
+ int i,j,k;
+ int nbr_nodes=nnpl*nnpl*nnpl;
+ int num_noeud;
+
+ /*val=(med_float *) malloc(nbr_nodes*sizeof(med_float));*/
+
+ for (i=0;i<nnpl;i++) for (j=0;j<nnpl;j++) for (k=0;k<nnpl;k++)
+ {
+ num_noeud=i+nnpl*j+nnpl*nnpl*k;
+ val[3*num_noeud ] = (med_float) 0;
+ val[3*num_noeud+1] = (med_float) 1;
+ val[3*num_noeud+2] = (med_float) 2;
+ }
+ for (num_noeud=0;num_noeud<nbr_nodes;num_noeud++) printf("Valeur Vectorielle noeud %5d : %4.5f %4.5f %4.5f \n ",num_noeud,val[3*num_noeud],val[3*num_noeud+1],val[3*num_noeud+2]);
+ }
+void cree_valeurs_champ_cell(med_float * val,int nnpl)
+ {
+ int i,j,k;
+ int nbr_cells=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int num_cell;
+
+ med_float diviseur=3*(nnpl-2);
+
+ /*val=(med_float *) malloc(3*nbr_cells*sizeof(med_float));*/
+
+ for (i=0;i<nnpl-1;i++) for (j=0;j<nnpl-1;j++) for (k=0;k<nnpl-1;k++)
+ {
+ num_cell=i+(nnpl-1)*j+(nnpl-1)*(nnpl-1)*k;
+ val[num_cell ] = (med_float) (i+j+k)/diviseur;
+ }
+ for (num_cell=0;num_cell<nbr_cells;num_cell++) printf("Valeur scalaire maille %5d : %4.5f\n ",num_cell,val[num_cell]);
+ }
+void cree_valeurs_champ_vector_cell(med_float * val,int nnpl)
+ {
+ int i,j,k;
+ int nbr_cells=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ int num_cell;
+
+ /*val=(med_float *) malloc(3*nbr_cells*sizeof(med_float));*/
+
+ for (i=0;i<nnpl-1;i++) for (j=0;j<nnpl-1;j++) for (k=0;k<nnpl-1;k++)
+ {
+ num_cell=i+(nnpl-1)*j+(nnpl-1)*(nnpl-1)*k;
+ val[3*num_cell ] = (med_float) 0;
+ val[3*num_cell+1] = (med_float) 1;
+ val[3*num_cell+2] = (med_float) 2;
+ }
+ for (num_cell=0;num_cell<nbr_cells;num_cell++) printf("Valeur Vectorielle maille %5d : %4.5f %4.5f %4.5f \n ",num_cell,val[3*num_cell],val[3*num_cell+1],val[3*num_cell+2]);
+ }
+
+
+/*****************************************************************************************************/
+
+int main (int argc, char **argv)
+ {
+
+ int i,j,k;
+
+ int nnpl;
+
+ int nbr_nodes, nbr_hexa8;
+
+ med_err ret;
+ med_idt fromfid;
+ med_idt tofid;
+ char frommaa[MED_TAILLE_NOM+1] = "fromMesh";
+ char tomaa[MED_TAILLE_NOM+1] = "toMesh";
+ const med_int mdim = 3;
+ med_int fromnnoe;
+ med_int tonnoe;
+
+ med_float * tocoo;
+ med_float * fromcoo;
+
+ char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z ";
+ char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm ";
+
+ char * nomnoe = NULL ;
+
+ med_int * fromnumnoe;
+ med_int * fromnufano;
+
+ med_int * tonumnoe;
+ med_int * tonufano;
+
+ med_int fromnhexa8;
+ med_int * fromhexa8;
+
+ med_int tonhexa8;
+ med_int * tohexa8;
+
+
+ char * fromnomhexa8;
+ med_int * fromnumhexa8;
+ med_int * fromnufahexa8;
+
+ char * tonomhexa8;
+ med_int * tonumhexa8;
+ med_int * tonufahexa8;
+
+/*****************************************************************************************************/
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ char gro2[MED_TAILLE_LNOM*2+1];
+ char gro3[MED_TAILLE_LNOM*3+1];
+ int nfame = 1;
+ int nfamn = 1;
+
+/*****************************************************************************************************/
+
+ /* Some fields : one on nodes : double , one on cells : double */
+
+ char champnode[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+ char champnode_comp[MED_TAILLE_PNOM+1]="X+Y+Z " ;
+ char champnode_unit[MED_TAILLE_PNOM+1]="X+Y+Z " ;
+ med_float * fieldnodedouble;
+
+ char champnodevector[MED_TAILLE_NOM+1]="fieldnodedoublevector" ;
+ char champnodevector_comp[MED_TAILLE_PNOM*3+1]="0 1 2 " ;
+ char champnodevector_unit[MED_TAILLE_PNOM*3+1]="O 1 2 " ;
+ med_float * fieldnodedoublevector;
+
+ char champcellscalar[MED_TAILLE_NOM+1]="fieldcelldouble" ;
+ char champcellscalar_comp[MED_TAILLE_PNOM+1]="X+Y+Z " ;
+ char champcellscalar_unit[MED_TAILLE_PNOM+1]="X+Y+Z " ;
+ med_float * fieldcelldouble;
+
+ char champcell[MED_TAILLE_NOM+1]="fieldcelldoublevector" ;
+ char champcell_comp[MED_TAILLE_PNOM*3+1]="0 1 2 " ;
+ char champcell_unit[MED_TAILLE_PNOM*3+1]="0 1 2 " ;
+ med_float * fieldcelldoublevector;
+
+/*****************************************************************************************************/
+
+
+ if (argc!=2)
+ {
+ printf("Il manque un paramètre : le nombre de point par ligne\n");
+ exit(-1);
+ }
+
+ sscanf(argv[1],"%d",&nnpl);
+
+ printf("VERSION 2.0\n");
+ printf("Traitement avec %d noeuds par ligne\n",nnpl);
+
+ fromnnoe = nnpl*nnpl*nnpl ;
+ fromnhexa8 = (nnpl-1)*(nnpl-1)*(nnpl-1) ;
+ tonnoe = (nnpl-1)*(nnpl-1)*(nnpl-1) ;
+ tonhexa8 = (nnpl-2)*(nnpl-2)*(nnpl-2) ;
+
+
+
+ nbr_nodes=nnpl*nnpl*nnpl;
+ nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
+
+ fromcoo = (med_float *) malloc(3*nbr_nodes*sizeof(med_float)); cree_nodes ( fromcoo , nnpl, 0 );
+ fromnumnoe = (med_int *) malloc(nbr_nodes*sizeof(med_int)); cree_num_nodes ( fromnumnoe , nnpl );
+ fromnufano = (med_int *) malloc(nbr_nodes*sizeof(med_int)); cree_fam_nodes ( fromnufano , nnpl );
+ fromhexa8 = (med_int *) malloc(8*nbr_hexa8*sizeof(med_int)); cree_Hexa8 ( fromhexa8 , nnpl ,fromnumnoe);
+ fromnomhexa8 = (char *) malloc((nbr_hexa8*MED_TAILLE_PNOM+1)*sizeof(char)); cree_noms_mailles ( fromnomhexa8 , nnpl );
+ fromnumhexa8 = (med_int *) malloc(nbr_hexa8*sizeof(med_int)); cree_num_mailles ( fromnumhexa8 , nnpl );
+ fromnufahexa8 = (med_int *) malloc(nbr_hexa8*sizeof(med_int)); cree_fam_mailles ( fromnufahexa8 , nnpl );
+
+ fieldnodedouble = (med_float *) malloc(nbr_nodes*sizeof(med_float)); cree_valeurs_champ_node ( fieldnodedouble , nnpl );
+ fieldnodedoublevector = (med_float *) malloc(3*nbr_nodes*sizeof(med_float)); cree_valeurs_champ_vector_node ( fieldnodedoublevector , nnpl );
+ fieldcelldouble = (med_float *) malloc(nbr_hexa8*sizeof(med_float)); cree_valeurs_champ_cell ( fieldcelldouble , nnpl );
+ fieldcelldoublevector = (med_float *) malloc(3*nbr_hexa8*sizeof(med_float)); cree_valeurs_champ_vector_cell ( fieldcelldoublevector , nnpl );
+
+
+ nbr_nodes=(nnpl-1)*(nnpl-1)*(nnpl-1);
+ nbr_hexa8=(nnpl-2)*(nnpl-2)*(nnpl-2);
+
+ tocoo = (med_float *) malloc(3*nbr_nodes*sizeof(med_float)); cree_nodes ( tocoo , nnpl-1, 1 );
+ tonumnoe = (med_int *) malloc(nbr_nodes*sizeof(med_int)); cree_num_nodes ( tonumnoe , nnpl-1 );
+ tonufano = (med_int *) malloc(nbr_nodes*sizeof(med_int)); cree_fam_nodes ( tonufano , nnpl-1 );
+ tohexa8 = (med_int *) malloc(8*nbr_hexa8*sizeof(med_int)); cree_Hexa8 ( tohexa8 , nnpl-1 ,tonumnoe);
+ tonomhexa8 = (char *) malloc((nbr_hexa8*MED_TAILLE_PNOM+1)*sizeof(char)); cree_noms_mailles ( tonomhexa8 , nnpl-1 );
+ tonumhexa8 = (med_int *) malloc(nbr_hexa8*sizeof(med_int)); cree_num_mailles ( tonumhexa8 , nnpl-1 );
+ tonufahexa8 = (med_int *) malloc(nbr_hexa8*sizeof(med_int)); cree_fam_mailles ( tonufahexa8 , nnpl-1 );
+
+
+/*****************************************************************************************************/
+ fromfid = MEDouvrir("fromMesh.med",MED_REMP);
+ if (fromfid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("MEDouvrir : %d\n",ret);
+
+/*****************************************************************************************************/
+ tofid = MEDouvrir("toMesh.med",MED_REMP);
+ if (tofid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("MEDouvrir : %d\n",ret);
+/*****************************************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fromfid,frommaa,mdim);
+ printf("MEDmaaCr : %d\n",ret);
+
+/*****************************************************************************************************/
+
+ if (ret == 0)
+ ret = MEDmaaCr(tofid,tomaa,mdim);
+ printf("MEDmaaCr : %d\n",ret);
+
+/*****************************************************************************************************/
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fromfid,frommaa,mdim,fromcoo,MED_FULL_INTERLACE,MED_CART,
+ // nomcoo,unicoo,nomnoe,MED_FAUX,fromnumnoe,MED_VRAI,
+ nomcoo,unicoo,nomnoe,MED_FAUX,fromnumnoe,MED_FAUX,
+ fromnufano,fromnnoe,MED_ECRI);
+ printf("MEDnoeudsEcr : %d\n",ret);
+/*****************************************************************************************************/
+
+ if (ret == 0)
+ ret = MEDnoeudsEcr(tofid,tomaa,mdim,tocoo,MED_FULL_INTERLACE,MED_CART,
+ //nomcoo,unicoo,nomnoe,MED_FAUX,tonumnoe,MED_VRAI,
+ nomcoo,unicoo,nomnoe,MED_FAUX,tonumnoe,MED_FAUX,
+ tonufano,tonnoe,MED_ECRI);
+ printf("MEDnoeudsEcr : %d\n",ret);
+
+
+/*****************************************************************************************************/
+/* ecriture des mailles MED_HEXA8 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fromfid,frommaa,mdim,fromhexa8,MED_FULL_INTERLACE,
+ fromnomhexa8,MED_FAUX,fromnumhexa8,MED_VRAI,fromnufahexa8,fromnhexa8,
+ MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
+ printf("MEDelementsEcr : %d \n",ret);
+
+/*****************************************************************************************************/
+/* ecriture des mailles MED_HEXA8 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+
+ if (ret == 0)
+ ret = MEDelementsEcr(tofid,tomaa,mdim,tohexa8,MED_FULL_INTERLACE,
+ tonomhexa8,MED_FAUX,tonumhexa8,MED_VRAI,tonufahexa8,tonhexa8,
+ MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
+ printf("MEDelementsEcr : %d \n",ret);
+
+/*****************************************************************************************************/
+/* ecriture des familles */
+/* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+/* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fromfid,frommaa,nomfam,numfam,&attide,&attval,attdes,0,gro,0);
+ }
+ printf("MEDfamCr : %d \n",ret);
+/*****************************************************************************************************/
+
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(tofid,tomaa,nomfam,numfam,&attide,&attval,attdes,0,gro,0);
+ }
+ printf("MEDfamCr : %d \n",ret);
+
+/*****************************************************************************************************/
+/* Les champs */
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fromfid,champnode,MED_REEL64,champnode_comp,champnode_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fromfid, frommaa, champnode, (unsigned char *)fieldnodedouble,
+ MED_FULL_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_FULL_INTERLACE, fromnhexa8,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fromfid,champcellscalar,MED_REEL64,champcellscalar_comp,champcellscalar_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fromfid, frommaa, champcellscalar, (unsigned char *)fieldcelldouble,
+ MED_FULL_INTERLACE, fromnhexa8,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fromfid,champnodevector,MED_REEL64,champnodevector_comp,champnodevector_unit,3);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fromfid, frommaa, champnodevector, (unsigned char *)fieldnodedoublevector,
+ MED_FULL_INTERLACE, fromnnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0. , MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ }
+ }
+
+
+/***************************************************************************/
+ret = MEDfermer(fromfid);
+printf("MEDfermer : %d\n",ret);
+/***************************************************************************/
+ret = MEDfermer(tofid);
+printf("MEDfermer : %d\n",ret);
+
+return 0;
+}
+
--- /dev/null
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Interpolation.hxx"
+
+#include "stdio.h"
+
+main () {
+
+ const char * fromFileName = "fromMesh.med";
+ const char * toFileName = "toMesh.med";
+ //const char * fieldName = "fieldcelldoublevector";
+ const char * fieldName = "fieldnodedouble";
+
+ const char * fromMeshName = "fromMesh";
+ const char * toMeshName = "toMesh";
+
+ try {
+
+ cout<<"Lecture du Maillage Source : "<<flush; MESH fromMesh (MED_DRIVER,fromFileName,fromMeshName); cout<<"OK !"<<endl;
+ //cout<<"Construction du support : "<<flush; SUPPORT fromSupport (&fromMesh,"XsupportX",MED_CELL); cout<<"OK !"<<endl;
+ cout<<"Construction du support : "<<flush; SUPPORT fromSupport (&fromMesh,"XsupportX",MED_NODE); cout<<"OK !"<<endl;
+ cout<<"Lecture du champ : "<<flush; FIELD<double> fromField (&fromSupport,MED_DRIVER,fromFileName,fieldName); cout<<"OK !"<<endl;
+ cout<<"Lecture du Mailllage Cible : "<<flush; MESH toMesh (MED_DRIVER,toFileName,toMeshName); cout<<"OK !"<<endl;
+
+ INTERPOLATION<3> myInter (fromField,toMesh);
+
+ //FIELD<double> * toField = myInter.interpolate(0,1);
+ FIELD<double> * toField = myInter.interpolate(1,1);
+
+ cout<<"Creation du driver"<<endl;
+
+ toField->addDriver(MED_DRIVER,toFileName,toField->getName()) ;
+
+ cout<<"toField->getName() = "<<toField->getName() <<endl;
+ cout<<"toField->getDescription() = "<<toField->getDescription() <<endl;
+ cout<<"toField->getNumberOfComponents() = "<<toField->getNumberOfComponents() <<endl;
+ cout<<"toField->getNumberOfValues() = "<<toField->getNumberOfValues() <<endl;
+ cout<<"toField->getComponentsNames() = "<<toField->getComponentsNames() <<endl;
+ cout<<"toField->getComponentsDescriptions() = "<<toField->getComponentsDescriptions()<<endl;
+ cout<<"toField->getMEDComponentsUnits() = "<<toField->getMEDComponentsUnits() <<endl;
+ cout<<"toField->getIterationNumber() = "<<toField->getIterationNumber() <<endl;
+ cout<<"toField->getTime() = "<<toField->getTime() <<endl;
+ cout<<"toField->getOrderNumber() = "<<toField->getOrderNumber() <<endl;
+ cout<<"toField->getValueType() = "<<toField->getValueType() <<endl;
+
+ toField->write();
+
+ cout<<"Fin"<<endl;
+
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+}
--- /dev/null
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Interpolation.hxx"
+
+#include <deque>
+
+#include "stdio.h"
+
+using namespace MEDMEM;
+
+// pour gestion timings
+#include "time.h"
+
+#define RUN(procedure) {double t0,t1;cout<<"# =============> TEMPS D'EXECUTION A PARTIR D'ICI "<<endl<<#procedure<<endl;t0=CPUtime();procedure;t1=CPUtime();cout<<"# ================> TEMPS D'EXECUTION : "<<t1-t0<<endl;}
+#define TIMORIZE(procedure,t) {double t0,t1;t0=CPUtime();procedure;t1=CPUtime();t=t1-t0;}
+
+double CPUtime()
+ {
+ #ifdef SYSTIMES
+ struct tms buf;
+ if (times(&buf)!=-1)
+ return ((double)buf.tms_utime+(double)buf.tms_stime)/(long) sysconf(_SC_CLK_TCK);
+ else
+ #endif
+ return ((double) clock())/CLOCKS_PER_SEC;
+ }
+
+double ABS(Valeur<double> v)
+ {
+ double tmp=0;
+ int i;
+ for (i=0;i<v.SIZE();i++) tmp+=fabs(v[i]);
+ return tmp;
+ }
+
+double ABS(Valeur<double> v1,Valeur<double> v2)
+ {
+ double tmp=0;
+ int i;
+ for (i=0;i<v1.SIZE();i++) tmp+=fabs(v1[i]-v2[i]);
+ return tmp;
+ }
+
+
+
+// effectue la soustraction du premier moins le second et stocke le résultat dans le premier
+void Flipback(FIELD<double> * firstField, FIELD<double> * secondField)
+ {
+ Wrapper_MED_Field first ( firstField);
+ Wrapper_MED_Field second (secondField);
+ int nbr_valeurs_first = first.Get_Nbr_Valeurs();
+ int nbr_valeurs_second = second.Get_Nbr_Valeurs();
+
+ double max1 = 0;
+ double max2 = 0;
+
+ double min1 = ABS(first[0]);
+ double min2 = ABS(second[0]);
+
+ int imax1,imax2;
+
+ double tmp;
+
+ int i;
+
+ //cout<<first<<endl;
+ //int tyty;cin>>tyty;
+
+ if (nbr_valeurs_first!=nbr_valeurs_second)
+ {
+ cerr<<"Les champs à soustraire n'ont pas le meme nombre de valeurs"<<endl;
+ exit(-1);
+ }
+
+ imax1=0;
+ for (i=0;i<nbr_valeurs_first;i++)
+ {
+ tmp=ABS(first[i]);
+ //cout<<"tmp 1 ["<<i<<"] = "<<tmp<<endl;
+ if (tmp>max1)
+ {
+ imax1=i;
+ max1=tmp;
+ }
+ if (tmp<min1) min1=tmp;
+ }
+
+ imax2=0;
+ for (i=0;i<nbr_valeurs_first;i++)
+ {
+ tmp=ABS(second[i]);
+ if (tmp>max2)
+ {
+ imax2=i;
+ max2=tmp;
+ }
+ if (tmp<min2) min2=tmp;
+ }
+
+ for (i=0;i<nbr_valeurs_first;i++)
+ {
+ first[i]=ABS(first[i],second[i]);
+ }
+
+ double maxdiff=ABS(first[0]);
+ double mindiff=ABS(first[0]);
+
+ for (i=0;i<nbr_valeurs_first;i++)
+ {
+ tmp=ABS(first[i]);
+ if (tmp>maxdiff) maxdiff=tmp;
+ if (tmp<mindiff) mindiff=tmp;
+ }
+
+ cout<<endl;
+ cout<<"/////////////////////////////////////////////////////////////////////////"<<endl;
+ cout<<"/////// max1 = "<<max1<<endl;
+ cout<<"/////// min1 = "<<min1<<endl;
+ cout<<"/////// Maximum First atteint pour i = "<<imax1<<endl;
+ cout<<"/////// max2 = "<<max2<<endl;
+ cout<<"/////// min2 = "<<min2<<endl;
+ cout<<"/////// Maximum Second atteint pour i = "<<imax2<<endl;
+ cout<<"/////// maxdiff = "<<maxdiff<<endl;
+ cout<<"/////// mindiff = "<<mindiff<<endl;
+ cout<<"/////////////////////////////////////////////////////////////////////////"<<endl;
+
+ }
+
+
+#include "MEDMEM_WrapperCells.hxx"
+
+main () {
+
+ const char * fromFileName = "ResultatSyrthes.med";
+ const char * toFileName = "MaillageAster.med";
+ const char * resultFileName = "ResultatFlipback.med";
+
+ const char * fromFieldName = "THERDEP_TEMP____________________";
+
+ const char * fromMeshName = "MA";
+ const char * toMeshName = "MAILLAGE_IDEAS";
+ int handle;
+
+ try {
+
+ string flag="================[MAIN MESSAGES]================> ";
+
+ cout<<flag<<"Lecture de la structure MED : "<<flush;
+ MED fromMED (MED_DRIVER,fromFileName);
+ cout<<"OK !"<<endl;
+
+ // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
+ fromMED.updateSupport();
+
+ cout<<flag<<"Lecture du Mailllage Cible : "<<flush;
+ MESH toMesh (MED_DRIVER,toFileName,toMeshName);
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Lecture des pas de temps : "<<flush;
+ deque<DT_IT_> pasDeTemps=fromMED.getFieldIteration (fromFieldName);
+ cout<<"OK !"<<endl;
+
+ deque<DT_IT_>::const_iterator currentStep;
+
+ INTERPOLATION<3> * interFromTo ;
+ INTERPOLATION<3> * interToFrom ;
+ FIELD<double> * toField ;
+ FIELD<double> * toToField ;
+ int flagNewMappingFromTo = 0;
+ int flagNewMappingToFrom = 0;
+
+ for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++)
+ {
+ cout<<flag<<"Traitement du Step ( "<<flush<<(*currentStep).dt<<" ; "<<(*currentStep).it<<" ) : "<<endl;
+
+ cout<<flag<<"Lecture du FIELD_ "<<flush;
+ FIELD_ * fromField_ = fromMED.getField(fromFieldName,(*currentStep).dt,(*currentStep).it);
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Transtypage en FIELD : "<<flush;
+ FIELD<double> * fromField = dynamic_cast<FIELD<double> *>(fromField_);
+ cout<<"OK !"<<endl;
+
+ if (currentStep==pasDeTemps.begin())
+ {
+ //Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
+ RUN(fromField->getSupport()->getMesh()->read());
+ }
+
+ MESH * fromMesh = fromField->getSupport()->getMesh();
+
+ cout<<flag<<"Lecture des valeurs du FIELD : "<<flush;
+ RUN(fromField->read());
+ cout<<"OK !"<<endl;
+
+ if (currentStep==pasDeTemps.begin())
+ {
+ cout<<flag<<"Préparation de l'interpolation DIRECTE pour le premier pas de temps : "<<flush;
+ RUN(interFromTo = new INTERPOLATION<3>(*fromField,toMesh));
+ cout<<"OK !"<<endl;
+ cout<<flag<<"Interpolation effective DIRECTE du premier pas de temps : "<<flush;
+ RUN(toField = interFromTo->interpolate(1,1));
+ cout<<"OK !"<<endl;
+ cout<<flag<<"Préparation de l'interpolation INVERSE pour le premier pas de temps : "<<flush;
+ RUN(interToFrom = new INTERPOLATION<3>(*toField,*fromMesh));
+ cout<<"OK !"<<endl;
+ cout<<flag<<"Interpolation effective INVERSE du premier pas de temps : "<<flush;
+ RUN(toToField = interToFrom->interpolate(1,1));
+ cout<<"OK !"<<endl;
+ }
+ else
+ {
+ cout<<flag<<"Interpolation nextStep DIRECTE : "<<flush;
+ RUN(toField = interFromTo->interpolateNextStep(*fromField,flagNewMappingFromTo));
+ cout<<"OK !"<<endl;
+ cout<<flag<<"Interpolation nextStep INVERSE : "<<flush;
+ RUN(toToField = interToFrom->interpolateNextStep(*toField,flagNewMappingToFrom));
+ cout<<"OK !"<<endl;
+ }
+
+ cout<<flag<<"Calcul du flip back : "<<flush;
+ Flipback(toToField,fromField);
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Creation du driver d'écriture Field : "<<flush;
+ toToField->addDriver(MED_DRIVER,resultFileName,toToField->getName());
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Ecriture du Field résultat : "<<flush;
+ toToField->write();
+ cout<<"OK !"<<endl;
+
+ if (flagNewMappingToFrom==1)
+ {
+ cout<<flag<<"Creation du driver d'écriture Mesh : "<<flush;
+ handle = fromMesh->addDriver(MED_DRIVER,resultFileName,fromMesh->getName()) ;
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Ecriture du Mesh résultat : "<<flush;
+ fromMesh->write(handle);
+ cout<<"OK !"<<endl;
+ }
+ }
+
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+}
--- /dev/null
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Interpolation.hxx"
+
+#include "stdio.h"
+
+main () {
+
+ const char * fromFileName = "fromMesh.med";
+ const char * toFileName = "toMesh.med";
+ //const char * fieldName = "fieldcelldoublevector";
+ const char * fieldName = "fieldnodedouble";
+
+ const char * fromMeshName = "fromMesh";
+ const char * toMeshName = "toMesh";
+
+ try {
+
+ cout<<"Lecture du Maillage Source : "<<flush; MESH fromMesh (MED_DRIVER,fromFileName,fromMeshName); cout<<"OK !"<<endl;
+ //cout<<"Construction du support : "<<flush; SUPPORT fromSupport (&fromMesh,"XsupportX",MED_CELL); cout<<"OK !"<<endl;
+ cout<<"Construction du support : "<<flush; SUPPORT fromSupport (&fromMesh,"XsupportX",MED_NODE); cout<<"OK !"<<endl;
+ cout<<"Lecture du champ : "<<flush; FIELD<double> fromField (&fromSupport,MED_DRIVER,fromFileName,fieldName); cout<<"OK !"<<endl;
+ cout<<"Lecture du Mailllage Cible : "<<flush; MESH toMesh (MED_DRIVER,toFileName,toMeshName); cout<<"OK !"<<endl;
+
+ INTERPOLATION<3> myInter (fromField,toMesh);
+
+ //FIELD<double> * toField = myInter.interpolate(0,1);
+ FIELD<double> * toField = myInter.interpolate(1,1);
+
+ cout<<"Creation du driver"<<endl;
+
+ toField->addDriver(MED_DRIVER,toFileName,toField->getName()) ;
+
+ cout<<"toField->getName() = "<<toField->getName() <<endl;
+ cout<<"toField->getDescription() = "<<toField->getDescription() <<endl;
+ cout<<"toField->getNumberOfComponents() = "<<toField->getNumberOfComponents() <<endl;
+ cout<<"toField->getNumberOfValues() = "<<toField->getNumberOfValues() <<endl;
+ cout<<"toField->getComponentsNames() = "<<toField->getComponentsNames() <<endl;
+ cout<<"toField->getComponentsDescriptions() = "<<toField->getComponentsDescriptions()<<endl;
+ cout<<"toField->getMEDComponentsUnits() = "<<toField->getMEDComponentsUnits() <<endl;
+ cout<<"toField->getIterationNumber() = "<<toField->getIterationNumber() <<endl;
+ cout<<"toField->getTime() = "<<toField->getTime() <<endl;
+ cout<<"toField->getOrderNumber() = "<<toField->getOrderNumber() <<endl;
+ cout<<"toField->getValueType() = "<<toField->getValueType() <<endl;
+
+ toField->write();
+
+ cout<<"Fin"<<endl;
+
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+}
--- /dev/null
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Interpolation.hxx"
+
+#include <deque>
+
+#include "stdio.h"
+
+
+
+// pour gestion timings
+#include "time.h"
+
+#define RUN(procedure) {double t0,t1;cout<<"# =============> TEMPS D'EXECUTION A PARTIR D'ICI "<<endl<<#procedure<<endl;t0=CPUtime();procedure;t1=CPUtime();cout<<"# ================> TEMPS D'EXECUTION : "<<t1-t0<<endl;}
+#define TIMORIZE(procedure,t) {double t0,t1;t0=CPUtime();procedure;t1=CPUtime();t=t1-t0;}
+
+double CPUtime()
+ {
+ #ifdef SYSTIMES
+ struct tms buf;
+ if (times(&buf)!=-1)
+ return ((double)buf.tms_utime+(double)buf.tms_stime)/(long) sysconf(_SC_CLK_TCK);
+ else
+ #endif
+ return ((double) clock())/CLOCKS_PER_SEC;
+ }
+
+
+
+#include "MEDMEM_WrapperCells.hxx"
+
+main () {
+/*
+int taille=100;
+int * liste = new int [taille] ;
+int i,j;
+int nbr_faces;
+for (i=0;i<taille;i++) liste[i]=i;
+
+Wrapper_Maille_Tria3 Tria3 ;Tria3 .positionne(liste);cout<<"Tria3 "<<endl;Tria3 .export_connectivite();
+Wrapper_Maille_Tria6 Tria6 ;Tria6 .positionne(liste);cout<<"Tria6 "<<endl;Tria6 .export_connectivite();
+Wrapper_Maille_Quad4 Quad4 ;Quad4 .positionne(liste);cout<<"Quad4 "<<endl;Quad4 .export_connectivite();
+Wrapper_Maille_Quad8 Quad8 ;Quad8 .positionne(liste);cout<<"Quad8 "<<endl;Quad8 .export_connectivite();
+Wrapper_Maille_Tetra4 Tetra4 ;Tetra4 .positionne(liste);cout<<"Tetra4 "<<endl;Tetra4 .export_connectivite();
+Wrapper_Maille_Tetra10 Tetra10;Tetra10.positionne(liste);cout<<"Tetra10"<<endl;Tetra10.export_connectivite();
+Wrapper_Maille_Hexa8 Hexa8 ;Hexa8 .positionne(liste);cout<<"Hexa8 "<<endl;Hexa8 .export_connectivite();
+Wrapper_Maille_Hexa20 Hexa20 ;Hexa20 .positionne(liste);cout<<"Hexa20 "<<endl;Hexa20 .export_connectivite();
+Wrapper_Maille_Pyra5 Pyra5 ;Pyra5 .positionne(liste);cout<<"Pyra5 "<<endl;Pyra5 .export_connectivite();
+Wrapper_Maille_Pyra13 Pyra13 ;Pyra13 .positionne(liste);cout<<"Pyra13 "<<endl;Pyra13 .export_connectivite();
+Wrapper_Maille_Penta6 Penta6 ;Penta6 .positionne(liste);cout<<"Penta6 "<<endl;Penta6 .export_connectivite();
+Wrapper_Maille_Penta15 Penta15;Penta15.positionne(liste);cout<<"Penta15"<<endl;Penta15.export_connectivite();
+//*/
+
+//*
+ const char * fromFileName = "ResultatSyrthes.med";
+ const char * toFileName = "MaillageAster.med";
+ const char * resultFileName = "ResultatInterpolation.med";
+
+ const char * fromFieldName = "THERDEP_TEMP____________________";
+
+ const char * fromMeshName = "MA";
+ const char * toMeshName = "MAILLAGE_IDEAS";
+ int handle;
+
+ try {
+
+ string flag="================[MAIN MESSAGES]================> ";
+
+ cout<<flag<<"Lecture de la structure MED : "<<flush;
+ MED fromMED (MED_DRIVER,fromFileName);
+ cout<<"OK !"<<endl;
+
+ // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
+ fromMED.updateSupport();
+
+ cout<<flag<<"Lecture du Mailllage Cible : "<<flush;
+ MESH toMesh (MED_DRIVER,toFileName,toMeshName);
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Lecture des pas de temps : "<<flush;
+ deque<DT_IT_> pasDeTemps=fromMED.getFieldIteration (fromFieldName);
+ cout<<"OK !"<<endl;
+
+ deque<DT_IT_>::const_iterator currentStep;
+
+ INTERPOLATION<3> * myInter ;
+ FIELD<double> * toField ;
+ int flagNewMapping = 1;
+
+ for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++)
+ {
+ cout<<flag<<"Traitement du Step ( "<<flush<<(*currentStep).dt<<" ; "<<(*currentStep).it<<" ) : "<<endl;
+
+ cout<<flag<<"Lecture du FIELD_ "<<flush;
+ FIELD_ * fromField_ = fromMED.getField(fromFieldName,(*currentStep).dt,(*currentStep).it);
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Transtypage en FIELD : "<<flush;
+ FIELD<double> * fromField = dynamic_cast<FIELD<double> *>(fromField_);
+ cout<<"OK !"<<endl;
+
+ if (currentStep==pasDeTemps.begin())
+ {
+ //Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
+ RUN(fromField->getSupport()->getMesh()->read());
+ }
+
+ cout<<flag<<"Lecture des valeurs du FIELD : "<<flush;
+ RUN(fromField->read());
+ cout<<"OK !"<<endl;
+
+ if (currentStep==pasDeTemps.begin())
+ {
+ cout<<flag<<"Préparation de l'interpolation pour le premier pas de temps : "<<flush;
+ RUN(myInter = new INTERPOLATION<3>(*fromField,toMesh));
+ cout<<"OK !"<<endl;
+ cout<<flag<<"Interpolation effective du premier pas de temps : "<<flush;
+ RUN(toField = myInter->interpolate(1,1));
+ cout<<"OK !"<<endl;
+ }
+ else
+ {
+ cout<<flag<<"Interpolation nextStep : "<<flush;
+ RUN(toField = myInter->interpolateNextStep(*fromField,flagNewMapping));
+ cout<<"OK !"<<endl;
+ }
+
+ cout<<flag<<"Creation du driver d'écriture Field : "<<flush;
+ toField->addDriver(MED_DRIVER,resultFileName,toField->getName());
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Ecriture du Field résultat : "<<flush;
+ toField->write();
+ cout<<"OK !"<<endl;
+
+ if (flagNewMapping==1)
+ {
+ cout<<flag<<"Creation du driver d'écriture Mesh : "<<flush;
+ handle = toMesh.addDriver(MED_DRIVER,resultFileName,toMesh.getName()) ;
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Ecriture du Mesh résultat : "<<flush;
+ toMesh.write(handle);
+ cout<<"OK !"<<endl;
+ }
+ }
+
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+//*/
+}
--- /dev/null
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Interpolation.hxx"
+
+#include <deque>
+
+#include "stdio.h"
+
+main () {
+
+ const char * fromFileName = "ResultatSyrthes.med";
+ const char * toFileName = "MaillageAster.med";
+// const char * resultFileName = "ResultatInterpolation.med";
+
+ const char * fromFieldName = "THERDEP_TEMP____________________";
+
+ const char * fromMeshName = "MA";
+ const char * toMeshName = "MAILLAGE_IDEAS";
+
+ try {
+
+ string flag="================[MAIN MESSAGES]================> ";
+
+ cout<<flag<<"Lecture de la structure MED : "<<flush; MED fromMED (MED_DRIVER,fromFileName) ; cout<<"OK !"<<endl;
+
+ // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
+ fromMED.updateSupport();
+
+ cout<<flag<<"Lecture du Maillage Source : "<<flush; MESH fromMesh (MED_DRIVER,fromFileName,fromMeshName) ; cout<<"OK !"<<endl;
+ cout<<flag<<"Lecture du Mailllage Cible : "<<flush; MESH toMesh (MED_DRIVER,toFileName,toMeshName) ; cout<<"OK !"<<endl;
+ cout<<flag<<"Lecture des pas de temps : "<<flush; deque<DT_IT_> pasDeTemps=fromMED.getFieldIteration (fromFieldName) ; cout<<"OK !"<<endl;
+ cout<<flag<<"Lecture du FIELD_ au premier pas de temps : "<<flush; FIELD_ * fromField_ = fromMED.getField(fromFieldName,pasDeTemps[0].dt,pasDeTemps[0].it) ; cout<<"OK !"<<endl;
+ cout<<flag<<"Transtypage en FIELD : "<<flush; FIELD<double> * fromField = dynamic_cast<FIELD<double> *>(fromField_) ; cout<<"OK !"<<endl;
+
+ // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
+ fromField->getSupport()->getMesh()->read();
+
+ cout<<flag<<"Lecture des valeurs du FIELD : "<<flush; fromField->read() ; cout<<"OK !"<<endl;
+ cout<<flag<<"Préparation de l'interpolation : "<<flush; INTERPOLATION<3> myInter (*fromField,toMesh) ; cout<<"OK !"<<endl;
+ cout<<flag<<"Interpolation effective : "<<flush; FIELD<double> * toField = myInter.interpolate(1,1) ; cout<<"OK !"<<endl;
+ cout<<flag<<"Creation du driver d'écriture : "<<flush; toField->addDriver(MED_DRIVER,toFileName,toField->getName()) ; cout<<"OK !"<<endl;
+// cout<<flag<<"Creation du driver d'écriture Field : "<<flush; toField->addDriver(MED_DRIVER,resultFileName,toField->getName()) ; cout<<"OK !"<<endl;
+ cout<<flag<<"Ecriture du Field résultat : "<<flush; toField->write() ; cout<<"OK !"<<endl;
+// cout<<flag<<"Creation du driver d'écriture Mesh : "<<flush; toMesh.addDriver(MED_DRIVER,resultFileName,toMesh.getName()) ; cout<<"OK !"<<endl;
+// cout<<flag<<"Ecriture du Mesh résultat : "<<flush; toMesh.write(1) ; cout<<"OK !"<<endl;
+
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+}
--- /dev/null
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Interpolation.hxx"
+
+#include <deque>
+
+#include "stdio.h"
+
+main () {
+
+ const char * fromFileName = "ResultatSyrthes.med";
+ const char * toFileName = "MaillageAster.med";
+ const char * resultFileName = "ResultatInterpolation.med";
+
+ const char * fromFieldName = "THERDEP_TEMP____________________";
+
+ const char * fromMeshName = "MA";
+ const char * toMeshName = "MAILLAGE_IDEAS";
+ int handle;
+
+ try {
+
+ string flag="================[MAIN MESSAGES]================> ";
+
+ cout<<flag<<"Lecture de la structure MED : "<<flush;
+ MED fromMED (MED_DRIVER,fromFileName);
+ cout<<"OK !"<<endl;
+
+ // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
+ fromMED.updateSupport();
+
+ cout<<flag<<"Lecture du Mailllage Cible : "<<flush;
+ MESH toMesh (MED_DRIVER,toFileName,toMeshName);
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Lecture des pas de temps : "<<flush;
+ deque<DT_IT_> pasDeTemps=fromMED.getFieldIteration (fromFieldName);
+ cout<<"OK !"<<endl;
+
+ deque<DT_IT_>::const_iterator currentStep;
+
+ INTERPOLATION<3> * myInter ;
+ FIELD<double> * toField ;
+ int flagNewMapping = 1;
+
+ for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++)
+ {
+ cout<<flag<<"Traitement du Step ( "<<flush<<(*currentStep).dt<<" ; "<<(*currentStep).it<<" ) : "<<endl;
+
+ cout<<flag<<"Lecture du FIELD_ "<<flush;
+ FIELD_ * fromField_ = fromMED.getField(fromFieldName,(*currentStep).dt,(*currentStep).it) ;
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Transtypage en FIELD : "<<flush;
+ FIELD<double> * fromField = dynamic_cast<FIELD<double> *>(fromField_);
+ cout<<"OK !"<<endl;
+
+ // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
+ fromField->getSupport()->getMesh()->read();
+
+ cout<<flag<<"Lecture des valeurs du FIELD : "<<flush; fromField->read();
+ cout<<"OK !"<<endl;
+
+ if (currentStep==pasDeTemps.begin())
+ {
+ cout<<flag<<"Préparation de l'interpolation pour le premier pas de temps : "<<flush;
+ myInter = new INTERPOLATION<3>(*fromField,toMesh) ;
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Interpolation effective du premier pas de temps : "<<flush;
+ toField = myInter->interpolate(1,1);
+ cout<<"OK !"<<endl;
+ }
+ else
+ {
+ cout<<flag<<"Interpolation nextStep : "<<flush;
+ toField = myInter->interpolateNextStep(*fromField,flagNewMapping);
+ cout<<"OK !"<<endl;
+ }
+
+ cout<<flag<<"Creation du driver d'écriture Field : "<<flush;
+ toField->addDriver(MED_DRIVER,resultFileName,toField->getName());
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Ecriture du Field résultat : "<<flush;
+ toField->write();
+ cout<<"OK !"<<endl;
+
+ if (flagNewMapping==1)
+ {
+ cout<<flag<<"Creation du driver d'écriture Mesh : "<<flush;
+ handle = toMesh.addDriver(MED_DRIVER,resultFileName,toMesh.getName()) ;
+ cout<<"OK !"<<endl;
+
+ cout<<flag<<"Ecriture du Mesh résultat : "<<flush;
+ toMesh.write(handle);
+ cout<<"OK !"<<endl;
+ }
+ }
+
+ } catch (MEDEXCEPTION& ex){
+ MESSAGE(ex.what()) ;
+ }
+}
LIB_SERVER_IDL = MED_Gen.idl SALOME_Component.idl \
SALOME_Exception.idl MED.idl
-LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_ModuleCatalog.idl
+LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_ModuleCatalog.idl SALOME_Comm.idl
# Executables targets
BIN =
const char* studyName)
throw(SALOME::SALOME_Exception)
{
+ beginService("Med_Gen_i::readStructFile");
+
SCRUTE(fileName);
SALOMEDS::Study_var myStudy = studyName2Study(studyName) ;
- if (!_duringLoad) addInStudy(myStudy) ;
+// if (!_duringLoad) addInStudy(myStudy) ;
SALOME_MED::MED_ptr myMedIOR ;
try
MED_i * myMedI = new MED_i();
myMedIOR = myMedI->_this() ;
// if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR) ;
- if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR,fileName) ;
+// if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR,fileName) ;
// create ::MED object, read all and add in study !
myMedI->init(myStudy,MED_DRIVER,fileName) ;
}
THROW_SALOME_CORBA_EXCEPTION("Unable to open File "\
,SALOME::BAD_PARAM);
}
- return SALOME_MED::MED::_duplicate(myMedIOR) ;
+
+ endService("Med_Gen_i::readStructFile");
+ return myMedIOR;
}
//=============================================================================
const char* studyName)
throw (SALOME::SALOME_Exception)
{
- BEGIN_OF("Med_Gen_i::readStructFileWithFieldType (const char* fileName,const char* studyName)");
+ beginService("Med_Gen_i::readStructFileWithFieldType");
+
+ BEGIN_OF("Med_Gen_i::readStructFileWithFieldType (const char* fileName,const char* studyName)");
SCRUTE(fileName);
SALOMEDS::Study_var myStudy = studyName2Study(studyName) ;
,SALOME::BAD_PARAM);
}
+ endService("Med_Gen_i::readStructFileWithFieldType");
END_OF("Med_Gen_i::readStructFileWithFieldType (const char* fileName,const char* studyName)");
const char* meshName)
throw (SALOME::SALOME_Exception)
{
+ beginService("Med_Gen_i::readMeshInFile");
SCRUTE(fileName);
SALOMEDS::Study_var myStudy = studyName2Study(studyName) ;
- if (!_duringLoad) addInStudy(myStudy) ;
+// if (!_duringLoad) addInStudy(myStudy) ;
// Creation du maillage
try
{
// add the mesh object in study
- if (!_duringLoad) meshi->addInStudy(myStudy,mesh);
+// if (!_duringLoad) meshi->addInStudy(myStudy,mesh);
}
catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {}
- return SALOME_MED::MESH::_duplicate(mesh);
+
+ endService("Med_Gen_i::readMeshInFile");
+ return mesh;
}
//=============================================================================
/*!
CORBA::Long iter)
throw (SALOME::SALOME_Exception)
{
+ beginService("Med_Gen_i::readFieldInFile");
SCRUTE(fileName);
string myStudyName(studyName);
// Creation du champ
- FIELD_ * myField= new FIELD_() ;
+ FIELD_ * myField;
MED * mymed = new MED(MED_DRIVER,fileName) ;
try
{
};
SUPPORT * fieldSupport;
- SALOME_MED::SUPPORT_ptr mySupportIOR;
try
{
fieldSupport=(SUPPORT *)myField->getSupport() ;
myMesh->read();
SCRUTE(myMesh->getName());
fieldSupport->update();
- SUPPORT_i * mySupportI = new SUPPORT_i(fieldSupport);
- mySupportIOR=mySupportI->_this();
}
catch (const exception & ex)
{
try
{
((FIELD<int>*)myField)->read() ;
- FIELDINT_i * myFieldIntI = new FIELDINT_i(mySupportIOR,(FIELD<int>*)myField);
- POA_SALOME_MED::FIELD_tie<FIELD_i> * myFieldTie = new POA_SALOME_MED::FIELD_tie<FIELD_i>(myFieldIntI);
- SALOME_MED::FIELD_ptr myFieldIOR = myFieldTie->_this() ;
- if (!_duringLoad) myFieldIntI->addInStudy(myStudy,myFieldIOR) ;
- return SALOME_MED::FIELD::_duplicate(myFieldIOR);
+ FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
+ SALOME_MED::FIELD_ptr myFieldIOR = myFieldIntI->_this();
+// if (!_duringLoad) myFieldIntI->addInStudy(myStudy,myFieldIOR) ;
+ endService("Med_Gen_i::readFieldInFile");
+ return myFieldIOR;
}
catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {}
catch (const exception & ex)
try
{
((FIELD<double>*)myField)->read() ;
- FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i(mySupportIOR,(FIELD<double>*)myField);
- POA_SALOME_MED::FIELD_tie<FIELD_i> * myFieldTie = new POA_SALOME_MED::FIELD_tie<FIELD_i>(myFieldDoubleI);
- SALOME_MED::FIELD_ptr myFieldIOR = myFieldTie->_this() ;
- if (!_duringLoad) myFieldDoubleI->addInStudy(myStudy,myFieldIOR) ;
- return SALOME_MED::FIELD::_duplicate(myFieldIOR);
+ FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
+ SALOME_MED::FIELD_ptr myFieldIOR = myFieldDoubleI->_this() ;
+// if (!_duringLoad) myFieldDoubleI->addInStudy(myStudy,myFieldIOR) ;
+ endService("Med_Gen_i::readFieldInFile");
+ return myFieldIOR;
}
catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {}
catch (const exception & ex)
/*!
A template class to generate an array of any particular type (int, long,
- float, double) for our purpose in the MED++ library./n/n
+ float, double) for our purpose in the MED++ library.\n\n
Arrays can be stored in MED_FULL_INTERLACE mode (ie : x1,y1,z1,x2,y2,z2...) or
- in MED_NO_INTERLACE mode ( x1,x2,..xn, y1, y2 ..,yn,z1,...,zn)./n The alternate
+ in MED_NO_INTERLACE mode ( x1,x2,..xn, y1, y2 ..,yn,z1,...,zn).\n The alternate
representation mode is calculate ONLY when it is usefull. We assure coherency
for minor data modifications (element, line or column) if you use set methods.
But, if you get a pointer and modify the array, no automatical coherency is possible.
- You can use calculateOther to force a recalculation and insure the coherency./n
- No recalculation is done, when the entire array is modified./n
+ You can use calculateOther to force a recalculation and insure the coherency.\n
+ No recalculation is done, when the entire array is modified.\n
Theses arrays are "Med like" arrays; lower bound equals 1. (first element is element 1,
- first coordinate is coordinate 1). /n
+ first coordinate is coordinate 1). \n
- Available constructors are :/n
+ Available constructors are :\n
- - default constructor (not very usefull)/n
- - constructor asking for array dimensions and mode (does memory allocation for you)/n
+ - default constructor (not very usefull)\n
+ - constructor asking for array dimensions and mode (does memory allocation for you)\n
- constructor asking for array dimensions, mode and values (doesn't do memory allocation
- but copies pointers only.)/n
- - a copy constructor which copies only pointers./n
+ but copies pointers only.)\n
+ - a copy constructor which copies only pointers.\n
(be aware of coherency)
- - a copy constructor which copies data (deepcopy)./n
- - assignement operator is also available and only copies pointers (and not data)./n/n
+ - a copy constructor which copies data (deepcopy).\n
+ - assignement operator is also available and only copies pointers (and not data).\n\n
Attribute "pointers" aren't standard pointers but class PointerOf objects in order to simplify
- memory management./n
+ memory management.\n
A simple test program (testUArray) allows to test this class.
*/
MEDARRAY (const med_int ld_values, const med_int length_values,
const medModeSwitch mode=MED_FULL_INTERLACE);
MEDARRAY (T* values, const med_int ld_values,
- const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE);
+ const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE,bool shallowCopy=false, bool ownershipOfValues=false);
MEDARRAY (MEDARRAY const &m);
MEDARRAY (MEDARRAY const &m, bool copyOther);
MEDARRAY & operator = (const MEDARRAY & m);
+ MEDARRAY & shallowCopy(const MEDARRAY & m);
+
inline med_int getLeadingValue() const;
inline med_int getLengthValue() const;
You don't have to know the T values when calling this construtor
but you have to call "set" method to initialize them later.
You also can get the pointer to the memory zone (with "get" method),
- and work with it./n
+ and work with it.\n
The desallocation of T array is not your responsability. \n\n
Throws MEDEXCEPTION if T array length is < 1*/
template <class T> MEDARRAY<T>::MEDARRAY( T*values,
const med_int ld_values,
const med_int length_values,
- const medModeSwitch mode):
+ const medModeSwitch mode,
+ bool shallowCopy,
+ bool ownershipOfValues):
_ldValues(ld_values),
_lengthValues(length_values),
_mode(mode),
}
if ( _mode == MED_FULL_INTERLACE)
{
- _valuesFull.set(_ldValues*length_values,values);
- _valuesDefault.set((T*)_valuesFull);
+ if(shallowCopy)
+ {
+ if(ownershipOfValues)
+ {
+ _valuesFull.setShallowAndOwnership((const T*)values);
+ }
+ else
+ {
+ _valuesFull.set((const T*)values);
+ }
+ }
+ else
+ {
+ _valuesFull.set(_ldValues*length_values,values);
+ }
+ _valuesDefault.set((T*)_valuesFull);
}
else
{
ASSERT (_mode == MED_NO_INTERLACE);
- _valuesNo.set(_ldValues*length_values,values);
+ if(shallowCopy)
+ {
+ if(ownershipOfValues)
+ {
+ _valuesNo.setShallowAndOwnership((const T*)values);
+ }
+ else
+ {
+ _valuesNo.set((const T*)values);
+ }
+ }
+ else
+ _valuesNo.set(_ldValues*length_values,values);
_valuesDefault.set((T*)_valuesNo);
}
-
ASSERT( (T*)_valuesDefault != NULL);
SCRUTE((T*)_valuesDefault);
SCRUTE((T*)_valuesOther);
// ------------------
- /*! This constructor allocates a new medarray and does a copy of pointers/n
- It DOES NOT copy the memory . The two objects will share the same data./n
+ /*! This constructor allocates a new medarray and does a copy of pointers\n
+ It DOES NOT copy the memory . The two objects will share the same data.\n
(for copying data, use constructor MEDARRAY(MEDARRAY<T> const & m,bool copyOther). */
template <class T> MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m ):
_ldValues(m._ldValues),
}
/*! This constructor allocates a new array and does a copy of values
- included in the m arrays./n
+ included in the m arrays.\n
If the boolean is setted to true, both representations (in full mode
- and no interlace mode) will be copied./n
- Otherwise, only _valuesDefault will be copied./n
- Desallocation of the arrays is not your reponsability./n/n
+ and no interlace mode) will be copied.\n
+ Otherwise, only _valuesDefault will be copied.\n
+ Desallocation of the arrays is not your reponsability.\n\n
Throws MEDEXCEPTION if _valuesOther is null and copyOther equals true*/
template <class T> MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & p,bool copyOther ):
_ldValues(p._ldValues),
// ------------------
-// /*! This operator does a copy of pointers/n
+// /*! This operator does a copy of pointers\n
// It DOES NOT copy of the memory.
-// The two objects will share data./n */
+// The two objects will share data.\n */
template <class T> MEDARRAY<T> & MEDARRAY<T>::operator = (const MEDARRAY & m)
{
return *this;
}
+/*! Idem operator= but performs only shallow copy (just copy of pointers) of arrays contains in _valuesFull and _valuesNo \n
+ WARNING the MEDARRAY returned HAS THE OWNERSHIP OF THE ARRAY !!!! */
+
+template <class T> MEDARRAY<T> & MEDARRAY<T>::shallowCopy(const MEDARRAY & m)
+{
+ _ldValues=m._ldValues;
+ _lengthValues=m._lengthValues;
+ _mode=m._mode;
+ if ((const T*) m._valuesFull !=NULL)
+ _valuesFull.setShallowAndOwnership((const T*) m._valuesFull);
+ if ((const T*) m._valuesNo !=NULL)
+ _valuesNo.setShallowAndOwnership((const T*) m._valuesNo);
+ if (_mode == MED_FULL_INTERLACE) {
+ _valuesDefault.set((T*) _valuesFull);
+ _valuesOther.set((T*) _valuesNo);
+ } else {
+ _valuesDefault.set((T*) _valuesNo);
+ _valuesOther.set((T*) _valuesFull);
+ }
+ return *this;
+}
+
// ------------------
/*! returns _ldValues. (for example, space dimension for coordinates array)*/
// ------------------
/*! returns a pointer to ith element of the array.
- (ith line in a MED_FULL_INTERLACE representation )/n
+ (ith line in a MED_FULL_INTERLACE representation )\n
Be aware : if _mode is MED_NO_INTERLACE, the entire
- array will be recalculate in MED_FULL_INTERLACE representation./n*/
+ array will be recalculate in MED_FULL_INTERLACE representation.\n*/
template <class T> const T* MEDARRAY<T>::getRow(const med_int i)
{
}
// ------------------
- /*! this method is similar to getRow method./n
+ /*! this method is similar to getRow method.\n
It returns a pointer to jth line of the array in a MED_NO-INTERLACE representation
- (for example, 2nd coordinates)./n
+ (for example, 2nd coordinates).\n
Be aware : if _mode is MED_FULL_INTERLACE, the entire
- array will be recalculate in MED_NO_INTERLACE representation./n*/
+ array will be recalculate in MED_NO_INTERLACE representation.\n*/
template <class T> const T* MEDARRAY<T>::getColumn(const med_int j)
{
// ------------------
- /*! returns the default mode (_mode)/n
+ /*! returns the default mode (_mode)\n
(internal use : needed by write method) */
template <class T> inline medModeSwitch MEDARRAY<T>::getMode() const
{
// ------------------
/*! Sets ith element to T* values\n
- if they both exist, both _valuesFull and _valuesNo arrays will be updated./n
+ if they both exist, both _valuesFull and _valuesNo arrays will be updated.\n
Throws exception if i < 1 or i > _lengthValues */
template <class T> void MEDARRAY<T>::setI(const med_int i, const T* value)
{
// ------------------
/*! Sets ith element to T* values\n
- if they both exist, both _valuesFull and _valuesNo arrays will be updated./n
+ if they both exist, both _valuesFull and _valuesNo arrays will be updated.\n
Throws exception if i < 1 or i > _lengthValues */
template <class T> void MEDARRAY<T>::setJ(const med_int j, const T* value)
{
// ------------------
- /*! Sets value of Jth coordinate of Ith element to T value./n
- Maintains coherency./n
+ /*! Sets value of Jth coordinate of Ith element to T value.\n
+ Maintains coherency.\n
Throws exception if we don't have
1<=i<=_lengthValues and 1<=j<=_ldValues */
template <class T> void MEDARRAY<T>::setIJ(const med_int i, const med_int j, const T value)
}
/*! Calculates the other mode of representation : MED_FULL_INTERLACE
- if __mode = MED_NO_INTERLACE and vice versa./n
+ if __mode = MED_NO_INTERLACE and vice versa.\n
Throws exception if no value are setted */
template <class T> void MEDARRAY<T>::calculateOther()
{
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=2 ;
- _numberOfNodeOfEachConstituent=new (int*)[1] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[2] ;
+ _numberOfNodeOfEachConstituent=new int*[1] ;
+ _numberOfNodeOfEachConstituent[0]=new int[2] ;
_numberOfNodeOfEachConstituent[0][0]=1 ;
_numberOfNodeOfEachConstituent[0][1]=1 ;
- _constituents = new (int**)[1] ;
- _constituents[0] = new (int*)[2] ;
+ _constituents = new int**[1] ;
+ _constituents[0] = new int*[2] ;
_constituents[0][0] = new int[1] ;
_constituents[0][0][0] = 1 ;
_constituents[0][1] = new int[1] ;
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=3 ;
- _numberOfNodeOfEachConstituent=new (int*)[1] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[3] ;
+ _numberOfNodeOfEachConstituent=new int*[1] ;
+ _numberOfNodeOfEachConstituent[0]=new int[3] ;
_numberOfNodeOfEachConstituent[0][0]=1 ;
_numberOfNodeOfEachConstituent[0][1]=1 ;
_numberOfNodeOfEachConstituent[0][2]=1 ;
- _constituents = new (int**)[1] ;
- _constituents[0] = new (int*)[3] ;
+ _constituents = new int**[1] ;
+ _constituents[0] = new int*[3] ;
_constituents[0][0] = new int[1] ;
_constituents[0][0][0] = 1 ;
_constituents[0][1] = new int[1] ;
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=3 ;
- _numberOfNodeOfEachConstituent=new (int*)[1] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[3] ;
+ _numberOfNodeOfEachConstituent=new int*[1] ;
+ _numberOfNodeOfEachConstituent[0]=new int[3] ;
_numberOfNodeOfEachConstituent[0][0]=2 ;
_numberOfNodeOfEachConstituent[0][1]=2 ;
_numberOfNodeOfEachConstituent[0][2]=2 ;
int* _edge3=new int[2];
_edge3[0]=3;
_edge3[1]=1;
- int ** tmpConstituents1 = new (int*)[3];
+ int ** tmpConstituents1 = new int*[3];
tmpConstituents1[0]=_edge1 ;
tmpConstituents1[1]=_edge2 ;
tmpConstituents1[2]=_edge3 ;
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=3 ;
- _numberOfNodeOfEachConstituent=new (int*)[1] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[3] ;
+ _numberOfNodeOfEachConstituent=new int*[1] ;
+ _numberOfNodeOfEachConstituent[0]=new int[3] ;
_numberOfNodeOfEachConstituent[0][0]=3 ;
_numberOfNodeOfEachConstituent[0][1]=3 ;
_numberOfNodeOfEachConstituent[0][2]=3 ;
_edge3[0]=3;
_edge3[1]=1;
_edge3[2]=6;
- int ** tmpConstituents1 = new (int*)[3];
+ int ** tmpConstituents1 = new int*[3];
tmpConstituents1[0]=_edge1 ;
tmpConstituents1[1]=_edge2 ;
tmpConstituents1[2]=_edge3 ;
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=4 ;
- _numberOfNodeOfEachConstituent=new (int*)[1] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[4] ;
+ _numberOfNodeOfEachConstituent=new int*[1] ;
+ _numberOfNodeOfEachConstituent[0]=new int[4] ;
_numberOfNodeOfEachConstituent[0][0]=2 ;
_numberOfNodeOfEachConstituent[0][1]=2 ;
_numberOfNodeOfEachConstituent[0][2]=2 ;
int* _edge4=new int[2];
_edge4[0]=4;
_edge4[1]=1;
- int ** tmpConstituents1 = new (int*)[4];
+ int ** tmpConstituents1 = new int*[4];
tmpConstituents1[0]=_edge1 ;
tmpConstituents1[1]=_edge2 ;
tmpConstituents1[2]=_edge3 ;
_numberOfConstituentsDimension=1 ;
_numberOfConstituents=new int[1] ;
_numberOfConstituents[0]=4 ;
- _numberOfNodeOfEachConstituent=new (int*)[1] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[4] ;
+ _numberOfNodeOfEachConstituent=new int*[1] ;
+ _numberOfNodeOfEachConstituent[0]=new int[4] ;
_numberOfNodeOfEachConstituent[0][0]=3 ;
_numberOfNodeOfEachConstituent[0][1]=3 ;
_numberOfNodeOfEachConstituent[0][2]=3 ;
_edge4[0]=4;
_edge4[1]=1;
_edge4[2]=8;
- int ** tmpConstituents1 = new (int*)[4];
+ int ** tmpConstituents1 = new int*[4];
tmpConstituents1[0]=_edge1 ;
tmpConstituents1[1]=_edge2 ;
tmpConstituents1[2]=_edge3 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=4 ;
_numberOfConstituents[1]=6 ;
- _numberOfNodeOfEachConstituent=new (int*)[2] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[4] ;
+ _numberOfNodeOfEachConstituent=new int*[2] ;
+ _numberOfNodeOfEachConstituent[0]=new int[4] ;
_numberOfNodeOfEachConstituent[0][0]=3 ;
_numberOfNodeOfEachConstituent[0][1]=3 ;
_numberOfNodeOfEachConstituent[0][2]=3 ;
_numberOfNodeOfEachConstituent[0][3]=3 ;
- _numberOfNodeOfEachConstituent[1]=new (int)[6] ;
+ _numberOfNodeOfEachConstituent[1]=new int[6] ;
_numberOfNodeOfEachConstituent[1][0]=2 ;
_numberOfNodeOfEachConstituent[1][1]=2 ;
_numberOfNodeOfEachConstituent[1][2]=2 ;
int* _edge6=new int[2];
_edge6[0]=3;
_edge6[1]=4;
- int ** tmpConstituents1 = new (int*)[4];
+ int ** tmpConstituents1 = new int*[4];
tmpConstituents1[0]=_face1 ;
tmpConstituents1[1]=_face2 ;
tmpConstituents1[2]=_face3 ;
tmpConstituents1[3]=_face4 ;
- int ** tmpConstituents2 = new (int*)[6];
+ int ** tmpConstituents2 = new int*[6];
tmpConstituents2[0]=_edge1 ;
tmpConstituents2[1]=_edge2 ;
tmpConstituents2[2]=_edge3 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=4 ;
_numberOfConstituents[1]=6 ;
- _numberOfNodeOfEachConstituent=new (int*)[2] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[4] ;
+ _numberOfNodeOfEachConstituent=new int*[2] ;
+ _numberOfNodeOfEachConstituent[0]=new int[4] ;
_numberOfNodeOfEachConstituent[0][0]=6 ;
_numberOfNodeOfEachConstituent[0][1]=6 ;
_numberOfNodeOfEachConstituent[0][2]=6 ;
_numberOfNodeOfEachConstituent[0][3]=6 ;
- _numberOfNodeOfEachConstituent[1]=new (int)[6] ;
+ _numberOfNodeOfEachConstituent[1]=new int[6] ;
_numberOfNodeOfEachConstituent[1][0]=3 ;
_numberOfNodeOfEachConstituent[1][1]=3 ;
_numberOfNodeOfEachConstituent[1][2]=3 ;
_edge6[0]=3;
_edge6[1]=4;
_edge6[2]=10;
- int ** tmpConstituents1 = new (int*)[4];
+ int ** tmpConstituents1 = new int*[4];
tmpConstituents1[0]=_face1 ;
tmpConstituents1[1]=_face2 ;
tmpConstituents1[2]=_face3 ;
tmpConstituents1[3]=_face4 ;
- int ** tmpConstituents2 = new (int*)[6];
+ int ** tmpConstituents2 = new int*[6];
tmpConstituents2[0]=_edge1 ;
tmpConstituents2[1]=_edge2 ;
tmpConstituents2[2]=_edge3 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=6 ;
_numberOfConstituents[1]=12 ;
- _numberOfNodeOfEachConstituent=new (int*)[2] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[6] ;
+ _numberOfNodeOfEachConstituent=new int*[2] ;
+ _numberOfNodeOfEachConstituent[0]=new int[6] ;
_numberOfNodeOfEachConstituent[0][0]=4 ;
_numberOfNodeOfEachConstituent[0][1]=4 ;
_numberOfNodeOfEachConstituent[0][2]=4 ;
_numberOfNodeOfEachConstituent[0][3]=4 ;
_numberOfNodeOfEachConstituent[0][4]=4 ;
_numberOfNodeOfEachConstituent[0][5]=4 ;
- _numberOfNodeOfEachConstituent[1]=new (int)[12] ;
+ _numberOfNodeOfEachConstituent[1]=new int[12] ;
_numberOfNodeOfEachConstituent[1][0]=2 ;
_numberOfNodeOfEachConstituent[1][1]=2 ;
_numberOfNodeOfEachConstituent[1][2]=2 ;
_face6[1]=8;
_face6[2]=5;
_face6[3]=1;
- int ** tmpConstituents1 = new (int*)[6];
+ int ** tmpConstituents1 = new int*[6];
tmpConstituents1[0]=_face1 ;
tmpConstituents1[1]=_face2 ;
tmpConstituents1[2]=_face3 ;
tmpConstituents1[3]=_face4 ;
tmpConstituents1[4]=_face5 ;
tmpConstituents1[5]=_face6 ;
- int ** tmpConstituents2 = new (int*)[12];
+ int ** tmpConstituents2 = new int*[12];
tmpConstituents2[0]=_edge1 ;
tmpConstituents2[1]=_edge2 ;
tmpConstituents2[2]=_edge3 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=6 ;
_numberOfConstituents[1]=12 ;
- _numberOfNodeOfEachConstituent=new (int*)[2] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[6] ;
+ _numberOfNodeOfEachConstituent=new int*[2] ;
+ _numberOfNodeOfEachConstituent[0]=new int[6] ;
_numberOfNodeOfEachConstituent[0][0]=8 ;
_numberOfNodeOfEachConstituent[0][1]=8 ;
_numberOfNodeOfEachConstituent[0][2]=8 ;
_numberOfNodeOfEachConstituent[0][3]=8 ;
_numberOfNodeOfEachConstituent[0][4]=8 ;
_numberOfNodeOfEachConstituent[0][5]=8 ;
- _numberOfNodeOfEachConstituent[1]=new (int)[12] ;
+ _numberOfNodeOfEachConstituent[1]=new int[12] ;
_numberOfNodeOfEachConstituent[1][0]=3 ;
_numberOfNodeOfEachConstituent[1][1]=3 ;
_numberOfNodeOfEachConstituent[1][2]=3 ;
_face6[5]=16;
_face6[6]=17;
_face6[7]=12;
- int ** tmpConstituents1 = new (int*)[6];
+ int ** tmpConstituents1 = new int*[6];
tmpConstituents1[0]=_face1 ;
tmpConstituents1[1]=_face2 ;
tmpConstituents1[2]=_face3 ;
tmpConstituents1[3]=_face4 ;
tmpConstituents1[4]=_face5 ;
tmpConstituents1[5]=_face6 ;
- int ** tmpConstituents2 = new (int*)[12];
+ int ** tmpConstituents2 = new int*[12];
tmpConstituents2[0]=_edge1 ;
tmpConstituents2[1]=_edge2 ;
tmpConstituents2[2]=_edge3 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=5 ;
_numberOfConstituents[1]=9 ;
- _numberOfNodeOfEachConstituent=new (int*)[2] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[5] ;
+ _numberOfNodeOfEachConstituent=new int*[2] ;
+ _numberOfNodeOfEachConstituent[0]=new int[5] ;
_numberOfNodeOfEachConstituent[0][0]=3 ;
_numberOfNodeOfEachConstituent[0][1]=3 ;
_numberOfNodeOfEachConstituent[0][2]=4 ;
_numberOfNodeOfEachConstituent[0][3]=4 ;
_numberOfNodeOfEachConstituent[0][4]=4 ;
- _numberOfNodeOfEachConstituent[1]=new (int)[9] ;
+ _numberOfNodeOfEachConstituent[1]=new int[9] ;
_numberOfNodeOfEachConstituent[1][0]=2 ;
_numberOfNodeOfEachConstituent[1][1]=2 ;
_numberOfNodeOfEachConstituent[1][2]=2 ;
_face5[1]=6;
_face5[2]=4;
_face5[3]=1;
- int ** tmpConstituents1 = new (int*)[5];
+ int ** tmpConstituents1 = new int*[5];
tmpConstituents1[0]=_face1 ;
tmpConstituents1[1]=_face2 ;
tmpConstituents1[2]=_face3 ;
tmpConstituents1[3]=_face4 ;
tmpConstituents1[4]=_face5 ;
- int ** tmpConstituents2 = new (int*)[9];
+ int ** tmpConstituents2 = new int*[9];
tmpConstituents2[0]=_edge1 ;
tmpConstituents2[1]=_edge2 ;
tmpConstituents2[2]=_edge3 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=5 ;
_numberOfConstituents[1]=9 ;
- _numberOfNodeOfEachConstituent=new (int*)[2] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[5] ;
+ _numberOfNodeOfEachConstituent=new int*[2] ;
+ _numberOfNodeOfEachConstituent[0]=new int[5] ;
_numberOfNodeOfEachConstituent[0][0]=6 ;
_numberOfNodeOfEachConstituent[0][1]=6 ;
_numberOfNodeOfEachConstituent[0][2]=8 ;
_numberOfNodeOfEachConstituent[0][3]=8 ;
_numberOfNodeOfEachConstituent[0][4]=8 ;
- _numberOfNodeOfEachConstituent[1]=new (int)[9] ;
+ _numberOfNodeOfEachConstituent[1]=new int[9] ;
_numberOfNodeOfEachConstituent[1][0]=3 ;
_numberOfNodeOfEachConstituent[1][1]=3 ;
_numberOfNodeOfEachConstituent[1][2]=3 ;
_face5[5]=12;
_face5[6]=13;
_face5[7]=9;
- int ** tmpConstituents1 = new (int*)[5];
+ int ** tmpConstituents1 = new int*[5];
tmpConstituents1[0]=_face1 ;
tmpConstituents1[1]=_face2 ;
tmpConstituents1[2]=_face3 ;
tmpConstituents1[3]=_face4 ;
tmpConstituents1[4]=_face5 ;
- int ** tmpConstituents2 = new (int*)[9];
+ int ** tmpConstituents2 = new int*[9];
tmpConstituents2[0]=_edge1 ;
tmpConstituents2[1]=_edge2 ;
tmpConstituents2[2]=_edge3 ;
tmpConstituents2[6]=_edge7 ;
tmpConstituents2[7]=_edge8 ;
tmpConstituents2[8]=_edge9 ;
- _constituents = new (int**)[2] ;
+ _constituents = new int**[2] ;
_constituents[0]=tmpConstituents1 ;
_constituents[1]=tmpConstituents2 ;
medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ;
tmpConstituentsType2[6] = MED_SEG3 ;
tmpConstituentsType2[7] = MED_SEG3 ;
tmpConstituentsType2[8] = MED_SEG3 ;
- _constituentsType = new (medGeometryElement*)[2] ;
+ _constituentsType = new medGeometryElement*[2] ;
_constituentsType[0]=tmpConstituentsType1 ;
_constituentsType[1]=tmpConstituentsType2 ;
break ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=5 ;
_numberOfConstituents[1]=8 ;
- _numberOfNodeOfEachConstituent=new (int*)[2] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[5] ;
+ _numberOfNodeOfEachConstituent=new int*[2] ;
+ _numberOfNodeOfEachConstituent[0]=new int[5] ;
_numberOfNodeOfEachConstituent[0][0]=4 ;
_numberOfNodeOfEachConstituent[0][1]=3 ;
_numberOfNodeOfEachConstituent[0][2]=3 ;
_numberOfNodeOfEachConstituent[0][3]=3 ;
_numberOfNodeOfEachConstituent[0][4]=3 ;
- _numberOfNodeOfEachConstituent[1]=new (int)[8] ;
+ _numberOfNodeOfEachConstituent[1]=new int[8] ;
_numberOfNodeOfEachConstituent[1][0]=2 ;
_numberOfNodeOfEachConstituent[1][1]=2 ;
_numberOfNodeOfEachConstituent[1][2]=2 ;
_face5[0]=4;
_face5[1]=5;
_face5[2]=1;
- int ** tmpConstituents1 = new (int*)[5];
+ int ** tmpConstituents1 = new int*[5];
tmpConstituents1[0]=_face1 ;
tmpConstituents1[1]=_face2 ;
tmpConstituents1[2]=_face3 ;
tmpConstituents1[3]=_face4 ;
tmpConstituents1[4]=_face5 ;
- int ** tmpConstituents2 = new (int*)[8];
+ int ** tmpConstituents2 = new int*[8];
tmpConstituents2[0]=_edge1 ;
tmpConstituents2[1]=_edge2 ;
tmpConstituents2[2]=_edge3 ;
_numberOfConstituents=new int[2] ;
_numberOfConstituents[0]=5 ;
_numberOfConstituents[1]=8 ;
- _numberOfNodeOfEachConstituent=new (int*)[2] ;
- _numberOfNodeOfEachConstituent[0]=new (int)[5] ;
+ _numberOfNodeOfEachConstituent=new int*[2] ;
+ _numberOfNodeOfEachConstituent[0]=new int[5] ;
_numberOfNodeOfEachConstituent[0][0]=8 ;
_numberOfNodeOfEachConstituent[0][1]=6 ;
_numberOfNodeOfEachConstituent[0][2]=6 ;
_numberOfNodeOfEachConstituent[0][3]=6 ;
_numberOfNodeOfEachConstituent[0][4]=6 ;
- _numberOfNodeOfEachConstituent[1]=new (int)[8] ;
+ _numberOfNodeOfEachConstituent[1]=new int[8] ;
_numberOfNodeOfEachConstituent[1][0]=3 ;
_numberOfNodeOfEachConstituent[1][1]=3 ;
_numberOfNodeOfEachConstituent[1][2]=3 ;
_face5[3]=13;
_face5[4]=10;
_face5[5]=9;
- int ** tmpConstituents1 = new (int*)[5];
+ int ** tmpConstituents1 = new int*[5];
tmpConstituents1[0]=_face1 ;
tmpConstituents1[1]=_face2 ;
tmpConstituents1[2]=_face3 ;
tmpConstituents1[3]=_face4 ;
tmpConstituents1[4]=_face5 ;
- int ** tmpConstituents2 = new (int*)[8];
+ int ** tmpConstituents2 = new int*[8];
tmpConstituents2[0]=_edge1 ;
tmpConstituents2[1]=_edge2 ;
tmpConstituents2[2]=_edge3 ;
for(int i=0; i<_numberOfConstituentsDimension; i++)
_numberOfConstituents[i]=m._numberOfConstituents[i] ;
- _numberOfNodeOfEachConstituent = new (int*)[_numberOfConstituentsDimension] ;
+ _numberOfNodeOfEachConstituent = new int*[_numberOfConstituentsDimension] ;
for(int i=0; i<_numberOfConstituentsDimension; i++) {
int numberOf = _numberOfConstituents[i] ;
int * newArray = new int[numberOf] ;
newArray[j] = oldArray[j] ;
_numberOfNodeOfEachConstituent[i] = newArray ;
}
- _constituents = new (int**)[_numberOfConstituentsDimension] ;
- _constituentsType = new (medGeometryElement*)[_numberOfConstituentsDimension] ;
+ _constituents = new int**[_numberOfConstituentsDimension] ;
+ _constituentsType = new medGeometryElement*[_numberOfConstituentsDimension] ;
for(int i=0; i<_numberOfConstituentsDimension; i++) {
int numberOf = _numberOfConstituents[i] ;
- int ** tmpArray = new (int*)[numberOf] ;
+ int ** tmpArray = new int*[numberOf] ;
medGeometryElement * newArrayType = new medGeometryElement[numberOf] ;
medGeometryElement * oldArrayType = m._constituentsType[i] ;
{
private:
- /*! private method : /n
+ /*! private method : \n
used by constructor and operator= */
void init(const CELLMODEL &m);
- /*! private method : /n */
+ /*! private method : \n */
void clean();
/*! returns number of nodes forming this type of cell */
inline int getNumberOfNodes() const;
- /*! returns the dimension of this type of cell./n
+ /*! returns the dimension of this type of cell.\n
it can be different from mesh dimension */
inline int getDimension() const;
using namespace MEDMEM;
/*!
- Default Constructor. /n
+ Default Constructor. \n
Default for Entity is MED_CELL and type of Connectivity is MED_NODAL */
//--------------------------------------------------------------//
CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity /* =MED_CELL */) :
}
/*!
- Constructor. /n
+ Constructor. \n
Default for Entity is MED_CELL */
//------------------------------------------------------------------------------//
CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity /* =MED_CELL */):
}
/*!
- Destructor./n
+ Destructor.\n
desallocates existing pointers */
//----------------------------//
CONNECTIVITY::~CONNECTIVITY()
if (_nodal==NULL)
calculateNodalConnectivity();
- if(_reverseNodalConnectivity==NULL) {
-
- med_int node_number = 0;
- vector <vector <med_int> > reverse_connectivity;
- reverse_connectivity.resize(_numberOfNodes+1);
+ if(_reverseNodalConnectivity==NULL)
+ {
+ med_int node_number = 0;
+ vector <vector <med_int> > reverse_connectivity;
+ reverse_connectivity.resize(_numberOfNodes+1);
- // Treat all cells types
+ // Treat all cells types
- for (med_int j = 0; j < _numberOfTypes; j++)
- {
- // node number of the cell type
- node_number = _type[j].getNumberOfNodes();
- // treat all cells of a particular type
- for (med_int k = _count[j]; k < _count[j+1]; k++)
- // treat all nodes of the cell type
- for (med_int local_node_number = 1; local_node_number < node_number+1; local_node_number++)
- {
- med_int global_node = _nodal->getIJ(k,local_node_number);
- reverse_connectivity[global_node].push_back(k);
- }
- }
+ for (med_int j = 0; j < _numberOfTypes; j++)
+ {
+ // node number of the cell type
+ node_number = _type[j].getNumberOfNodes();
+ // treat all cells of a particular type
+ for (med_int k = _count[j]; k < _count[j+1]; k++)
+ // treat all nodes of the cell type
+ for (med_int local_node_number = 1;
+ local_node_number < node_number+1;
+ local_node_number++)
+ {
+ med_int global_node = _nodal->getIJ(k,local_node_number);
+ reverse_connectivity[global_node].push_back(k);
+ }
+ }
- // Full reverse_nodal_connectivity and reverse_nodal_connectivity_index
+ // Full reverse_nodal_connectivity and reverse_nodal_connectivity_index
- //calculate size of reverse_nodal_connectivity array
- med_int size_reverse_nodal_connectivity = 0;
- for (med_int i = 1; i < _numberOfNodes+1; i++)
- size_reverse_nodal_connectivity += reverse_connectivity[i].size();
+ //calculate size of reverse_nodal_connectivity array
+ med_int size_reverse_nodal_connectivity = 0;
+ for (med_int i = 1; i < _numberOfNodes+1; i++)
+ size_reverse_nodal_connectivity += reverse_connectivity[i].size();
//MEDSKYLINEARRAY * ReverseConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity);
- med_int * reverse_nodal_connectivity_index = new (med_int)[_numberOfNodes+1];
- med_int * reverse_nodal_connectivity = new (med_int)[size_reverse_nodal_connectivity];
+ med_int * reverse_nodal_connectivity_index = new med_int[_numberOfNodes+1];
+ med_int * reverse_nodal_connectivity = new med_int[size_reverse_nodal_connectivity];
//const med_int * reverse_nodal_connectivity = ReverseConnectivity->getValue();
//const med_int * reverse_nodal_connectivity_index = ReverseConnectivity->getIndex();
- reverse_nodal_connectivity_index[0] = 1;
- for (med_int i = 1; i < _numberOfNodes+1; i++)
- {
- med_int size = reverse_connectivity[i].size();
- reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size;
- for (med_int j = 0; j < size; j++)
- reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j];
- }
+ reverse_nodal_connectivity_index[0] = 1;
+ for (med_int i = 1; i < _numberOfNodes+1; i++)
+ {
+ med_int size = reverse_connectivity[i].size();
+ reverse_nodal_connectivity_index[i] =
+ reverse_nodal_connectivity_index[i-1] + size;
+ for (med_int j = 0; j < size; j++)
+ reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j];
+ }
- //_reverseNodalConnectivity = ReverseConnectivity;
- _reverseNodalConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity,
- reverse_nodal_connectivity_index,
- reverse_nodal_connectivity);
+ //_reverseNodalConnectivity = ReverseConnectivity;
+ _reverseNodalConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity,
+ reverse_nodal_connectivity_index,
+ reverse_nodal_connectivity);
delete [] reverse_nodal_connectivity_index;
delete [] reverse_nodal_connectivity;
}
/*! If not yet done, calculate the Descending Connectivity */
//-------------------------------------------------//
void CONNECTIVITY::calculateDescendingConnectivity()
- //-------------------------------------------------//
+//-------------------------------------------------//
{
const char * LOC = "CONNECTIVITY::calculateDescendingConnectivity() : ";
BEGIN_OF(LOC);
for (int j=_count[i]; j<_count[i+1]; j++) // we loop on all cell of this type
for (int k=1; k<=NumberOfConstituentPerCell; k++)
{ // we loop on all sub cell of it
- if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0) {
- // it is a new sub cell !
- // TotalNumberOfSubCell++;
- // Which type ?
- if (Type.getConstituentType(1,k)==_constituent->_geometricTypes[0]){
- tmp_NumberOfConstituentsForeachType[0]++;
- TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[0];
- } else {
- tmp_NumberOfConstituentsForeachType[1]++;
- TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[1];
- }
- //we have maximum two types
+ if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0)
+ {
+ // it is a new sub cell !
+ // TotalNumberOfSubCell++;
+ // Which type ?
+ if (Type.getConstituentType(1,k)==_constituent->_geometricTypes[0])
+ {
+ tmp_NumberOfConstituentsForeachType[0]++;
+ TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[0];
+ }
+ else
+ {
+ tmp_NumberOfConstituentsForeachType[1]++;
+ TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[1];
+ }
+ //we have maximum two types
- descend_connectivity[descend_connectivity_index[j-1]+k-2]=TotalNumberOfSubCell;
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j;
- int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100;
-
- int * NodesLists = new int[NumberOfNodesPerConstituent];
- for (int l=0; l<NumberOfNodesPerConstituent; l++) {
- NodesLists[l]=_nodal->getIJ(j,Type.getNodeConstituent(1,k,l+1));
- ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l]=NodesLists[l];
- }
- // we use reverse_nodal_connectivity to find the other element which contain this sub cell
-
- // all elements which contains first node of sub cell :
- int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1];
- int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]];
- int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0;
-
- if (NumberOfCellsInList > 0)
- { // we could have no element !
- int * CellsList = new int[NumberOfCellsInList];
- for (int l=ReverseNodalConnectivityIndex_0; l<ReverseNodalConnectivityIndex_1; l++)
- CellsList[l-ReverseNodalConnectivityIndex_0]=ReverseNodalConnectivityValue[l-1];
-
- // foreach node in sub cell, we search elements which are in common
- // at the end, we must have only one !
-
- for (int l=1; l<NumberOfNodesPerConstituent; l++) {
- int NewNumberOfCellsInList = 0;
- int * NewCellsList = new int[NumberOfCellsInList];
- for (int l1=0; l1<NumberOfCellsInList; l1++)
- for (int l2=ReverseNodalConnectivityIndex[NodesLists[l]-1]; l2<ReverseNodalConnectivityIndex[NodesLists[l]]; l2++)
- {
- if (CellsList[l1]<ReverseNodalConnectivityValue[l2-1])
- // increasing order : CellsList[l1] are not in elements list of node l
- break;
- if ((CellsList[l1]==ReverseNodalConnectivityValue[l2-1])&(CellsList[l1]!=j)) {
- // we have found one
- NewCellsList[NewNumberOfCellsInList]=CellsList[l1];
- NewNumberOfCellsInList++;
- break;
- }
- }
- NumberOfCellsInList = NewNumberOfCellsInList;
+ descend_connectivity[descend_connectivity_index[j-1]+k-2]=
+ TotalNumberOfSubCell;
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j;
- delete [] CellsList;
- CellsList = NewCellsList;
- }
+ int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100;
- if (NumberOfCellsInList > 0) { // We have found some elements !
- int CellNumber = CellsList[0];
- //delete [] CellsList;
- if (NumberOfCellsInList>1)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<<NumberOfCellsInList<<") !"));
+ int * NodesLists = new int[NumberOfNodesPerConstituent];
+ for (int l=0; l<NumberOfNodesPerConstituent; l++)
+ {
+ NodesLists[l]=_nodal->getIJ(j,Type.getNodeConstituent(1,k,l+1));
+ ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l] =
+ NodesLists[l];
+ }
+ // we use reverse_nodal_connectivity to find the other element which contain this sub cell
+
+ // all elements which contains first node of sub cell :
+ int ReverseNodalConnectivityIndex_0 =
+ ReverseNodalConnectivityIndex[NodesLists[0]-1];
+ int ReverseNodalConnectivityIndex_1 =
+ ReverseNodalConnectivityIndex[NodesLists[0]];
+ int NumberOfCellsInList =
+ ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0;
+
+ if (NumberOfCellsInList > 0)
+ { // we could have no element !
+ int * CellsList = new int[NumberOfCellsInList];
+ for (int l=ReverseNodalConnectivityIndex_0;
+ l<ReverseNodalConnectivityIndex_1; l++)
+ CellsList[l-ReverseNodalConnectivityIndex_0]=
+ ReverseNodalConnectivityValue[l-1];
+
+ // foreach node in sub cell, we search elements which are in common
+ // at the end, we must have only one !
- if (NumberOfCellsInList==1)
+ for (int l=1; l<NumberOfNodesPerConstituent; l++)
{
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=CellNumber;
+ int NewNumberOfCellsInList = 0;
+ int * NewCellsList = new int[NumberOfCellsInList];
+ for (int l1=0; l1<NumberOfCellsInList; l1++)
+ for (int l2=ReverseNodalConnectivityIndex[NodesLists[l]-1];
+ l2<ReverseNodalConnectivityIndex[NodesLists[l]];
+ l2++)
+ {
+ if (CellsList[l1]<ReverseNodalConnectivityValue[l2-1])
+ // increasing order : CellsList[l1] are not in elements list of node l
+ break;
+ if ((CellsList[l1]==
+ ReverseNodalConnectivityValue[l2-1])&
+ (CellsList[l1]!=j))
+ {
+ // we have found one
+ NewCellsList[NewNumberOfCellsInList] =
+ CellsList[l1];
+ NewNumberOfCellsInList++;
+ break;
+ }
+ }
+ NumberOfCellsInList = NewNumberOfCellsInList;
+
+ delete [] CellsList;
+ CellsList = NewCellsList;
+ }
+
+ if (NumberOfCellsInList > 0)
+ { // We have found some elements !
+ if (NumberOfCellsInList>1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<<NumberOfCellsInList<<") !"));
+
+ int CellNumber = CellsList[0];
+
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1] =
+ CellNumber;
// we search sub cell number in this cell to not calculate it another time
// which type ?
//int sub_cell_count2 = Type2.get_entities_count(1);
//int nodes_cell_count2 = Type2.get_nodes_count();
bool find2 = false;
- for (int l=1; l<=Type2.getNumberOfConstituents(1);l++) { // on all sub cell
- int counter = 0;
- for (int m=1; m<=Type2.getConstituentType(1,l)%100; m++)
- for (int n=1; n<=Type.getConstituentType(1,k)%100; n++)
- {
- if (_nodal->getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1])
- counter++;
+ for (int l=1; l<=Type2.getNumberOfConstituents(1);l++)
+ { // on all sub cell
+ int counter = 0;
+ for (int m=1; m<=Type2.getConstituentType(1,l)%100;
+ m++)
+ for (int n=1; n<=Type.getConstituentType(1,k)%100;
+ n++)
+ {
+ if (_nodal->getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) ==
+ NodesLists[n-1])
+ counter++;
+ }
+ if (counter==Type.getConstituentType(1,k)%100)
+ {
+ descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=
+ -1*TotalNumberOfSubCell; // because, see it in other side !
+ find2 = true;
}
- if (counter==Type.getConstituentType(1,k)%100)
- {
- descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=-1*TotalNumberOfSubCell; // because, see it in other side !
- find2 = true;
- }
- if (find2)
- break;
- }
+ if (find2)
+ break;
+ }
if (!find2)
- MESSAGE(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ?
- }
- } else {
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0;
+ {
+ MESSAGE(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ?
+ }
+ }
+ else
+ {
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0;
+ }
+ delete [] CellsList;
}
- delete [] CellsList;
- }
-
- delete [] NodesLists;
- }
+
+ delete [] NodesLists;
+ }
}
}
// we adjust _constituent
int NumberOfConstituent=0;
int SizeOfConstituentNodal=0;
- for (int i=0;i<_constituent->_numberOfTypes; i++) {
- NumberOfConstituent += tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1;
- SizeOfConstituentNodal += (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes();
- }
+ for (int i=0;i<_constituent->_numberOfTypes; i++)
+ {
+ NumberOfConstituent +=
+ tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1;
+ SizeOfConstituentNodal +=
+ (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes();
+ }
// we built new _nodal attribute in _constituent
//MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal);
//const int *ConstituentNodalValue = ConstituentNodal->getValue();
reverseDescendingConnectivityIndex[0]=1;
// first constituent type
- for(int j=0; j<tmp_NumberOfConstituentsForeachType[0]; j++) {
- ConstituentNodalIndex[j+1]=ConstituentNodalConnectivityIndex[j+1];
- for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++){
- ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[k-1];
- }
- reverseDescendingConnectivityIndex[j+1]=reverseDescendingConnectivityIndex[j]+2;
- for(int k=reverseDescendingConnectivityIndex[j]; k<reverseDescendingConnectivityIndex[j+1]; k++){
- reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[k-1];
+ for(int j=0; j<tmp_NumberOfConstituentsForeachType[0]; j++)
+ {
+ ConstituentNodalIndex[j+1]=ConstituentNodalConnectivityIndex[j+1];
+ for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++)
+ {
+ ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[k-1];
+ }
+ reverseDescendingConnectivityIndex[j+1] =
+ reverseDescendingConnectivityIndex[j]+2;
+ for(int k=reverseDescendingConnectivityIndex[j];
+ k<reverseDescendingConnectivityIndex[j+1]; k++)
+ {
+ reverseDescendingConnectivityValue[k-1] =
+ ReverseDescendingConnectivityValue[k-1];
+ }
}
- }
// second type if any
- if (_constituent->_numberOfTypes==2) {
- int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1;
- int offset1=offset*_constituent->_type[0].getNumberOfNodes();
- int offset2=offset*2;
- int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes();
- for(int j=tmp_NumberOfConstituentsForeachType[0]; j<NumberOfConstituent; j++) {
- ConstituentNodalIndex[j+1]=ConstituentNodalIndex[j]+NumberOfNodesPerConstituent;
- for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++){
- ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[offset1+k-1];
- }
- reverseDescendingConnectivityIndex[j+1]=reverseDescendingConnectivityIndex[j]+2;
- for(int k=reverseDescendingConnectivityIndex[j]; k<reverseDescendingConnectivityIndex[j+1]; k++){
- reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[offset2+k-1];
- }
+ if (_constituent->_numberOfTypes==2)
+ {
+ int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1;
+ int offset1=offset*_constituent->_type[0].getNumberOfNodes();
+ int offset2=offset*2;
+ int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes();
+ for(int j=tmp_NumberOfConstituentsForeachType[0]; j<NumberOfConstituent; j++)
+ {
+ ConstituentNodalIndex[j+1]=
+ ConstituentNodalIndex[j]+NumberOfNodesPerConstituent;
+ for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++)
+ {
+ ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[offset1+k-1];
+ }
+ reverseDescendingConnectivityIndex[j+1] =
+ reverseDescendingConnectivityIndex[j]+2;
+ for(int k=reverseDescendingConnectivityIndex[j];
+ k<reverseDescendingConnectivityIndex[j+1]; k++)
+ {
+ reverseDescendingConnectivityValue[k-1] =
+ ReverseDescendingConnectivityValue[offset2+k-1];
+ }
+ }
+ _constituent->_count[2]=NumberOfConstituent+1;
+ // we correct _descending to adjust face number
+ for(int j=0;j<DescendingSize;j++)
+ {
+ if (descend_connectivity[j]>tmp_NumberOfConstituentsForeachType[0])
+ descend_connectivity[j]-=offset;
+ else if (descend_connectivity[j]<-tmp_NumberOfConstituentsForeachType[0])
+ descend_connectivity[j]+=offset;
+ }
}
- _constituent->_count[2]=NumberOfConstituent+1;
- // we correct _descending to adjust face number
- for(int j=0;j<DescendingSize;j++)
- if (descend_connectivity[j]>tmp_NumberOfConstituentsForeachType[0])
- descend_connectivity[j]-=offset;
- }
delete [] ConstituentNodalConnectivityIndex;
delete [] ConstituentNodalConnectivity;
delete [] ConstituentNodalIndex;
delete [] ConstituentNodalValue;
-
+
delete [] ReverseDescendingConnectivityValue;
}
END_OF(LOC);
class GROUP;
/*!
- This class deals with all type of connectivity ./n
+ This class deals with all type of connectivity .\n
it a recursive class.
*/
/* -------------------- */
private:
- /*! private method :/n
+ /*! private method :\n
does nothing if already exists, else
evaluates _nodal from _descending */
void calculateNodalConnectivity();
- /*! private method :/n
+ /*! private method :\n
does nothing if already exists, else
evaluates from _nodal */
void calculateReverseNodalConnectivity();
- /*! private method :/n
+ /*! private method :\n
does nothing if already exists, else
evaluates _descending from _nodal */
void calculateDescendingConnectivity();
- /*! private method :/n
+ /*! private method :\n
does nothing if already exists, else
evaluates from _descending */
// void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity);
const med_int* getReverseDescendingConnectivity ();
const med_int* getReverseDescendingConnectivityIndex ();
- /*! private method :/n
+ /*! private method :\n
does nothing if already exists, else
evaluates _neighbourhood from _descending */
void calculateNeighbourhood(CONNECTIVITY &myConnectivity);
inline void setNumberOfNodes(med_int NumberOfNodes);
+ inline med_int getEntityDimension() const;
+
inline void setEntityDimension(med_int EntityDimension);
inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const;
}
/*! Returns the number of different %medGeometryElement types
- existing in the specified entity. /n
+ existing in the specified entity. \n
Note : Not implemented for MED_ALL_ENTITIES. */
//-----------------------------------------------------------------------//
inline med_int CONNECTIVITY::getNumberOfTypes(medEntityMesh Entity) const
return _numberOfTypes;
else if (_constituent!=NULL)
return _constituent->getNumberOfTypes(Entity);
- else if (_constituent == NULL)
- {
- MESSAGE("CONNECTIVITY::getNumberOfTypes : _constituent == NULL");
- try
- {
- (const_cast <CONNECTIVITY *> (this))->calculateDescendingConnectivity();
- }
- catch (MEDEXCEPTION & ex)
- {
- return 0 ;
- }
-
- SCRUTE(_entityDimension);
-
- if (_entityDimension != 2 && _entityDimension != 3) return 0;
-
- try
- {
- _constituent->calculateConnectivity(MED_NODAL,Entity);
- }
- catch (MEDEXCEPTION & ex)
- {
- return 0 ;
- }
-
- return _constituent->getNumberOfTypes(Entity);
- }
+// else if (_constituent == NULL)
+// {
+// MESSAGE("CONNECTIVITY::getNumberOfTypes : _constituent == NULL");
+// try
+// {
+// (const_cast <CONNECTIVITY *> (this))->calculateDescendingConnectivity();
+// }
+// catch (MEDEXCEPTION & ex)
+// {
+// return 0 ;
+// }
+
+// SCRUTE(_entityDimension);
+
+// if (_entityDimension != 2 && _entityDimension != 3) return 0;
+
+// try
+// {
+// _constituent->calculateConnectivity(MED_NODAL,Entity);
+// }
+// catch (MEDEXCEPTION & ex)
+// {
+// return 0 ;
+// }
+
+// return _constituent->getNumberOfTypes(Entity);
+// }
else
return 0; // because it is the right information (no exception needed)!
}
throw MEDEXCEPTION("CONNECTIVITY::getGeometricTypes : Entity not defined !");
}
-/*! Returns an array containing the accumulated number of entities sorted by the geometric type./n
+/*! Returns an array containing the accumulated number of entities sorted by the geometric type.\n
- Exemple :/n
+ Exemple :\n
- In case of a CONNECTIVITY containing 3*MED_TRIA3 et 2*MED_QUAD4 : /n
- int * count = getGlobalNumberingIndex(MED_CELL)/n
- count[0] is always set to 1/n
- count[1] is set to 1+3=4/n
- count[2] is set to 4+2=6 = total number of cells + 1/n
+ In case of a CONNECTIVITY containing 3*MED_TRIA3 et 2*MED_QUAD4 : \n
+ int * count = getGlobalNumberingIndex(MED_CELL)\n
+ count[0] is always set to 1\n
+ count[1] is set to 1+3=4\n
+ count[2] is set to 4+2=6 = total number of cells + 1\n
- Note : Not implemented for MED_ALL_ENTITIES. /n
+ Note : Not implemented for MED_ALL_ENTITIES. \n
Note : The geometric type order is given by the typedef enum medGeometryElement.
*/
/*!
Returns an array containing CELLMODEL foreach element type present
-in connectivity for given medEntityMesh (similar as getGeometricTypes)./n
+in connectivity for given medEntityMesh (similar as getGeometricTypes).\n
Throw an execption if the given entity is not defined or if the array is not defined.
*/
//-----------------------------------------------------------------------------//
_entityDimension=EntityDimension;
}
+med_int CONNECTIVITY::getEntityDimension() const
+{
+ return _entityDimension;
+}
+
#endif /* CONNECTIVITY_HXX */
BEGIN_OF("Default Constructor COORDINATE");
}
-/*! This constructor allocate a MEDARRAY of SpaceDimension * NumberOfNodes./n
+/*! This constructor allocate a MEDARRAY of SpaceDimension * NumberOfNodes.\n
It will create empty array for optional data (nodeNumber..) */
//------------------------------------------------------------------------------//
COORDINATE::COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode):
BEGIN_OF("Constructor COORDINATE");
}
-/*! This constructor will COPY all data (it is a deep copy) included in m./n
+/*! This constructor will COPY all data (it is a deep copy) included in m.\n
But only the default storage mode of coordinates array
will be copied (not both storage representation modes even if they both
exist in original object) : for example only full_interlace mode */
/*! sets the attribute _coordinate with Coordinate */
//----------------------------------------------------------//
-void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate)
+void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate,bool shallowCopy)
//----------------------------------------------------------//
{
// const int numberOfNodes = (int) Coordinate->getLengthValue();
if ( Coordinate->get(mode) != NULL)
{
- MEDARRAY<double> pourAttribut(*Coordinate,false);
- _coordinate = pourAttribut;
- //_coordinate.set(mode,Coordinate->get(mode));
+ if(shallowCopy)
+ {
+ _coordinate.shallowCopy(*Coordinate);
+ }
+ else
+ {
+ MEDARRAY<double> pourAttribut(*Coordinate,false);
+ _coordinate = pourAttribut;
+ //_coordinate.set(mode,Coordinate->get(mode));
+ }
}
else
{
- throw MED_EXCEPTION ( LOCALIZED(STRING("setCoordinates(MEDARRAY<double>
- *Coordinate)") << "No Coordinate"));
+ throw MED_EXCEPTION ( LOCALIZED(STRING("setCoordinates(MEDARRAY<double> *Coordinate)") << "No Coordinate"));
}
}
return _coordinate.getColumn(Axis) ;
}
-/*! returns an array with names of coordinates. /n
- Example : /n
- - x,y,z /n
- - r,teta,phi /n
+/*! returns an array with names of coordinates. \n
+ Example : \n
+ - x,y,z \n
+ - r,teta,phi \n
- ... */
//--------------------------------------//
const string * COORDINATE::getCoordinatesNames() const
#include "MEDMEM_Array.hxx"
/*!
- This class contains coordinates of the nodes ./n
+ This class contains coordinates of the nodes .\n
It could also store useful optional information about nodes
- as node numbers and about axes as names or units. /n
+ as node numbers and about axes as names or units. \n
spaceDimension and numberOfNodes can be found in _coordinate object.
*/
/*! _coordinate is a MEDARRAY<double> object : \n
- - spaceDimension /n
- - numberOfNodes /n
- - default storage mode /n
- - Up to 4 "PointerOf" to an array of size spaceDimension*NumberOfNodes/n
+ - spaceDimension \n
+ - numberOfNodes \n
+ - default storage mode \n
+ - Up to 4 "PointerOf" to an array of size spaceDimension*NumberOfNodes\n
Storing the object (not a pointer to this object) is more convenient for memory
management.
COORDINATE(const COORDINATE & m);
virtual ~COORDINATE();
- void setCoordinates(MEDARRAY<double> *Coordinate);
+ void setCoordinates(MEDARRAY<double> *Coordinate,bool shallowCopy=false);
void setCoordinates(const medModeSwitch Mode, const double *Coordinate);
void setCoordinatesNames(const string * CoordinateName);
void setCoordinateName(const string CoordinateName, const int i);
--- /dev/null
+#include "MEDMEM_DriverFactory.hxx"
+
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_GibiMeshDriver.hxx"
+#include "MEDMEM_PorflowMeshDriver.hxx"
+#include "MEDMEM_VtkMeshDriver.hxx"
+
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_MedMedDriver.hxx"
+#include "MEDMEM_VtkMedDriver.hxx"
+
+//#include "MEDMEM_Field.hxx"
+
+#include "MEDMEM_Exception.hxx"
+//#include "MEDMEM_STRING.hxx"
+//#include "utilities.h"
+
+using namespace MEDMEM;
+
+GENDRIVER *DRIVERFACTORY::buildDriverForMesh(driverTypes driverType, const std::string & fileName, MESH *mesh,const string & driverName)
+{
+ GENDRIVER *ret;
+ switch(driverType)
+ {
+ case MED_DRIVER : {
+ MED_MESH_RDWR_DRIVER *retmed=new MED_MESH_RDWR_DRIVER(fileName,mesh);
+ retmed->setMeshName(driverName);
+ return retmed;
+ }
+
+ case GIBI_DRIVER : {
+ ret=new GIBI_MESH_RDWR_DRIVER(fileName,mesh);
+ return ret;
+ }
+
+ case PORFLOW_DRIVER : {
+ ret=new PORFLOW_MESH_RDWR_DRIVER(fileName,mesh);
+ return ret;
+ }
+
+ case VTK_DRIVER : {
+ ret=new VTK_MESH_DRIVER(fileName,mesh);
+ return ret;
+ }
+
+ case NO_DRIVER : {
+ throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed");
+ }
+ default:
+ throw MED_EXCEPTION ("other driver than MED_DRIVER GIBI_DRIVER PORFLOW_DRIVER and VT_DRIVER has been specified to the method which is not allowed");
+ }
+}
+
+GENDRIVER *DRIVERFACTORY::buildDriverForMed(driverTypes driverType, const std::string & fileName, MED *med)
+{
+ GENDRIVER *ret;
+ switch(driverType)
+ {
+ case MED_DRIVER : {
+ ret=new MED_MED_RDWR_DRIVER(fileName,med);
+ break ;
+ }
+
+ case VTK_DRIVER : {
+ ret=new VTK_MED_DRIVER(fileName,med);
+ break ;
+ }
+
+ case GIBI_DRIVER : {
+ throw MED_EXCEPTION ("GIBI_DRIVER has been specified to the method which is not allowed because there is no GIBI driver for the MED object");
+ break;
+ }
+
+ case PORFLOW_DRIVER : {
+ throw MED_EXCEPTION ("PORFLOW_DRIVER has been specified to the method which is not allowed because there is no PORFLOW driver for the MED object");
+ break;
+ }
+
+ case NO_DRIVER : {
+ throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed");
+ break;
+ }
+ default:
+ throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed");
+ }
+ return ret;
+}
+
--- /dev/null
+#ifndef DRIVERFACTORY_HXX
+#define DRIVERFACTORY_HXX
+
+#include "MEDMEM_GenDriver.hxx"
+#include <string>
+
+namespace MEDMEM {
+
+ class MESH;
+ template<class T> class FIELD;
+ class MED;
+
+ namespace DRIVERFACTORY {
+ GENDRIVER *buildDriverForMesh(driverTypes driverType, const std::string & fileName, MESH *mesh,const string & driverName);
+ template<class T>
+ GENDRIVER *buildDriverForField(driverTypes driverType, const std::string & fileName, FIELD<T> *field);
+ GENDRIVER *buildDriverForMed(driverTypes driverType, const std::string & fileName, MED *med);
+ }
+
+}
+
+#include "MEDMEM_VtkFieldDriver.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
+
+using namespace MEDMEM;
+
+template<class T>
+GENDRIVER *DRIVERFACTORY::buildDriverForField(driverTypes driverType, const std::string & fileName, FIELD<T> *field)
+{
+ GENDRIVER *ret;
+ switch(driverType)
+ {
+ case MED_DRIVER : {
+ ret=new MED_FIELD_RDWR_DRIVER<T>(fileName,field);
+ break;
+ }
+
+ case VTK_DRIVER : {
+ ret=new VTK_FIELD_DRIVER<T>(fileName,field);
+ break ;
+ }
+
+ case GIBI_DRIVER : {
+ throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
+ break;
+ }
+
+ case PORFLOW_DRIVER : {
+ throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
+ break;
+ }
+
+ case NO_DRIVER : {
+ throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
+ break;
+ }
+ default:
+ MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD");
+ }
+ return ret;
+}
+
+#endif
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_Group.hxx"
+#include <iomanip>
#include <algorithm>
using namespace MEDMEM;
#include "utilities.h"
namespace MED_FR {
-/*! This Class inherits from map. /n
- It is a constant map association int (which is a med_geometrie_element) and string. /n
+/*! This Class inherits from map. \n
+ It is a constant map association int (which is a med_geometrie_element) and string. \n
Operator [] returns the (string) name of the geometry of an element
- given by a med_geometrie_element value. /n
+ given by a med_geometrie_element value. \n
Such a static map is instancied and can be used in any code to have
the name of the geometry of an element : MED_FR:GEO_NAME
A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */
// ____________________________
-/*! This Class inherits from map. /n
- It is a constant map association int (which is a med_entite_maillage) and string. /n
+/*! This Class inherits from map. \n
+ It is a constant map association int (which is a med_entite_maillage) and string. \n
Operator[] returns the (string) name of the type of an entity given by
- a med_entite_maillage value. /n
+ a med_entite_maillage value. \n
Such a static map is instancied and can be used in any code to have
the name of the geometry of an element : MED_FR:ENT_NAME
A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */
// ____________________________
-/*! This Class inherits from map. /n
- It is a constant map association int (which is a med_entite_maillage) and a list. /n
+/*! This Class inherits from map. \n
+ It is a constant map association int (which is a med_entite_maillage) and a list. \n
Operator[] returns the list of all exisiting med_geometrie_element for
- a med_entite_maillage value. /n
+ a med_entite_maillage value. \n
Such a static map is instancied and can be used in any code to have
the name of the geometry of an element : MED_FR:MESH_ENTITIES
A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */
\internal
Function used to duplicate char *
*/
-const char* duplicate( const char *const str ) ;
-const char* duplicate( const char *const str )
+char* duplicate( const char *const str ) ;
+char* duplicate( const char *const str )
{
ASSERT(str!=NULL) ;
const size_t length = strlen( str ) ;
Function used to elaborate the text of the MEDEXCEPTION
*/
// --------------------------------------------------------------------------------------- //
-const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber )
+char *makeText( const char *text, const char *fileName, const unsigned int lineNumber )
// --------------------------------------------------------------------------------------- //
{
char *newText = 0 ;
if ( _text )
{
delete [] _text ;
- char *& txt = (char*)_text ;
- txt = 0 ;
+ _text = 0 ;
}
ASSERT(_text==NULL) ;
}
MEDEXCEPTION(void);
protected :
- const char* _text ;
+ char* _text ;
public :
MEDEXCEPTION(const char *text, const char *fileName=0,
/*!
- This class describe a family of elements on an entity./n
- It inherits from support. /n
+ This class describe a family of elements on an entity.\n
+ It inherits from support. \n
It contains a list of elements (by SUPPORT class inheritance)
- and a description of some attributs./n
+ and a description of some attributs.\n
All families on one entity represent a mesh partition for this entity.
int _identifier ;
/*!
\if developper
- Number of attribute of the family ./n
+ Number of attribute of the family .\n
Note that attributes are numbered from 1 to N.
\endif
*/
{
_groupName = GroupName ;
}
-/*! Returns the attribute _identifier./n
+/*! Returns the attribute _identifier.\n
Note that there is one identifier precisely for each family. */
//--------------------------------------
inline int FAMILY::getIdentifier() const
{
return _attributeIdentifier ;
}
-/*! Returns identifer of the Ith attribute of the family./n
+/*! Returns identifer of the Ith attribute of the family.\n
Note that they are numbered from 1 to N */
//----------------------------------------------------
inline int FAMILY::getAttributeIdentifier(int i) const
{
return _attributeValue ;
}
-/*! Returns value of the Ith attribute of the family./n
+/*! Returns value of the Ith attribute of the family.\n
Note that they are numbered from 1 to N */
//-----------------------------------------------
inline int FAMILY::getAttributeValue(int i) const
{
return _attributeDescription ;
}
-/*! Returns description of the Ith attribute of the family/n
+/*! Returns description of the Ith attribute of the family\n
Note that they are numbered from 1 to N */
//--------------------------------------------------------
inline string FAMILY::getAttributeDescription(int i) const
{
return _groupName ;
}
-/*! Returns the name of the Ith group the family belongs to./n
+/*! Returns the name of the Ith group the family belongs to.\n
Note that they are numbered from 1 to N*/
//---------------------------------------------
inline string FAMILY::getGroupName(int i) const
using namespace std;
#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
using namespace MEDMEM;
// ---------------------------------
// check-up, fill diagnosis if some incompatibility is found.
if(m._support != n._support)
- diagnosis+="They don't have the same support!";
+ {
+ if(!(*m._support==*n._support))
+ diagnosis+="They don't have the same support!";
+ }
else if(m._numberOfComponents != n._numberOfComponents)
- diagnosis+="They don't have the same number of components!";
+ diagnosis+="They don't have the same number of components!";
else if(m._numberOfValues != n._numberOfValues)
- diagnosis+="They don't have the same number of values!";
+ diagnosis+="They don't have the same number of values!";
else
- {
+ {
for(int i=0; i<m._numberOfComponents; i++)
{
// Not yet implemented
// diagnosis+="Components don't have the same types!";
// break;
// }
- if(m._MEDComponentsUnits[i] != n._MEDComponentsUnits[i])
+ if(m._MEDComponentsUnits[i] != n._MEDComponentsUnits[i])
{
- diagnosis+="Components don't have the same units!";
- break;
+ diagnosis+="Components don't have the same units!";
+ break;
}
}
- }
+ }
if(diagnosis.size()) // if fields are not compatible : complete diagnosis and throw exception
{
#include "MEDMEM_Unit.hxx"
#include "MEDMEM_Array.hxx"
#include "MEDMEM_GenDriver.hxx"
-
-#include "MEDMEM_MedFieldDriver.hxx"
-#include "MEDMEM_MedMedDriver.hxx"
-
-#include "MEDMEM_VtkFieldDriver.hxx"
-#include "MEDMEM_VtkMedDriver.hxx"
+#include "MEDMEM_DriverFactory.hxx"
using namespace MED_EN;
*/
namespace MEDMEM {
+
+ template<class T> class FIELD;
+
class FIELD_ // GENERIC POINTER TO a template <class T> class FIELD
{
protected:
/*!
\if developper
- Array of size _numberOfComponents. /n
- (constant, scalar, vector, tensor)/n
+ Array of size _numberOfComponents. \n
+ (constant, scalar, vector, tensor)\n
We could use an array of integer to store
- numbers of values: /n
- - 1 for scalar,/n
- - space dimension for vector,/n
- - space dimension square for tensor./n
+ numbers of values: \n
+ - 1 for scalar,\n
+ - space dimension for vector,\n
+ - space dimension square for tensor.\n
So numbers of values per entities would be
sum of _componentsTypes array.
*/
namespace MEDMEM {
+
+ template<class T2> class MED_FIELD_RDONLY_DRIVER;
+ template<class T2> class MED_FIELD_WRONLY_DRIVER;
+ template<class T2> class VTK_FIELD_DRIVER;
+
template <class T> class FIELD : public FIELD_
{
-
- // ------- Drivers Management Part
protected:
-
- //-----------------------//
- class INSTANCE
- //-----------------------//
- {
- public:
- virtual GENDRIVER * run(const string & fileName, FIELD<T> * ptrFIELD) const = 0 ;
- } ;
-
- //-------------------------------------------------------//
- template <class T2> class INSTANCE_DE : public INSTANCE
- //-------------------------------------------------------//
- {
- public :
- GENDRIVER * run(const string & fileName, FIELD<T> * ptrFIELD) const
- {
- return new T2(fileName,ptrFIELD);
- }
- } ;
-
- // static INSTANCE_DE<MED_FIELD_RDONLY_DRIVER> inst_med_rdonly ;
- static INSTANCE_DE<MED_FIELD_RDWR_DRIVER<T> > inst_med ;
- static INSTANCE_DE<VTK_FIELD_DRIVER<T> > inst_vtk ;
-
- static const INSTANCE * const instances[] ;
-
// ------ End of Drivers Management Part
// array of value of type T
friend class MED_FIELD_RDONLY_DRIVER<T>;
friend class MED_FIELD_WRONLY_DRIVER<T>;
-
friend class VTK_FIELD_DRIVER<T>;
//friend class MED_FIELD_RDWR_DRIVER <T>;
inline void setValue(MEDARRAY<T> *Value);
inline MEDARRAY<T>* getvalue() const;
+ inline int getValueLength(medModeSwitch Mode) const;
inline const T* getValue(medModeSwitch Mode) const;
inline const T* getValueI(medModeSwitch Mode,int i) const;
inline T getValueIJ(int i,int j) const;
/*!
Overload addition operator.
This operation is authorized only for compatible fields that have the same support.
- The compatibility checking includes equality tests of the folowing data members:/n
+ The compatibility checking includes equality tests of the folowing data members:\n
- _support
- _numberOfComponents
- _numberOfValues
The data members of the returned field are initialized, based on the first field, except for the name,
which is the combination of the two field's names and the operator.
- Advised Utilisation in C++ : <tt> FIELD<T> c = a + b; </tt> /n
+ Advised Utilisation in C++ : <tt> FIELD<T> c = a + b; </tt> \n
In this case, the (recent) compilators perform optimisation and don't call the copy constructor.
When using python, this operator calls the copy constructor in any case.
The user has to be aware that when using operator + in associatives expressions like
- <tt> a = b + c + d +e; </tt> /n
+ <tt> a = b + c + d +e; </tt> \n
no optimisation is performed : the evaluation of last expression requires the construction of
3 temporary fields.
*/
/*!
Overload substraction operator.
This operation is authorized only for compatible fields that have the same support.
- The compatibility checking includes equality tests of the folowing data members:/n
+ The compatibility checking includes equality tests of the folowing data members:\n
- _support
- _numberOfComponents
- _numberOfValues
The data members of the returned field are initialized, based on the first field, except for the name,
which is the combination of the two field's names and the operator.
- Advised Utilisation in C++ : <tt> FIELD<T> c = a - b; </tt> /n
+ Advised Utilisation in C++ : <tt> FIELD<T> c = a - b; </tt> \n
In this case, the (recent) compilators perform optimisation and don't call the copy constructor.
When using python, this operator calls the copy constructor in any case.
The user has to be aware that when using operator - in associatives expressions like
- <tt> a = b - c - d -e; </tt> /n
+ <tt> a = b - c - d -e; </tt> \n
no optimisation is performed : the evaluation of last expression requires the construction of
3 temporary fields.
*/
/*!
Overload multiplication operator.
This operation is authorized only for compatible fields that have the same support.
- The compatibility checking includes equality tests of the folowing data members:/n
+ The compatibility checking includes equality tests of the folowing data members:\n
- _support
- _numberOfComponents
- _numberOfValues
The data members of the returned field are initialized, based on the first field, except for the name,
which is the combination of the two field's names and the operator.
- Advised Utilisation in C++ : <tt> FIELD<T> c = a * b; </tt> /n
+ Advised Utilisation in C++ : <tt> FIELD<T> c = a * b; </tt> \n
In this case, the (recent) compilators perform optimisation and don't call the copy constructor.
When using python, this operator calls the copy constructor in any case.
The user has to be aware that when using operator * in associatives expressions like
- <tt> a = b * c * d *e; </tt> /n
+ <tt> a = b * c * d *e; </tt> \n
no optimisation is performed : the evaluation of last expression requires the construction of
3 temporary fields.
*/
/*!
Overload division operator.
This operation is authorized only for compatible fields that have the same support.
- The compatibility checking includes equality tests of the folowing data members:/n
+ The compatibility checking includes equality tests of the folowing data members:\n
- _support
- _numberOfComponents
- _numberOfValues
The data members of the returned field are initialized, based on the first field, except for the name,
which is the combination of the two field's names and the operator.
- Advised Utilisation in C++ : <tt> FIELD<T> c = a / b; </tt> /n
+ Advised Utilisation in C++ : <tt> FIELD<T> c = a / b; </tt> \n
In this case, the (recent) compilators perform optimisation and don't call the copy constructor.
When using python, this operator calls the copy constructor in any case.
The user has to be aware that when using operator / in associatives expressions like
- <tt> a = b / c / d /e; </tt> /n
+ <tt> a = b / c / d /e; </tt> \n
no optimisation is performed : the evaluation of last expression requires the construction of
3 temporary fields.
*/
/*!
* Return a pointer to a new field that holds the scalar product. Static member function.
* This operation is authorized only for compatible fields that have the same support.
- * The compatibility checking includes equality tests of the folowing data members:/n
+ * The compatibility checking includes equality tests of the folowing data members:\n
* - _support
* - _numberOfComponents
* - _numberOfValues
// Methodes Inline
// -----------------
-
-template <class T> FIELD<T>::INSTANCE_DE<MED_FIELD_RDWR_DRIVER<T> > FIELD<T>::inst_med ;
-
-template <class T> FIELD<T>::INSTANCE_DE<VTK_FIELD_DRIVER<T> > FIELD<T>::inst_vtk ;
-
-template <class T> const typename FIELD<T>::INSTANCE * const FIELD<T>::instances[] = { &FIELD<T>::inst_med, &FIELD<T>::inst_vtk} ;
-
-
/*!
Create the specified driver and return its index reference to path to
read or write methods.
const char * LOC = "FIELD<T>::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name\") : ";
GENDRIVER * driver;
- int current;
- int itDriver = (int) NO_DRIVER;
BEGIN_OF(LOC);
SCRUTE(driverType);
- SCRUTE(instances[driverType]);
-
- switch(driverType)
- {
- case MED_DRIVER : {
- itDriver = (int) driverType ;
- break ;
- }
-
- case VTK_DRIVER : {
- itDriver = 1 ;
- break ;
- }
-
- case GIBI_DRIVER : {
- throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"));
- break;
- }
-
- case NO_DRIVER : {
- throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"));
- break;
- }
- }
-
- if (itDriver == ((int) NO_DRIVER))
- throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"));
-
- driver = instances[itDriver]->run(fileName, this) ;
+ driver = DRIVERFACTORY::buildDriverForField(driverType,fileName,this);
_drivers.push_back(driver);
- current = _drivers.size()-1;
+ int current = _drivers.size()-1;
_drivers[current]->setFieldName(driverName);
return _value ;
}
+/*!
+ Return the actual length of the reference to values array returned by getValue.
+*/
+template <class T> inline int FIELD<T>::getValueLength(medModeSwitch Mode) const{
+ return _numberOfComponents*_numberOfValues;
+}
+
/*!
Return a reference to values array to read them.
*/
if (nb_indices != nb_objets)
{
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName
- << "Erreur de lecture dans enregistrement de type " << ENREG_TYPE_2
- << " (pile " << PILE_NOEUDS << ")" ));
+ << "Erreur de lecture dans enregistrement de type " << (int)ENREG_TYPE_2
+ << " (pile " << (int)PILE_NOEUDS << ")" ));
}
place_noeuds.resize(nb_objets);
// PROVISOIRE : certains fichier gibi n'ont
if (nb_reels < numero_noeuds.size()*(space_dimension))
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName
- << "Erreur de lecture dans enregistrement de type " << ENREG_TYPE_2
- << " (pile " << PILE_COORDONNEES << ")" ));
+ << "Erreur de lecture dans enregistrement de type " << (int)ENREG_TYPE_2
+ << " (pile " << (int)PILE_COORDONNEES << ")" ));
for (unsigned i=0; i!=numero_noeuds.size(); ++i)
{
SCRUTE(numberOfFamilies);
- if ((numberOfFamilies==1)&(isOnAllElts))
+ if ((numberOfFamilies==1) || (isOnAllElts))
{
_numberOfFamilies = numberOfFamilies;
_isOnAllElts = isOnAllElts ;
/*!
- This class describe a group of elements on an entity./n
- It inherits from SUPPORT./n
- It is a blending of some FAMILY class./n/n
+ This class describe a group of elements on an entity.\n
+ It inherits from SUPPORT.\n
+ It is a blending of some FAMILY class.\n\n
*/
# include <string>
# include "MEDMEM_Med.hxx"
-
+# include "MEDMEM_DriverFactory.hxx"
# include "MEDMEM_STRING.hxx"
# include "MEDMEM_Mesh.hxx"
MESSAGE(LOC << "driverType = " << driverType);
- MED_MED_RDONLY_DRIVER * myDriver = new MED_MED_RDONLY_DRIVER(fileName,this) ;
- int current = addDriver(*myDriver);
- //int current= addDriver(driverType,fileName);
+ int current = addDriver(driverType,fileName);
_drivers[current]->open();
_drivers[current]->readFileStruct();
END_OF(LOC);
} ;
-// ------- Drivers Management Part
-
-// Add your new driver instance declaration here (step 3-1)
-MED::INSTANCE_DE<MED_MED_RDWR_DRIVER> MED::inst_med ;
-MED::INSTANCE_DE<VTK_MED_DRIVER> MED::inst_vtk ;
-
-// Add your new driver instance in the MED instance list (step 3-2)
-const MED::INSTANCE * const MED::instances[] = { &MED::inst_med, &MED::inst_vtk };
/*!
Create the specified driver and return its index reference to path to
int MED::addDriver(driverTypes driverType, const string & fileName="Default File Name.med") {
const char * LOC = "MED::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\") : ";
- GENDRIVER * driver;
- int current;
- int itDriver = (int) NO_DRIVER;
BEGIN_OF(LOC);
SCRUTE(driverType);
- SCRUTE(instances[driverType]);
-
- switch(driverType)
- {
- case MED_DRIVER : {
- itDriver = (int) driverType ;
- break ;
- }
-
- case VTK_DRIVER : {
- itDriver = 1 ;
- break ;
- }
-
- case GIBI_DRIVER : {
- throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "GIBI_DRIVER has been specified to the method which is not allowed because there is no GIBI driver for the MED object"));
- break;
- }
-
- case NO_DRIVER : {
- throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "NO_DRIVER has been specified to the method which is not allowed"));
- break;
- }
- }
+ GENDRIVER *driver = DRIVERFACTORY::buildDriverForMed(driverType,fileName,this);
- if (itDriver == ((int) NO_DRIVER))
- throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "NO_DRIVER has been specified to the method which is not allowed"));
+ _drivers.push_back(driver);
- driver = instances[itDriver]->run(fileName, this) ;
-
- current = _drivers.size()-1;
+ int current = _drivers.size()-1;
driver->setId(current);
current = _drivers.size()-1;
SCRUTE(current);
driver.setId(current);
-
-
- MESSAGE(LOC << " je suis la 1");
END_OF(LOC);
- MESSAGE(LOC << " je suis la 2");
return current;
}
// LOCAL
# include "MEDMEM_define.hxx"
-
-// Add your own driver header (step 2)
-# include "MEDMEM_MedMedDriver.hxx"
-# include "MEDMEM_VtkMedDriver.hxx"
-
# include "MEDMEM_Exception.hxx"
+# include "MEDMEM_GenDriver.hxx"
+
using namespace MED_EN;
void addField ( FIELD_ * const ptrField ) throw (MED_EXCEPTION) ;
void addMesh ( MESH * const ptrMesh ) throw (MED_EXCEPTION) ;
-
- // ------ Drivers Management Part
-protected:
-
- class INSTANCE {
- public:
- virtual GENDRIVER * run(const string & fileName, MED * const ptrMed) const = 0 ;
- } ;
-
- template <class T> class INSTANCE_DE : public INSTANCE {
- public :
- GENDRIVER * run(const string & fileName, MED * const ptrMed) const
- {
- MESSAGE("GENDRIVER * run") ;
- return new T(fileName,ptrMed) ;
- }
- } ;
-
- // Add your new driver instance here (step 3)
- static INSTANCE_DE<MED_MED_RDWR_DRIVER> inst_med ;
- static INSTANCE_DE<VTK_MED_DRIVER> inst_vtk ;
- static const INSTANCE * const instances[] ;
-
-public:
-
int addDriver (driverTypes driverType, const string & fileName);
int addDriver (GENDRIVER & driver);
void rmDriver (int index=0) throw (MEDEXCEPTION) ;
const char * LOC = " MED_FIELD_RDONLY_DRIVER::read() " ;
BEGIN_OF(LOC);
- if (_ptrField->_name=="")
- _ptrField->_name = _fieldName ;
+ if (MED_FIELD_DRIVER<T>::_ptrField->_name=="")
+ MED_FIELD_DRIVER<T>::_ptrField->_name = MED_FIELD_DRIVER<T>::_fieldName ;
else
- _fieldName = _ptrField->_name; // bug indetermine ! apres avoir fait readfilestruct, lorsque je recupere le champ, tout est bon sauf le nom du champ dans le driver !!!!!
+ MED_FIELD_DRIVER<T>::_fieldName = MED_FIELD_DRIVER<T>::_ptrField->_name; // bug indetermine ! apres avoir fait readfilestruct, lorsque je recupere le champ, tout est bon sauf le nom du champ dans le driver !!!!!
- MESSAGE("###### "<<LOC<<" fieldNameDRIVER : "<<_fieldName<<" fieldName : "<<_ptrField->_name);
+ MESSAGE("###### "<<LOC<<" fieldNameDRIVER : "<<MED_FIELD_DRIVER<T>::_fieldName<<" fieldName : "<<MED_FIELD_DRIVER<T>::_ptrField->_name);
- string MeshName = _ptrField->getSupport()->getMesh()->getName() ;
+ string MeshName = MED_FIELD_DRIVER<T>::_ptrField->getSupport()->getMesh()->getName() ;
- if (_status==MED_OPENED)
+ if (MED_FIELD_DRIVER<T>::_status==MED_OPENED)
{
// search_field() ;
MED_FR::med_type_champ type ;
// we search the field number !!!!
- if (_fieldNum==MED_INVALID) {
+ if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID) {
int numberOfFields = 0; //MED_INVALID
- numberOfFields = MED_FR::MEDnChamp(_medIdt,0) ;
+ numberOfFields = MED_FR::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,0) ;
if ( numberOfFields <= 0 )
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !"));
for (int i=1;i<=numberOfFields;i++) {
- numberOfComponents = MED_FR::MEDnChamp(_medIdt,i) ;
+ numberOfComponents = MED_FR::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,i) ;
if ( numberOfComponents <= 0 )
// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
// << "Be careful there is no compound for field n°"
componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
- err = MED_FR::MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
+ err = MED_FR::MEDchampInfo(MED_FIELD_DRIVER<T>::_medIdt, i, fieldName, &type, componentName,
unitName, numberOfComponents) ;
- MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<_fieldName.c_str()<<"#");
- if ( !strcmp(fieldName,_fieldName.c_str()) ) {
+ MESSAGE("Champ "<<i<<" : #" << fieldName <<"# et recherche #"<<MED_FIELD_DRIVER<T>::_fieldName.c_str()<<"#");
+ if ( !strcmp(fieldName,MED_FIELD_DRIVER<T>::_fieldName.c_str()) ) {
MESSAGE("FOUND FIELD "<< fieldName <<" : "<<i);
- _fieldNum = i ;
+ MED_FIELD_DRIVER<T>::_fieldNum = i ;
break ;
}
// not found : release memory and search next field !
delete[] fieldName ;
- if (_fieldNum==MED_INVALID)
- throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<<_fieldName << " not found in file " << _fileName ) );
- MESSAGE ("FieldNum : "<<_fieldNum);
+ if (MED_FIELD_DRIVER<T>::_fieldNum==MED_INVALID)
+ throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<<MED_FIELD_DRIVER<T>::_fieldName << " not found in file " << MED_FIELD_DRIVER<T>::_fileName ) );
+ MESSAGE ("FieldNum : "<<MED_FIELD_DRIVER<T>::_fieldNum);
// int err ;
- // int NumberOfComponents = MED_FR::MEDnChamp(_medIdt,_fieldNum) ;
+ // int NumberOfComponents = MED_FR::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,MED_FIELD_DRIVER<T>::_fieldNum) ;
if (numberOfComponents < 1)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no component")) ; // use iostring !
// test type to check if it is rigth !!!???
- _ptrField->_numberOfComponents = numberOfComponents ;
- _ptrField->_componentsTypes = new int[numberOfComponents] ;
- _ptrField->_componentsNames = new string[numberOfComponents] ;
- _ptrField->_componentsUnits = new UNIT[numberOfComponents] ;
- _ptrField->_componentsDescriptions = new string[numberOfComponents] ;
- _ptrField->_MEDComponentsUnits = new string[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_numberOfComponents = numberOfComponents ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes = new int[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsNames = new string[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits = new UNIT[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions = new string[numberOfComponents] ;
+ MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits = new string[numberOfComponents] ;
for (int i=0; i<numberOfComponents; i++) {
- _ptrField->_componentsTypes[i] = 1 ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes[i] = 1 ;
// PG : what about space !!!
- _ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
- SCRUTE(_ptrField->_componentsNames[i]);
- _ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
- SCRUTE(_ptrField->_MEDComponentsUnits[i]);
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
+ SCRUTE(MED_FIELD_DRIVER<T>::_ptrField->_componentsNames[i]);
+ MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
+ SCRUTE(MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits[i]);
}
delete[] componentName;
delete[] unitName;
// read values for each geometric type in _support
- int NumberOfTypes = _ptrField->_support->getNumberOfTypes() ;
- const medGeometryElement *Types = _ptrField->_support->getTypes() ;
- T ** myValues = new (T*)[NumberOfTypes] ;
+ int NumberOfTypes = MED_FIELD_DRIVER<T>::_ptrField->_support->getNumberOfTypes() ;
+ const medGeometryElement *Types = MED_FIELD_DRIVER<T>::_ptrField->_support->getTypes() ;
+ T ** myValues = new T*[NumberOfTypes] ;
int * NumberOfValues = new int[NumberOfTypes] ;
int TotalNumberOfValues = 0 ;
MESSAGE ("NumberOfTypes :"<< NumberOfTypes);
+ _ptrField->_numberOfValues=0 ;
for (int i=0; i<NumberOfTypes; i++) {
MESSAGE ("Type["<<i+1<<"] :"<< Types[i]);
- MESSAGE ("Entity :"<<_ptrField->_support->getEntity());
+ MESSAGE ("Entity :"<<MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity());
NumberOfValues[i] =
- MEDnVal(_medIdt,
- const_cast <char*> (_fieldName.c_str()),
- (MED_FR::med_entite_maillage)_ptrField->_support->getEntity(),
+ MEDnVal(MED_FIELD_DRIVER<T>::_medIdt,
+ const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
+ (MED_FR::med_entite_maillage)MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity(),
(MED_FR::med_geometrie_element)Types[i],
- _ptrField->_iterationNumber,
- _ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss
+ MED_FIELD_DRIVER<T>::_ptrField->_iterationNumber,
+ MED_FIELD_DRIVER<T>::_ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss
// test if NumberOfValues is the same in _support !!! TODO that !!
// we suppose it is
// we could allocate array
MESSAGE ("NumberOfValues :"<< NumberOfValues[i]);
MESSAGE ("NumberOfComponents :"<< numberOfComponents);
MESSAGE ("MESH_NAME :"<< MeshName.c_str());
- MESSAGE ("FIELD_NAME :"<< _fieldName.c_str());
- MESSAGE ("MED_ENTITE :"<< (MED_FR::med_entite_maillage) _ptrField->_support->getEntity());
+ MESSAGE ("FIELD_NAME :"<< MED_FIELD_DRIVER<T>::_fieldName.c_str());
+ MESSAGE ("MED_ENTITE :"<< (MED_FR::med_entite_maillage) MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity());
MESSAGE("MED_GEOM :"<<(MED_FR::med_geometrie_element)Types[i]);
- MESSAGE("Iteration :"<<_ptrField->getIterationNumber());
- MESSAGE("Order :"<<_ptrField->getOrderNumber());
- _ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
- if ( MED_FR::MEDchampLire(_medIdt,const_cast <char*> (MeshName.c_str()),
- const_cast <char*> (_fieldName.c_str()),
+ MESSAGE("Iteration :"<<MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber());
+ MESSAGE("Order :"<<MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber());
+ MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
+ if ( MED_FR::MEDchampLire(MED_FIELD_DRIVER<T>::_medIdt,const_cast <char*> (MeshName.c_str()),
+ const_cast <char*> (MED_FIELD_DRIVER<T>::_fieldName.c_str()),
(unsigned char*) myValues[i],
MED_FR::MED_NO_INTERLACE,
MED_ALL,
ProfilName,
- (MED_FR::med_entite_maillage) _ptrField->_support->getEntity(),(MED_FR::med_geometrie_element)Types[i],
- _ptrField->getIterationNumber(),
- _ptrField->getOrderNumber()
+ (MED_FR::med_entite_maillage) MED_FIELD_DRIVER<T>::_ptrField->_support->getEntity(),(MED_FR::med_geometrie_element)Types[i],
+ MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
+ MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
) < 0) {
// we must do some delete !!!
for(int j=0; j<=i;j++)
delete[] myValues;
delete[] NumberOfValues ;
delete[] ProfilName;
- delete[] _ptrField->_componentsTypes ;
- delete[] _ptrField->_componentsNames ;
- delete[] _ptrField->_componentsUnits ;
- delete[] _ptrField->_componentsDescriptions ;
- delete[] _ptrField->_MEDComponentsUnits ;
- _ptrField->_componentsTypes = NULL ;
- _ptrField->_componentsNames = NULL ;
- _ptrField->_componentsUnits = NULL ;
- _ptrField->_componentsDescriptions = NULL ;
- _ptrField->_MEDComponentsUnits = NULL ;
- _fieldNum = MED_INVALID ; // we have not found right field, so reset the field number
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsNames ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions ;
+ delete[] MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsTypes = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsNames = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsUnits = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_componentsDescriptions = NULL ;
+ MED_FIELD_DRIVER<T>::_ptrField->_MEDComponentsUnits = NULL ;
+ MED_FIELD_DRIVER<T>::_fieldNum = MED_INVALID ; // we have not found right field, so reset the field number
throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ;
}
}
// allocate _value
// probleme avec les points de gauss : voir lorsqu-il y en a (!= 1)
- // MEDARRAY<T> * Values = new MEDARRAY<T>(_ptrField->getNumberOfComponents(),TotalNumberOfValues/_ptrField->getNumberOfComponents(),MED_EN::MED_NO_INTERLACE);
+ // MEDARRAY<T> * Values = new MEDARRAY<T>(MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents(),TotalNumberOfValues/MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents(),MED_EN::MED_NO_INTERLACE);
- if (_ptrField->_value==NULL)
- _ptrField->_value=new MEDARRAY<T>(numberOfComponents,TotalNumberOfValues,MED_EN::MED_NO_INTERLACE);
+ if (MED_FIELD_DRIVER<T>::_ptrField->_value==NULL)
+ MED_FIELD_DRIVER<T>::_ptrField->_value=new MEDARRAY<T>(numberOfComponents,TotalNumberOfValues,MED_EN::MED_NO_INTERLACE);
- MEDARRAY<T> * Values = _ptrField->_value ; // create by constructor ???
+ MEDARRAY<T> * Values = MED_FIELD_DRIVER<T>::_ptrField->_value ; // create by constructor ???
// check if dimensions are right : inutile : c'est dans le constructeur !!!
//if (Values->getLeadingValue() != numberOfComponents)
// throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<<Values->getLeadingValue()<<" and "<<numberOfComponents) ) ;
for (int j=0; j<NumberOfTypes; j++) {
T * myValue = myValues[j] ;
int NumberOf = NumberOfValues[j] ;
-// _ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
+// MED_FIELD_DRIVER<T>::_ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
int offset = NumberOf*i ;
for (int k=0 ; k<NumberOf; k++) {
//ValuesT[Count]=myValue[k+offset] ;
delete[] myValues ;
delete[] NumberOfValues ;
- _ptrField->_isRead = true ;
+ MED_FIELD_DRIVER<T>::_ptrField->_isRead = true ;
}
END_OF(LOC);
{
const char * LOC = "MED_FIELD_WRONLY_DRIVER::write(void) const " ;
BEGIN_OF(LOC);
- if (_status==MED_OPENED)
+ if (MED_FIELD_DRIVER<T>::_status==MED_OPENED)
{
int err ;
- int component_count=_ptrField->getNumberOfComponents();
+ int component_count=MED_FIELD_DRIVER<T>::_ptrField->getNumberOfComponents();
string component_name(component_count*MED_TAILLE_PNOM,' ') ;
string component_unit(component_count*MED_TAILLE_PNOM,' ') ;
- const string * listcomponent_name=_ptrField->getComponentsNames() ;
- const string * listcomponent_unit=_ptrField->getMEDComponentsUnits() ;
+ const string * listcomponent_name=MED_FIELD_DRIVER<T>::_ptrField->getComponentsNames() ;
+ const string * listcomponent_unit=MED_FIELD_DRIVER<T>::_ptrField->getMEDComponentsUnits() ;
int length ;
for (int i=0; i < component_count ; i++) {
length = min(MED_TAILLE_PNOM,(int)listcomponent_name[i].size());
MESSAGE("component_name=|"<<component_name<<"|");
MESSAGE("component_unit=|"<<component_unit<<"|");
- MED_EN::med_type_champ ValueType=_ptrField->getValueType() ;
+ MED_EN::med_type_champ ValueType=MED_FIELD_DRIVER<T>::_ptrField->getValueType() ;
MESSAGE("Template Type =|"<<ValueType<<"|");
char * compName ;
char * compUnit ;
bool Find = false ;
- int n = MED_FR::MEDnChamp(_medIdt,0);
+ int n = MED_FR::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,0);
int nbComp ;
for (int i=1; i<=n; i++) {
- nbComp = MED_FR::MEDnChamp(_medIdt,i);
+ nbComp = MED_FR::MEDnChamp(MED_FIELD_DRIVER<T>::_medIdt,i);
compName = new char[MED_TAILLE_PNOM*nbComp+1];
compUnit = new char[MED_TAILLE_PNOM*nbComp+1];
- err = MED_FR::MEDchampInfo(_medIdt,i,champName,&type,compName,compUnit,nbComp);
+ err = MED_FR::MEDchampInfo(MED_FIELD_DRIVER<T>::_medIdt,i,champName,&type,compName,compUnit,nbComp);
if (err == 0)
- if (strcmp(champName,_ptrField->getName().c_str())==0) { // Found !
+ if (strcmp(champName,MED_FIELD_DRIVER<T>::_ptrField->getName().c_str())==0) { // Found !
Find = true ;
break ;
}
// Verify the field doesn't exist
string dataGroupName = "/CHA/";
- dataGroupName += _ptrField->getName();
+ dataGroupName += MED_FIELD_DRIVER<T>::_ptrField->getName();
MESSAGE(LOC << "|" << dataGroupName << "|" );
- med_idt gid = H5Gopen(_medIdt, dataGroupName.c_str() );
+ med_idt gid = H5Gopen(MED_FIELD_DRIVER<T>::_medIdt, dataGroupName.c_str() );
if ( gid < 0 ) {
// create field :
- err=MED_FR::MEDchampCr(_medIdt,
- const_cast <char*> ((_ptrField->getName()).c_str()),
+ err=MED_FR::MEDchampCr(MED_FIELD_DRIVER<T>::_medIdt,
+ const_cast <char*> ((MED_FIELD_DRIVER<T>::_ptrField->getName()).c_str()),
(MED_FR::med_type_champ) ValueType,
const_cast <char*> ( component_name.c_str() ),
const_cast <char*> ( component_unit.c_str() ),
else H5Gclose(gid);
}
- const SUPPORT * mySupport = _ptrField->getSupport() ;
+ const SUPPORT * mySupport = MED_FIELD_DRIVER<T>::_ptrField->getSupport() ;
if (! mySupport->isOnAllElements())
throw MEDEXCEPTION( LOCALIZED (STRING(LOC)
MESH * myMesh = mySupport->getMesh() ;
string MeshName = myMesh->getName() ;
- //MED_EN::medModeSwitch Mode = _ptrField->_value->getMode() ;
+ //MED_EN::medModeSwitch Mode = MED_FIELD_DRIVER<T>::_ptrField->_value->getMode() ;
// on boucle sur tout les types pour ecrire les tableaux de valeur
int NumberOfType = mySupport->getNumberOfTypes() ;
int Index = 1 ;
for (int i=0;i<NumberOfType;i++) {
int NumberOfElements = mySupport->getNumberOfElements(Types[i]) ;
- const T * value = _ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
+ const T * value = MED_FIELD_DRIVER<T>::_ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
- MESSAGE("_medIdt : "<<_medIdt);
+ MESSAGE("MED_FIELD_DRIVER<T>::_medIdt : "<<MED_FIELD_DRIVER<T>::_medIdt);
MESSAGE("MeshName.c_str() : "<<MeshName.c_str());
- MESSAGE("_ptrField->getName() : "<<_ptrField->getName());
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getName() : "<<MED_FIELD_DRIVER<T>::_ptrField->getName());
MESSAGE("value : "<<value);
MESSAGE("NumberOfElements : "<<NumberOfElements);
MESSAGE("NumberOfGaussPoint[i] : "<<NumberOfGaussPoint[i]);
MESSAGE("mySupport->getEntity() : "<<mySupport->getEntity());
MESSAGE("Types[i] : "<<Types[i]);
- MESSAGE("_ptrField->getIterationNumber() : "<<_ptrField->getIterationNumber());
- MESSAGE("_ptrField->getTime() : "<<_ptrField->getTime());
- MESSAGE("_ptrField->getOrderNumber() : "<<_ptrField->getOrderNumber());
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber() : "<<MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber());
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getTime() : "<<MED_FIELD_DRIVER<T>::_ptrField->getTime());
+ MESSAGE("MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber() : "<<MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber());
/* char chanom[MED_TAILLE_NOM+1];
char chacomp[MED_TAILLE_NOM+1];
MED_FR::med_type_champ chatype;
med_int chancomp=1;
- err=MED_FR::MEDchampInfo(_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp);
+ err=MED_FR::MEDchampInfo(MED_FIELD_DRIVER<T>::_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp);
if (err<0)
{
cout<<"==================> valeur de MED_FR::MED_REEL64 = "<<MED_FR::MED_REEL64<<endl;
*/
- err=MED_FR::MEDchampEcr(_medIdt,
+ err=MED_FR::MEDchampEcr(MED_FIELD_DRIVER<T>::_medIdt,
const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
- const_cast <char*> ( (_ptrField->getName()).c_str()),
+ const_cast <char*> ( (MED_FIELD_DRIVER<T>::_ptrField->getName()).c_str()),
(unsigned char*)value,
MED_FR::MED_FULL_INTERLACE,
NumberOfElements,
MED_FR::MED_REMP, // PROFIL NON GERE, mode de remplacement non géré
(MED_FR::med_entite_maillage)mySupport->getEntity(),
(MED_FR::med_geometrie_element)Types[i],
- _ptrField->getIterationNumber(),
+ MED_FIELD_DRIVER<T>::_ptrField->getIterationNumber(),
" ",
- _ptrField->getTime(),
- _ptrField->getOrderNumber()
+ MED_FIELD_DRIVER<T>::_ptrField->getTime(),
+ MED_FIELD_DRIVER<T>::_ptrField->getOrderNumber()
);
if (err < MED_VALID )
throw MEDEXCEPTION(LOCALIZED( STRING(LOC)
- <<": Error in writing Field "<< _ptrField->getName() <<", type "<<Types[i]
+ <<": Error in writing Field "<< MED_FIELD_DRIVER<T>::_ptrField->getName() <<", type "<<Types[i]
)
);
# include <string>
# include "MEDMEM_MedMedDriver.hxx"
-
+# include "MEDMEM_MedMeshDriver.hxx"
# include "MEDMEM_DriversDef.hxx"
# include "MEDMEM_Mesh.hxx"
// if neither nodal nor descending connectivity exists
// throw an exception.
err = getNodalConnectivity(Connectivity) ;
- if (err!=MED_VALID) {
- Connectivity->_typeConnectivity = MED_DESCENDING ;
- err = getDescendingConnectivity(Connectivity) ;
- } else
+ if (err!=MED_VALID)
+ {
+ Connectivity->_typeConnectivity = MED_DESCENDING ;
+ err = getDescendingConnectivity(Connectivity) ;
+ }
+ else
getDescendingConnectivity(Connectivity) ; // we read it if there is one
- if (err!=MED_VALID) {
- delete Connectivity ;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read any Connectivity")) ;
- }
+ if (err!=MED_VALID)
+ {
+ delete Connectivity ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " <<
+ "any Connectivity")) ;
+ }
_ptrMesh->_meshDimension = Connectivity->_entityDimension ;
// PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!!
- if(Connectivity->_constituent==NULL) {
-
- SCRUTE(_ptrMesh->_meshDimension);
- if (_ptrMesh->_meshDimension == 3) {
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
- CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
- ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ; // NODAL or DESCENDING
- SCRUTE(ConnectivityFace->_typeConnectivity);
- if (Connectivity->_typeConnectivity == MED_DESCENDING) {
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
- err = getDescendingConnectivity(ConnectivityFace) ;
- if (err!=MED_VALID)
- throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No FACE in descending connectivity")) ;
- getNodalConnectivity(ConnectivityFace) ; // if any !
- } else {
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
- err = getNodalConnectivity(ConnectivityFace) ;
- if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
- err = getDescendingConnectivity(ConnectivityFace) ;
- } else
- getDescendingConnectivity(ConnectivityFace); // if any !
- }
- if (err!=MED_VALID) {
- delete ConnectivityFace ;
- MESSAGE(LOC<<"No FACE defined.") ;
- } else {
- MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES FACES DANS L'OBJET CONNECTIVITY" );
- Connectivity->_constituent=ConnectivityFace ;
- }
- }
+ if(Connectivity->_constituent==NULL)
+ {
+ SCRUTE(_ptrMesh->_meshDimension);
+ if (_ptrMesh->_meshDimension == 3)
+ {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
+ CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
+ ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ;
+ // NODAL or DESCENDING
+ SCRUTE(ConnectivityFace->_typeConnectivity);
+ if (Connectivity->_typeConnectivity == MED_DESCENDING)
+ {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
+ err = getDescendingConnectivity(ConnectivityFace) ;
+ if (err!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<
+ "No FACE in descending connectivity")) ;
+ getNodalConnectivity(ConnectivityFace) ; // if any !
+ }
+ else
+ {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
+ err = getNodalConnectivity(ConnectivityFace) ;
+ if (err!=MED_VALID)
+ { // or error ????? we are in NODAL mode.
+ err = getDescendingConnectivity(ConnectivityFace) ;
+ }
+ else
+ getDescendingConnectivity(ConnectivityFace); // if any !
+ }
+
+ if (err!=MED_VALID)
+ {
+ delete ConnectivityFace ;
+ MESSAGE(LOC<<"No FACE defined.") ;
+ }
+ else
+ {
+ MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES " <<
+ "FACES DANS L'OBJET CONNECTIVITY" );
+ Connectivity->_constituent=ConnectivityFace ;
+ }
+ }
- // read MED_EDGE connectivity
- if (_ptrMesh->_meshDimension > 1) { // we are in 3 or 2D
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
- CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
- ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
- if (Connectivity->_typeConnectivity == MED_DESCENDING) {
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES ARRETES" );
- err = getDescendingConnectivity(ConnectivityEdge) ;
- if (err!=MED_VALID)
- throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No EDGE in descending connectivity")) ;
- getNodalConnectivity(ConnectivityEdge) ; // if any !
- } else {
- MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
- err = getNodalConnectivity(ConnectivityEdge) ;
- if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
- err = getDescendingConnectivity(ConnectivityEdge) ;
- } else
- getDescendingConnectivity(ConnectivityEdge) ; // if any !
+ // read MED_EDGE connectivity
+ if (_ptrMesh->_meshDimension > 1)
+ { // we are in 3 or 2D
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
+ CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
+ ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
+ if (Connectivity->_typeConnectivity == MED_DESCENDING)
+ {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE " <<
+ "DES ARRETES" );
+ err = getDescendingConnectivity(ConnectivityEdge) ;
+ if (err!=MED_VALID)
+ throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) <<
+ "No EDGE in descending connectivity")) ;
+ getNodalConnectivity(ConnectivityEdge) ; // if any !
+ }
+ else
+ {
+ MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
+ err = getNodalConnectivity(ConnectivityEdge) ;
+ if (err!=MED_VALID)
+ { // or error ????? we are in NODAL mode.
+ err = getDescendingConnectivity(ConnectivityEdge) ;
+ }
+ else
+ getDescendingConnectivity(ConnectivityEdge) ; // if any !
+ }
+
+ if (err!=MED_VALID)
+ {
+ delete ConnectivityEdge ;
+ MESSAGE(LOC<<"No EDGE defined.") ;
+ }
+ else
+ {
+ if (_ptrMesh->_meshDimension == 3)
+ if (Connectivity->_constituent != NULL)
+ Connectivity->_constituent->_constituent=ConnectivityEdge ;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
+ else
+ { // IN 2D
+ MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES " <<
+ "ARETES DANS L'OBJET CONNECTIVITY" );
+ Connectivity->_constituent=ConnectivityEdge ;
+ }
+ }
+ }
}
- if (err!=MED_VALID) {
- delete ConnectivityEdge ;
- MESSAGE(LOC<<"No EDGE defined.") ;
- } else {
- if (_ptrMesh->_meshDimension == 3)
- if (Connectivity->_constituent != NULL)
- Connectivity->_constituent->_constituent=ConnectivityEdge ;
- else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
- else { // IN 2D
- MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES ARETES DANS L'OBJET CONNECTIVITY" );
- Connectivity->_constituent=ConnectivityEdge ;
- }
- }
- }
- }
_ptrMesh->_connectivity = Connectivity ;
// all right !
{
const char * LOC = "MED_MESH_RDONLY_DRIVER::getNodalConnectivity : " ;
BEGIN_OF(LOC);
+
+ int spaceDimension = _ptrMesh->_spaceDimension;
+
if (_status==MED_OPENED)
{
// Get the type of entity to work on (previously set in the Connectivity Object)
// Get the number of cells of each type & store it in <tmp_cells_count>.
int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
int i;
- for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) { // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
- tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
- MED_FR::MED_CONN,(MED_FR::med_entite_maillage) Entity,
- all_cell_type[i],MED_FR::MED_NOD);
-
-
- // Get the greatest dimension of the cells : Connectivity->_entityDimension
- // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
- // In version prior to 2.2.x, it is possible
- if (tmp_cells_count[i]>0) {
- Connectivity->_entityDimension=all_cell_type[i]/100;
- Connectivity->_numberOfTypes++;
+ for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+ { // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
+
+ tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
+ MED_FR::MED_CONN,(MED_FR::med_entite_maillage) Entity,
+ all_cell_type[i],MED_FR::MED_NOD);
+
+ // Get the greatest dimension of the cells : Connectivity->_entityDimension
+ // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
+ // In version prior to 2.2.x, it is possible
+ if (tmp_cells_count[i]>0)
+ {
+ Connectivity->_entityDimension=all_cell_type[i]/100;
+ Connectivity->_numberOfTypes++;
+ }
}
- }
// If there is no nodal connectivity, we quit !
- if ( Connectivity->_numberOfTypes == 0 ) {
- delete[] tmp_cells_count ;
- return MED_ERROR ;
- }
+ if ( Connectivity->_numberOfTypes == 0 )
+ {
+ delete[] tmp_cells_count ;
+ return MED_ERROR ;
+ }
// if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge !
char version_med[10] ;
- if ( MEDfichEntete(_medIdt,MED_FR::MED_VERSION,version_med) != 0 ){
- // error : we suppose we have not a good med file !
- delete[] tmp_cells_count ;
- return MED_ERROR ;
- }
+ if ( MEDfichEntete(_medIdt,MED_FR::MED_VERSION,version_med) != 0 )
+ {
+ // error : we suppose we have not a good med file !
+ delete[] tmp_cells_count ;
+ return MED_ERROR ;
+ }
// we get MED version number
// If MED version is < 2.2 then the cells which dimension
tmpFaceCount[0] = 0 ;
int numberOfFacesTypes = 0;
- if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE)) {
+// if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE))
+// {
+// Connectivity->_numberOfTypes=0;
- Connectivity->_numberOfTypes=0;
+// for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+// {
+// tmpFaceCount[i]=0;
+// tmpEdgeCount[i]=0;
+// if (tmp_cells_count[i]!=0)
+// {
+// int dimension = all_cell_type[i]/100 ;
+// if (Connectivity->_entityDimension==dimension)
+// Connectivity->_numberOfTypes++ ;
+
+// if (dimension == 2)
+// if (Connectivity->_entityDimension==3)
+// {
+// tmpFaceCount[i]=tmp_cells_count[i] ;
+// tmp_cells_count[i]=0 ;
+// numberOfFacesTypes++;
+// }
+// if (dimension == 1)
+// if (Connectivity->_entityDimension>dimension)
+// {
+// tmpEdgeCount[i]=tmp_cells_count[i] ;
+// tmp_cells_count[i]=0;
+// numberOfEdgesTypes++ ;
+// }
+// }
+// }
+// }
+
+ if (Entity==MED_FR::MED_MAILLE)
+ {
+ Connectivity->_numberOfTypes=0;
- for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) {
- tmpFaceCount[i]=0;
- tmpEdgeCount[i]=0;
- if (tmp_cells_count[i]!=0) {
- int dimension = all_cell_type[i]/100 ;
- if (Connectivity->_entityDimension==dimension)
- Connectivity->_numberOfTypes++ ;
+ for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+ {
+ tmpFaceCount[i]=0;
+ tmpEdgeCount[i]=0;
+ if (tmp_cells_count[i]!=0)
+ {
+ int dimension = all_cell_type[i]/100 ;
+ if (Connectivity->_entityDimension==dimension)
+ Connectivity->_numberOfTypes++ ;
- if (dimension == 2)
- if (Connectivity->_entityDimension==3) {
- tmpFaceCount[i]=tmp_cells_count[i] ;
- tmp_cells_count[i]=0 ;
- numberOfFacesTypes++;
- }
- if (dimension == 1)
- if (Connectivity->_entityDimension>dimension) {
- tmpEdgeCount[i]=tmp_cells_count[i] ;
- tmp_cells_count[i]=0;
- numberOfEdgesTypes++ ;
- }
- }
+ if (dimension == 2)
+ if (Connectivity->_entityDimension==3)
+ {
+ tmpFaceCount[i]=tmp_cells_count[i] ;
+ //tmp_cells_count[i]=0 ;
+ //Connectivity->_numberOfTypes++ ;
+ numberOfFacesTypes++;
+ }
+ if (dimension == 1)
+ if (Connectivity->_entityDimension>dimension)
+ {
+ tmpEdgeCount[i]=tmp_cells_count[i] ;
+ //tmp_cells_count[i]=0;
+ //Connectivity->_numberOfTypes++ ;
+ numberOfEdgesTypes++ ;
+ }
+ }
+ }
}
- }
// bloc to read CELL :
{
- // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
- // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
+ // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
+ // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes] ; // Double emploi pour des raisons pratiques
Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes] ; //
Connectivity->_count = new int [Connectivity->_numberOfTypes+1] ;
int size = 0 ;
int typeNumber=1 ;
int i;
- for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) { // no point1 cell type (?)
- if (tmp_cells_count[i]>0) {
- Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
+ for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+ { // no point1 cell type (?)
+ int dimension = all_cell_type[i]/100 ;
+ if ((tmp_cells_count[i]>0) && (Connectivity->_entityDimension == dimension))
+ {
+ Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
- CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
- Connectivity->_type[typeNumber-1]=t ;
+ CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
+
+ Connectivity->_type[typeNumber-1] = t ;
- Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
+ Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
- // probleme avec les mailles de dimension < a dimension du maillage :
- // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
+ // probleme avec les mailles de dimension < a dimension du maillage :
+ // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
- size+=tmp_cells_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
+ size+=tmp_cells_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
- MESSAGE(LOC
- << Connectivity->_count[typeNumber]-1 << " cells of type "
- << all_cell_type_tab[i] );
- typeNumber++;
+ MESSAGE(LOC
+ << Connectivity->_count[typeNumber]-1 << " cells of type "
+ << all_cell_type_tab[i] );
+
+ typeNumber++;
+ }
}
- }
// Creation of the MEDSKYLINEARRAY
//Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
// Fill the MEDSKYLINEARRAY by reading the MED file.
int j=0;
- for ( i=0;i<Connectivity->_numberOfTypes;i++) {
- int multi = 0 ;
- MED_FR::med_geometrie_element med_type = (MED_FR::med_geometrie_element) Connectivity->_type[i].getType() ;
-// if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension)
- if (Connectivity->_entity == MED_CELL)
- if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension)
- multi=1;
+ for ( i=0;i<Connectivity->_numberOfTypes;i++)
+ {
+ int multi = 0 ;
+ MED_FR::med_geometrie_element med_type = (MED_FR::med_geometrie_element) Connectivity->_type[i].getType() ;
+ //if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension)
+ if (Connectivity->_entity == MED_CELL)
+ if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension)
+ multi=1;
- // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
- int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
+ // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
+ int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
- // initialise index
- for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
- NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ;
+ // initialise index
+ for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
+ NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ;
- int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
- int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
+ int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
+ int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
-// int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
-// Connectivity->_entityDimension,tmp_ConnectivityArray,
-// MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
- int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- _ptrMesh->_spaceDimension,tmp_ConnectivityArray,
- MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
-
- if ( err != MED_VALID) {
- delete[] tmp_ConnectivityArray;
- delete[] tmp_cells_count;
- delete[] tmpFaceCount;
- delete[] tmpEdgeCount;
- MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
- return MED_ERROR ;
- }
+ //int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ // Connectivity->_entityDimension,tmp_ConnectivityArray,
+ //MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
+
+ int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,tmp_ConnectivityArray,
+ MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,
+ MED_FR::MED_NOD);
+
+ if ( err != MED_VALID)
+ {
+ delete[] tmp_ConnectivityArray;
+ delete[] tmp_cells_count;
+ delete[] tmpFaceCount;
+ delete[] tmpEdgeCount;
+ MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
+ return MED_ERROR ;
+ }
- int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
+ int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
- // version originale sans prise en compte des numéros optionnels
- //
- for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
- ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
+ // version originale sans prise en compte des numéros optionnels
+ //
+ for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
+ ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
- //////////////////////////////////////////////////////////////////////////////////////
- /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
- //////////////////////////////////////////////////////////////////////////////////////
- ///
- /// Rénumérote le tableau temporaire tmp_ConnectivityArray en utilisant _optionnalToCanonicNodesNumbers
- /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
-
-// if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
-// {
-// for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
-// ConnectivityArray[j*NumberOfNodeByCell+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ;
-// }
-// else
-// {
-// for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
-// ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
-// }
-
- //////////////////////////////////////////////////////////////////////////////////////
-
+ //////////////////////////////////////////////////////////////////////////////
+ // Modification pour prise en compte de la numérotation optionnelle des noeuds ///
+ //////////////////////////////////////////////////////////////////////////////
+ //
+ // Rénumérote le tableau temporaire tmp_ConnectivityArray en utilisant _optionnalToCanonicNodesNumbers
+ // Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
+
+ // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
+ // {
+ // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
+ // ConnectivityArray[j*NumberOfNodeByCell+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ;
+ // }
+ // else
+ // {
+ // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
+ // ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
+ // }
+ ////////////////////////////////////////////////////////////////////////////
- delete[] tmp_ConnectivityArray;
-
- }
+ delete[] tmp_ConnectivityArray;
+ }
Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,
size,
NodalIndex,
NodalValue) ;
+
delete[] NodalIndex;
delete[] NodalValue;
-
} // end of bloc to read CELL
delete[] tmp_cells_count;
tmp_constituentArray = new int[NumberOfNodeByFace*tmp_numberOfFaces] ;
MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
}
+
int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
Connectivity->_entityDimension,tmp_constituentArray,
MED_FR::MED_FULL_INTERLACE,NULL,0,MED_FR::MED_MAILLE,med_type,MED_FR::MED_NOD);
MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
- MEDArrayCellFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_CELL)] ; // ET SI IL N'Y A PAS DE CELLS ?
+ MEDArrayCellFamily = new int*[_ptrMesh->getNumberOfTypes(MED_CELL)] ; // ET SI IL N'Y A PAS DE CELLS ?
const medGeometryElement * myTypes = _ptrMesh->getTypes(MED_CELL);
for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
MEDArrayCellFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_CELL,myTypes[i])] ;
if (_ptrMesh->_connectivity->_constituent != NULL) {
if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE) {
// FACE
- MEDArrayFaceFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_FACE)] ;
+ MEDArrayFaceFamily = new int*[_ptrMesh->getNumberOfTypes(MED_FACE)] ;
myTypes = _ptrMesh->getTypes(MED_FACE);
for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
MEDArrayFaceFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_FACE,myTypes[i])] ;
} else {
// EDGE in 2D
- MEDArrayEdgeFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
+ MEDArrayEdgeFamily = new int*[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
myTypes = _ptrMesh->getTypes(MED_EDGE);
for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ;
}
// EDGE in 3D
if (_ptrMesh->_connectivity->_constituent->_constituent != NULL) {
- MEDArrayEdgeFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
+ MEDArrayEdgeFamily = new int*[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
myTypes = _ptrMesh->getTypes(MED_EDGE);
for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ;
err = MEDfamLire(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
MEDArrayNodeFamily,
_ptrMesh->getNumberOfNodes(),
- MED_FR::MED_NOEUD,(enum MED_FR::med_geometrie_element) MED_NONE);
+ MED_FR::MED_NOEUD,(MED_FR::med_geometrie_element) MED_NONE);
if ( err != MED_VALID) {
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes()
<< "| nodes in mesh |"
err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
MEDArrayNodeFamily, NumberOfNodes,MED_FR::MED_REMP ,
MED_FR::MED_NOEUD,
- (enum MED_FR::med_geometrie_element) MED_NONE);
+ (MED_FR::med_geometrie_element) MED_NONE);
else
err = MEDfamGridEcr(_medIdt,
const_cast <char *> (_ptrMesh->_name.c_str()),
#include <list>
#include <map>
+#include <sstream>
#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Field.hxx"
#include "MEDMEM_Coordinate.hxx"
#include "MEDMEM_Connectivity.hxx"
#include "MEDMEM_CellModel.hxx"
+
+#include "MEDMEM_DriverFactory.hxx"
+
using namespace MEDMEM;
//#include "MEDMEM_Grid.hxx" this inclision should have never be here !!!
// ------- Drivers Management Part
-// MESH::INSTANCE_DE<MED_MESH_RDONLY_DRIVER> MESH::inst_med_rdonly ;
-//const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med_rdonly , &MESH::inst_med_rdwr } ;
-
-// Add a similar line for your personnal driver (step 3)
-
-MESH::INSTANCE_DE<MED_MESH_RDWR_DRIVER> MESH::inst_med ;
-MESH::INSTANCE_DE<GIBI_MESH_RDWR_DRIVER> MESH::inst_gibi ;
-MESH::INSTANCE_DE<PORFLOW_MESH_RDWR_DRIVER> MESH::inst_porflow ;
-MESH::INSTANCE_DE<VTK_MESH_DRIVER> MESH::inst_vtk;
-
-// Add your own driver in the driver list (step 4)
-// Note the list must be coherent with the driver type list defined in MEDMEM_DRIVER.hxx.
-const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med, &MESH::inst_gibi, &MESH::inst_porflow, &MESH::inst_vtk } ;
-
/*! Add a %MESH driver of type %driverTypes (MED_DRIVER, ....) associated with file fileName. The meshname used in the file
is driverName. addDriver returns an integer handler. */
int MESH::addDriver(driverTypes driverType,
const char * LOC = "MESH::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Mesh Name\") : ";
GENDRIVER * driver;
- int current;
- int itDriver = (int) NO_DRIVER;
BEGIN_OF(LOC);
SCRUTE(driverType);
- SCRUTE(instances[driverType]);
-
- switch(driverType)
- {
- case MED_DRIVER : {
- itDriver = (int) driverType ;
- break ;
- }
-
- case GIBI_DRIVER : {
- itDriver = (int) driverType ;
- break ;
- }
-
- case PORFLOW_DRIVER : {
- itDriver = (int) driverType ;
- break ;
- }
-
- case VTK_DRIVER : {
- itDriver = 3 ;
- break ;
- }
-
- case NO_DRIVER : {
- throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "NO_DRIVER has been specified to the method which is not allowed"));
- }
- }
-
- if (itDriver == ((int) NO_DRIVER))
- throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "othe driver than MED_DRIVER GIBI_DRIVER PORFLOW_DRIVER and VT_DRIVER has been specified to the method which is not allowed"));
-
- driver = instances[itDriver]->run(fileName, this) ;
+ driver = DRIVERFACTORY::buildDriverForMesh(driverType,fileName,this,driverName) ;
_drivers.push_back(driver);
- current = _drivers.size()-1;
+ int current = _drivers.size()-1;
_drivers[current]->setMeshName(driverName);
BEGIN_OF(LOC);
init();
-
- switch(driverType)
- {
- case MED_DRIVER :
- {
- MED_MESH_RDONLY_DRIVER myDriver(fileName,this);
- myDriver.setMeshName(driverName);
- current = addDriver(myDriver);
- break;
- }
- case GIBI_DRIVER :
- {
- GIBI_MESH_RDONLY_DRIVER myDriver(fileName,this);
- current = addDriver(myDriver);
- break;
- }
- case PORFLOW_DRIVER :
- {
- PORFLOW_MESH_RDONLY_DRIVER myDriver(fileName,this);
- current = addDriver(myDriver);
- break;
- }
- default :
- {
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Driver type unknown : can't create driver!"));
- break;
- }
- }
-
-// current = addDriver(driverType,fileName,driverName);
-// switch(_drivers[current]->getAccessMode() ) {
-// case MED_WRONLY : {
-// MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must not be a MED_WRONLY accessMode");
-// rmDriver(current);
-// break;}
-// default : {
-// }
-// }
+ GENDRIVER *myDriver=DRIVERFACTORY::buildDriverForMesh(driverType,fileName,this,driverName);
+ current = addDriver(*myDriver);
+ delete myDriver;
_drivers[current]->open();
_drivers[current]->read();
_drivers[current]->close();
//#include "MEDMEM_Support.hxx"
#include "MEDMEM_Coordinate.hxx"
#include "MEDMEM_Connectivity.hxx"
-
-// Add your own driver header (step 2)
-#include "MEDMEM_MedMeshDriver.hxx"
-#include "MEDMEM_MedMedDriver.hxx"
-#include "MEDMEM_GibiMeshDriver.hxx"
-#include "MEDMEM_PorflowMeshDriver.hxx"
-
-#include "MEDMEM_VtkMeshDriver.hxx"
-
-
-
-//class GENDRIVER;
-//class MED_MESH_RDONLY_DRIVER;
-//class MED_MESH_WRONLY_DRIVER;
+#include "MEDMEM_GenDriver.hxx"
using namespace MED_EN;
class MESH
{
-
-
-public :
-
- // ------- Drivers Management Part
-protected:
-
- //-----------------------//
- class INSTANCE
- //-----------------------//
- {
- public:
- virtual GENDRIVER * run(const string & fileName, MESH * ptrMesh) const = 0;
- };
-
- //-------------------------------------------------------//
- template <class T> class INSTANCE_DE : public INSTANCE
- //-------------------------------------------------------//
- {
- public :
- GENDRIVER * run(const string & fileName, MESH * ptrMesh) const
- { return new T(fileName,ptrMesh); }
- };
-
- // Add a similar line for your personnal driver (step 3)
-
- static INSTANCE_DE<MED_MESH_RDWR_DRIVER> inst_med;
- static INSTANCE_DE<GIBI_MESH_RDWR_DRIVER> inst_gibi;
- static INSTANCE_DE<PORFLOW_MESH_RDWR_DRIVER> inst_porflow;
- static INSTANCE_DE<VTK_MESH_DRIVER> inst_vtk;
-
- //static INSTANCE_DE<VTK_DRIVER> inst_vtk ;
- static const INSTANCE * const instances[];
-
- // ------ End of Drivers Management Part
-
-
//-----------------------//
// Attributes
//-----------------------//
void rmDriver(int index=0);
virtual void read(int index=0);
- inline void read(const MED_MED_DRIVER & genDriver);
+ inline void read(const GENDRIVER & genDriver);
inline void write(int index=0, const string & driverName = "");
- inline void write(const MED_MED_DRIVER & genDriver);
+ inline void write(const GENDRIVER & genDriver);
// void calculateReverseConnectivity();
// void createFaces(); //Faces creation => full constituent informations
virtual inline void calculateConnectivity(medModeSwitch Mode,
medConnectivity ConnectivityType,
medEntityMesh Entity) const ;
+ virtual inline int getConnectivityLength(medModeSwitch Mode,
+ medConnectivity ConnectivityType,
+ medEntityMesh Entity,
+ medGeometryElement Type) const;
virtual inline const int * getConnectivity(medModeSwitch Mode,
medConnectivity ConnectivityType,
medEntityMesh Entity,
medEntityMesh Entity,
medGeometryElement Type,
int * connectivity) const;
-
+ virtual inline int getReverseConnectivityLength(medConnectivity ConnectivityType,
+ medEntityMesh Entity=MED_CELL) const;
virtual inline const int * getReverseConnectivity(medConnectivity ConnectivityType,
medEntityMesh Entity=MED_CELL) const;
+ virtual inline int getReverseConnectivityIndexLength(medConnectivity ConnectivityType,
+ medEntityMesh Entity=MED_CELL) const;
virtual inline const int * getReverseConnectivityIndex(medConnectivity ConnectivityType,
medEntityMesh Entity=MED_CELL) const;
// This method is MED specific : don't use it
// must be private.
-inline void MESH::write(const MED_MED_DRIVER & genDriver)
+inline void MESH::write(const GENDRIVER & genDriver)
{
const char * LOC = "MESH::write(const MED_MED_DRIVER & genDriver): ";
BEGIN_OF(LOC);
// This method is MED specific : don't use it
// must be private.
-inline void MESH::read(const MED_MED_DRIVER & genDriver)
+inline void MESH::read(const GENDRIVER & genDriver)
{
const char * LOC = "MESH::read(const MED_MED_DRIVER & genDriver): ";
BEGIN_OF(LOC);
else
throw MEDEXCEPTION(LOCALIZED("MESH::calculateConnectivity : only for MED_FULL_INTERLACE mode"));
}
+/*!
+ Return the corresponding length of the array returned by MESH::getConnectivity with exactly the same arguments.
+ Used particulary for wrapping CORBA and python.
+ */
+inline int MESH::getConnectivityLength(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type) const
+{
+ int nbOfElm = getNumberOfElements(entity,Type);
+ int size;
+
+ if (Type == MED_ALL_ELEMENTS)
+ {
+ size = getConnectivityIndex(ConnectivityType,entity)[nbOfElm]-1;
+ }
+ else
+ {
+ size = nbOfElm*(((int) Type)%100);
+ }
+ return size;
+}
/*!
Return the required connectivity in the right mode for the given
geometric type of the given entity.
// checkGridFillConnectivity();
return _connectivity->getConnectivityIndex(ConnectivityType, entity);
}
+/*!
+ Return the corresponding length of the array returned by MESH::getReverseConnectivity with exactly the same arguments.
+ Used particulary for wrapping CORBA and python.
+ */
+
+inline int MESH::getReverseConnectivityLength(medConnectivity ConnectivityType,
+ medEntityMesh Entity) const
+{
+ int spaceDim = getSpaceDimension();
+ int nb;
+
+ if (ConnectivityType == MED_NODAL)
+ {
+ nb = getNumberOfNodes();
+ }
+ else
+ {
+ if (spaceDim == 2)
+ nb = getNumberOfElements(MED_EDGE,
+ MED_ALL_ELEMENTS);
+ else if (spaceDim == 3)
+ nb = getNumberOfElements(MED_FACE,
+ MED_ALL_ELEMENTS);
+ }
+ return getReverseConnectivityIndex(ConnectivityType)[nb]-1;
+}
/*!
Return the reverse connectivity required by ConnectivityType :
- If ConnectivityType=MED_NODAL : return connectivity node-cell
You must get ReverseConnectivityIndex array to use it.
*/
+
inline const int * MESH::getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
{
// checkGridFillConnectivity();
return _connectivity->getReverseConnectivity(ConnectivityType,Entity);
}
+/*!
+ Return the corresponding length of the array returned by MESH::getReverseConnectivityIndex with exactly the same arguments.
+ Used particulary for wrapping CORBA and python.
+ */
+inline int MESH::getReverseConnectivityIndexLength(medConnectivity ConnectivityType,
+ medEntityMesh Entity) const
+{
+ int spaceDim = getSpaceDimension();
+
+ if (ConnectivityType == MED_NODAL)
+ {
+ return getNumberOfNodes()+1;
+ }
+ else
+ {
+ if (spaceDim == 2)
+ return getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS)+1;
+ else if (spaceDim == 3)
+ return getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)+1;
+ else
+ throw MEDEXCEPTION("Invalid dimension");
+ }
+}
/*!
Return the index array required by ConnectivityType.
void set( const int &size ) ;
void set( const T *pointer ) ;
void set( const int &size, const T *pointer ) ;
+ void setShallowAndOwnership( const T *pointer );
PointerOf<T>& operator=( const PointerOf<T> &pointer ) ;
} ;
} ;
}
/*! If size <= 0, creates a null "T*" pointer\n
- Else allocates memory and sets desallocation boolean to true./n
+ Else allocates memory and sets desallocation boolean to true.\n
Memory will be desallocated when erasing this PointerOf*/
template <typename T> PointerOf<T>::PointerOf( const int &size )
{
}
}
-/*! Creates a standard pointer to the memory zone pointed by T*. /n
- T* owner is in charged of memory desallocation. /n
+/*! Creates a standard pointer to the memory zone pointed by T*. \n
+ T* owner is in charged of memory desallocation. \n
Memory will not be released when erasing this PointerOf*/
template <typename T> PointerOf<T>::PointerOf( const T* pointer ) : _pointer( (T*)pointer ), _done(false)
{
}
/*! If size <= 0, return an exception\n
- Else duplicate array and sets desallocation boolean to true./n
+ Else duplicate array and sets desallocation boolean to true.\n
Memory will be desallocated when erasing this PointerOf*/
template <typename T> PointerOf<T>::PointerOf( const int &size, const T* pointer)
{
}
-/*! If necessary, released memory holded by PointerOf/n.
- Else allocates memory and sets desallocation boolean to true./n
- Can be used in order to "nullify" an existing PointerOf/n
+/*! If necessary, released memory holded by PointerOf\n.
+ Else allocates memory and sets desallocation boolean to true.\n
+ Can be used in order to "nullify" an existing PointerOf\n
Memory will be desallocated when erasing this PointerOf*/
template <typename T> void PointerOf<T>::set( const int &size )
{
return ;
}
-/*! If necessary, released memory holded by PointerOf/n.
- Then, sets _pointer to the memory zone pointed by T*. /n
- T* owner is in charged of memory desallocation. /n
+/*! If necessary, released memory holded by PointerOf\n.
+ Then, sets _pointer to the memory zone pointed by T*. \n
+ T* owner is in charged of memory desallocation. \n
memory will not be released when erasing this PointerOf*/
template <typename T> void PointerOf<T>::set( const T *pointer )
{
return ;
}
-/*! If necessary, released memory holded by PointerOf/n.
+/*! If necessary, released memory holded by PointerOf\n.
If size <= 0, return an exception\n.
- Else allocates memory and sets desallocation boolean to true./n
- Can be used in order to "nullify" an existing PointerOf/n
+ Else allocates memory and sets desallocation boolean to true.\n
+ Can be used in order to "nullify" an existing PointerOf\n
Memory will be desallocated when erasing this PointerOf*/
template <typename T> void PointerOf<T>::set( const int &size, const T *pointer)
{
return ;
}
+template <typename T> void PointerOf<T>::setShallowAndOwnership( const T *pointer )
+{
+ if ( _pointer && _done )
+ delete [] _pointer;
+ _pointer=(T*)pointer;
+ _done=true;
+}
+
# endif /* # if ! defined( __PointerOf_HXX__ ) */
}
MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count, const med_int length,
- const med_int* index, const med_int* value):
- _count(count), _length(length),
- _index(_count+1),_value(_length)
+ const med_int* index, const med_int* value,bool shallowCopy):
+ _count(count), _length(length)
{
MESSAGE("Constructeur MEDSKYLINEARRAY(count="<<count<<", length="<<length<<") avec parametres");
- memcpy((med_int*)_index,index,sizeof(med_int)*(_count+1));
- memcpy((med_int*)_value,value,sizeof(med_int)*_length);
+ if(shallowCopy)
+ {
+ _index.setShallowAndOwnership(index);
+ _value.setShallowAndOwnership(value);
+ }
+ else
+ {
+ _index.set(_count+1,index);
+ _value.set(_length,value);
+ }
}
// void MEDSKYLINEARRAY::setMEDSKYLINEARRAY( const med_int count , const med_int length, med_int* index , med_int* value )
MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
MEDSKYLINEARRAY( const med_int count, const med_int length );
MEDSKYLINEARRAY( const med_int count, const med_int length,
- const med_int* index, const med_int* value );
+ const med_int* index, const med_int* value, bool shallowCopy=false );
//void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
int * numberOfElements= new int[it];
_totalNumberOfElements = 0 ;
//int totalSize = 0 ;
- int ** tmp_array = new (int*)[it];
+ int ** tmp_array = new int*[it];
for (int i=0;i<it;i++) {
int numberOfElementsInType = tmp_NumberOfElementsInType[i] ;
numberOfElements[i] = numberOfElementsInType ;
_numberOfElements = new int[it] ;
_totalNumberOfElements = 0 ;
//int totalSize = 0 ;
- int ** tmp_array = new (int*)[it];
+ int ** tmp_array = new int*[it];
for (int i=0;i<it;i++) {
int numberOfElementsInType = tmp_NumberOfElementsInType[i] ;
_numberOfElements[i] = numberOfElementsInType ;
inline void setNumberOfElements(const int *NumberOfElements);
inline void setTotalNumberOfElements(int TotalNumberOfElements);
inline void setNumber(MEDSKYLINEARRAY * Number);
- inline void setNumber(const int * index, const int* value);
+ inline void setNumber(const int * index, const int* value, bool shallowCopy=false);
inline string getName() const;
inline string getDescription() const;
/*! set the attribute _number with index and value arrays */
//---------------------------------------------------
-inline void SUPPORT::setNumber(const int * index, const int* value)
+inline void SUPPORT::setNumber(const int * index, const int* value, bool shallowCopy)
//---------------------------------------------------
{
if (_number != NULL) delete _number ;
- _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value);
+ _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value,shallowCopy);
}
/*! returns the name of the support. */
#define VTK_FIELD_DRIVER_HXX
#include <string>
+#include <fstream>
+#include <sstream>
#include "MEDMEM_define.hxx"
switch (fieldType)
{
- case MED_INT32 : {
- MESSAGE("MED_INT32");
- if (NomberOfComponents==3)
- (*_vtkFile) << "VECTORS " << name.str() << " int" << endl ;
- else if (NomberOfComponents<=4)
- {
- (*_vtkFile) << "SCALARS " << name.str() << " int " << NomberOfComponents << endl ;
- (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
- }
- else
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
-
- //const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
- const int * value = ((FIELD<int>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
- for (int i=0; i<NomberOfValue; i++)
- {
- for(int j=0; j<NomberOfComponents; j++)
- (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
- (*_vtkFile) << endl ;
- }
- break ;
- }
- case MED_REEL64 : {
- MESSAGE("MED_REEL64");
- if (NomberOfComponents==3)
- (*_vtkFile) << "VECTORS " << name.str() << " float" << endl ;
- else if (NomberOfComponents<=4)
- {
- (*_vtkFile) << "SCALARS " << name.str() << " float " << NomberOfComponents << endl ;
- (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
- }
- else
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
-
- const double * value = ((FIELD<double>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
- for (int i=0; i<NomberOfValue; i++)
- {
- for(int j=0; j<NomberOfComponents; j++)
- (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
- (*_vtkFile) << endl ;
- }
- break ;
- }
- default : {
+ case MED_INT32 :
+ {
+ break ;
+ }
+ case MED_REEL64 :
+ {
+ break ;
+ }
+ default :
+ {
throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<< name.str() <<" the type is not int or double !"));
+ }
}
+
+ if (NomberOfComponents==3)
+ (*_vtkFile) << "VECTORS " << name.str() << " int" << endl ;
+ else if (NomberOfComponents<=4)
+ {
+ (*_vtkFile) << "SCALARS " << name.str() << " int " << NomberOfComponents << endl ;
+ (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
}
+ else
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
+
+ const T * value = _ptrField->getValue(MED_NO_INTERLACE) ;
+ for (int i=0; i<NomberOfValue; i++)
+ {
+ for(int j=0; j<NomberOfComponents; j++)
+ (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+ (*_vtkFile) << endl ;
+ }
END_OF(LOC);
}
SCRUTE(name.str());
SCRUTE(fieldType);
-
switch (fieldType)
{
- case MED_INT32 : {
- MESSAGE("MED_INT32");
- if (NomberOfComponents==3)
- (*_vtkFile) << "VECTORS " << name.str() << " int" << endl ;
- else if (NomberOfComponents<=4)
- {
- (*_vtkFile) << "SCALARS " << name.str() << " int " << NomberOfComponents << endl ;
- (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
- }
- else
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
-
- //const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
- const int * value = ((FIELD<int>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
- for (int i=0; i<NomberOfValue; i++)
- {
- for(int j=0; j<NomberOfComponents; j++)
- (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
- (*_vtkFile) << endl ;
- }
- break ;
- }
- case MED_REEL64 : {
- MESSAGE("MED_REEL64");
- if (NomberOfComponents==3)
- (*_vtkFile) << "VECTORS " << name.str() << " float" << endl ;
- else if (NomberOfComponents<=4)
- {
- (*_vtkFile) << "SCALARS " << name.str() << " float " << NomberOfComponents << endl ;
- (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
- }
- else
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
-
- const double * value = ((FIELD<double>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
- for (int i=0; i<NomberOfValue; i++)
- {
- for(int j=0; j<NomberOfComponents; j++)
- (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
- (*_vtkFile) << endl ;
- }
- break ;
- }
- default : {
+ case MED_INT32 :
+ {
+ break ;
+ }
+ case MED_REEL64 :
+ {
+ break ;
+ }
+ default :
+ {
throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<< name.str() <<" the type is not int or double !"));
+ }
}
+
+ if (NomberOfComponents==3)
+ (*_vtkFile) << "VECTORS " << name.str() << " int" << endl ;
+ else if (NomberOfComponents<=4)
+ {
+ (*_vtkFile) << "SCALARS " << name.str() << " int " << NomberOfComponents << endl ;
+ (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
}
+ else
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
+ const T * value = _ptrField->getValue(MED_NO_INTERLACE) ;
+
+ for (int i=0; i<NomberOfValue; i++)
+ {
+ for(int j=0; j<NomberOfComponents; j++)
+ (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+ (*_vtkFile) << endl ;
+ }
END_OF(LOC);
}
MEDMEM_Coordinate.hxx \
MEDMEM_define.hxx \
MEDMEM_DriversDef.hxx \
+MEDMEM_DriverFactory.hxx \
MEDMEM_Family.hxx \
MEDMEM_Field.hxx \
MEDMEM_GenDriver.hxx \
MEDMEM_Connectivity.cxx \
MEDMEM_Coordinate.cxx \
MEDMEM_DriversDef.cxx \
+MEDMEM_DriverFactory.cxx \
MEDMEM_Family.cxx \
MEDMEM_Field.cxx \
MEDMEM_GenDriver.cxx \
*/
med_int nseg2 = 6;
- med_int seg2[12] = {
- 6, 3,
- 8, 9,
- 3, 2,
- 9, 6,
- 2, 5,
- 5, 8
+ med_int seg2[18] = {
+ 6, 3, 0,
+ 8, 9, 0,
+ 3, 2, 0,
+ 9, 6, 0,
+ 2, 5, 0,
+ 5, 8, 0
};
char nomseg2[MED_TAILLE_PNOM*6+1] = "seg1 seg2 seg3 seg4 seg5 seg6 ";
med_int numseg2[6] = {1,2,3,4,5,6};
if (ret == 0)
ret = MEDelementsEcr(fid,maa,mdim,seg2,MED_FULL_INTERLACE,
nomseg2,MED_FAUX,numseg2,MED_VRAI,nufaseg2,nseg2,
- MED_ARETE,MED_SEG2,MED_NOD,MED_ECRI);
+ MED_MAILLE,MED_SEG2,MED_NOD,MED_ECRI);
printf("%d \n",ret);
/***************************************************************************/
*/
med_int nquad4 = 8;
- med_int quad4[32] = {
- 20, 21, 24, 23,
- 22, 23, 26, 25,
- 19, 20, 23, 22,
- 23, 24, 27, 26,
- 1 , 4, 5, 2,
- 5, 8, 9, 6,
- 2, 5, 6, 3,
- 7, 8, 5, 4
+ med_int quad4[40] = {
+ 20, 21, 24, 23, 0,
+ 22, 23, 26, 25, 0,
+ 19, 20, 23, 22, 0,
+ 23, 24, 27, 26, 0,
+ 1 , 4, 5, 2, 0,
+ 5, 8, 9, 6, 0,
+ 2, 5, 6, 3, 0,
+ 7, 8, 5, 4, 0
};
char nomquad4[MED_TAILLE_PNOM*8+1] = "quad1 quad2 quad3 quad4 quad5 quad6 quad7 quad8 ";
if (ret == 0)
ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
- MED_FACE,MED_QUAD4,MED_NOD,MED_ECRI);
+ MED_MAILLE,MED_QUAD4,MED_NOD,MED_ECRI);
printf("%d \n",ret);
/***************************************************************************/
#include "MEDMEM_FieldDouble_i.hxx"
#include "utilities.h"
#include "MEDMEM_convert.hxx"
+#include "SenderFactory.hxx"
+#include "MultiCommException.hxx"
using namespace MEDMEM;
//=============================================================================
* Default constructor
*/
//=============================================================================
-FIELDDOUBLE_i::FIELDDOUBLE_i(): FIELDOF_i<double>()
+FIELDDOUBLE_i::FIELDDOUBLE_i(): FIELD_i()
{
BEGIN_OF("Default Constructor FIELDDOUBLE_i");
END_OF("Default Constructor FIELDDOUBLE_i");
*/
//=============================================================================
FIELDDOUBLE_i::FIELDDOUBLE_i(FIELDDOUBLE_i & fd):
- FIELDOF_i<double>(fd._fieldTptr)
+ FIELD_i(fd)
{
BEGIN_OF("Default Constructor FIELDDOUBLE_i");
END_OF("Default Constructor FIELDDOUBLE_i");
* Default constructor
*/
//=============================================================================
-FIELDDOUBLE_i::FIELDDOUBLE_i(SALOME_MED::SUPPORT_ptr mySupportIOR,::FIELD<double> * const f): FIELDOF_i<double>(mySupportIOR,f)
+FIELDDOUBLE_i::FIELDDOUBLE_i(::FIELD<double> * const f, bool ownCppPtr):
+ FIELD_i(f,ownCppPtr)
{
BEGIN_OF("Constructor FIELDDOUBLE_i");
END_OF(" Constructor FIELDDOUBLE_i");
SALOME_MED::double_array_var myseq = new SALOME_MED::double_array;
try
{
- int nbval=_fieldTptr->getNumberOfComponents();
-
- // Ajout NB pour avoir la valeur correct de nbval
- SALOME_MED::medEntityMesh entity = _support->getEntity();
- if (_support->isOnAllElements())
- {
- if (entity == SALOME_MED::MED_NODE)
- nbval = (_support->getMesh()->getNumberOfNodes())*nbval;
- else
- nbval = (_support->getMesh()->getNumberOfElements(entity,SALOME_MED::MED_ALL_ELEMENTS))*nbval;
- }
- else
- {
- nbval = (_support->getNumberOfElements(SALOME_MED::MED_ALL_ELEMENTS))*nbval;
- }
-
medModeSwitch modemed=convertIdlModeToMedMode(mode);
- const double * values =_fieldTptr->getValue(modemed);
-
+// ::FIELD<double> *ptrD=dynamic_cast< ::FIELD<double>* >(_fieldTptr);
+// the alternative is not safe but the previous fails using the python API
+ MEDMEM::FIELD<double> *ptrD = (MEDMEM::FIELD<double> *) _fieldTptr;
+ const double * values =ptrD->getValue(modemed);
+ int nbval=ptrD->getValueLength(modemed);
myseq->length(nbval);
for (int i=0; i<nbval; i++)
{
}
return myseq._retn();
}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Field's values
+*/
+//=============================================================================
+
+SALOME::Sender_ptr FIELDDOUBLE_i::getSenderForValue( SALOME_MED::medModeSwitch mode )
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ SALOME::Sender_ptr ret;
+ try
+ {
+ medModeSwitch modemed=convertIdlModeToMedMode(mode);
+ ::FIELD<double> *ptrD=dynamic_cast< ::FIELD<double>* >(_fieldTptr);
+ const double * values =ptrD->getValue(modemed);
+ int nbval=ptrD->getValueLength(modemed);
+ ret=SenderFactory::buildSender(*this,values,nbval);
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Unable to acces Field ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ return ret;
+}
#include CORBA_SERVER_HEADER(MED)
#include "MEDMEM_Field_i.hxx"
-#include "MEDMEM_FieldOf_i.hxx"
#include "MEDMEM_Field.hxx"
namespace MEDMEM {
-class FIELDDOUBLE_i: public FIELDOF_i<double>
+ class FIELDDOUBLE_i: public POA_SALOME_MED::FIELDDOUBLE,
+ public FIELD_i,
+ public SALOMEMultiComm
{
private:
public:
FIELDDOUBLE_i();
~FIELDDOUBLE_i();
- FIELDDOUBLE_i(SALOME_MED::SUPPORT_ptr mySupportIOR,::FIELD<double> * const f);
+ FIELDDOUBLE_i(::FIELD<double> * const f, bool ownCppPtr=false);
FIELDDOUBLE_i(FIELDDOUBLE_i & f);
SALOME_MED::double_array * getValue (SALOME_MED::medModeSwitch mode )
throw (SALOME::SALOME_Exception);
+ SALOME::Sender_ptr getSenderForValue(SALOME_MED::medModeSwitch mode)
+ throw (SALOME::SALOME_Exception);
};
}
#include "utilities.h"
#include "MEDMEM_FieldInt_i.hxx"
#include "MEDMEM_convert.hxx"
+#include "SenderFactory.hxx"
+#include "MultiCommException.hxx"
using namespace MEDMEM;
//=============================================================================
* Default constructor
*/
//=============================================================================
-FIELDINT_i::FIELDINT_i(): FIELDOF_i<int>()
+FIELDINT_i::FIELDINT_i(): FIELD_i()
{
BEGIN_OF("Default Constructor FIELDINT_i");
END_OF("Default Constructor FIELDINT_i");
* Default constructor
*/
//=============================================================================
-FIELDINT_i::FIELDINT_i(SALOME_MED::SUPPORT_ptr mySupportIOR, ::FIELD<int> * const f): FIELDOF_i<int>(mySupportIOR,f)
+FIELDINT_i::FIELDINT_i(::FIELD<int> * const f, bool ownCppPtr):
+ FIELD_i(f,ownCppPtr)
{
BEGIN_OF("Constructor FIELDINT_i");
END_OF(" Constructor FIELDINT_i");
* Constructor par recopie
*/
//=============================================================================
-FIELDINT_i::FIELDINT_i(FIELDINT_i &fi):
- FIELDOF_i<int>(fi._fieldTptr)
+FIELDINT_i::FIELDINT_i(FIELDINT_i &fi):FIELD_i(fi)
{
BEGIN_OF("Constructor FIELDINT_i");
END_OF(" Constructor FIELDINT_i");
SALOME::INTERNAL_ERROR);
SALOME_MED::long_array_var myseq = new SALOME_MED::long_array;
try
- {
- int nbval=_fieldTptr->getNumberOfComponents();
-
- // Ajout NB pour avoir la valeur correct de nbval
- SALOME_MED::medEntityMesh entity = _support->getEntity();
- if (_support->isOnAllElements())
- {
- if (entity == SALOME_MED::MED_NODE)
- nbval = (_support->getMesh()->getNumberOfNodes())*nbval;
- else
- nbval = (_support->getMesh()->getNumberOfElements(entity,SALOME_MED::MED_ALL_ELEMENTS))*nbval;
- }
- else
- {
- nbval = (_support->getNumberOfElements(SALOME_MED::MED_ALL_ELEMENTS))*nbval;
- }
-
- medModeSwitch modemed=convertIdlModeToMedMode(mode);
- const int * values =_fieldTptr->getValue(modemed);
+ {
+ medModeSwitch modemed=convertIdlModeToMedMode(mode);
+// ::FIELD<int> *ptrI=dynamic_cast< ::FIELD<int>* >(_fieldTptr);
+//the alternative is not safe but the previous one fails using the python API
+ MEDMEM::FIELD<int> *ptrI = (MEDMEM::FIELD<int> *) _fieldTptr;
- myseq->length(nbval);
+ const int * values =ptrI->getValue(modemed);
+ int nbval=ptrI->getValueLength(modemed);
+ myseq->length(nbval);
for (int i=0; i<nbval; i++)
{
myseq[i]=values[i];
}
return myseq._retn();
}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Field's values
+*/
+//=============================================================================
+
+SALOME::Sender_ptr FIELDINT_i::getSenderForValue( SALOME_MED::medModeSwitch mode )
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ SALOME::Sender_ptr ret;
+ try
+ {
+ medModeSwitch modemed=convertIdlModeToMedMode(mode);
+ ::FIELD<int> *ptrI=dynamic_cast< ::FIELD<int>* >(_fieldTptr);
+ const int * values =ptrI->getValue(modemed);
+ int nbval=ptrI->getValueLength(modemed);
+ ret=SenderFactory::buildSender(*this,values,nbval);
+ }
+ catch(MEDEXCEPTION &ex)
+ {
+ MESSAGE("Unable to acces Field");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ return ret;
+}
#include CORBA_SERVER_HEADER(MED)
#include "MEDMEM_Field_i.hxx"
-#include "MEDMEM_FieldOf_i.hxx"
#include "MEDMEM_Field.hxx"
namespace MEDMEM {
-class FIELDINT_i: public FIELDOF_i<int>
+ class FIELDINT_i: public POA_SALOME_MED::FIELDINT,
+ public FIELD_i,
+ public SALOMEMultiComm
{
private:
FIELDINT_i();
public:
~FIELDINT_i();
- FIELDINT_i(SALOME_MED::SUPPORT_ptr mySupportIOR, ::FIELD<int> * const f);
+ FIELDINT_i(::FIELD<int> * const f, bool ownCppPtr=false);
FIELDINT_i(FIELDINT_i & f);
SALOME_MED::long_array * getValue (SALOME_MED::medModeSwitch mode )
throw (SALOME::SALOME_Exception);
+ SALOME::Sender_ptr getSenderForValue(SALOME_MED::medModeSwitch mode)
+ throw (SALOME::SALOME_Exception);
};
}
#endif /* MED_FIELDINT_I_HXX_ */
+++ /dev/null
-//=============================================================================
-// File : MEDMEM_FieldOf_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_FieldOf_i.hxx
-//=============================================================================
-
-
-#ifndef MED_FIELDOF_I_HXX_
-#define MED_FIELDOF_I_HXX_
-
-#include <map>
-#include <string>
-# include <sstream>
-
-#include <SALOMEconfig.h>
-
-# include "Utils_ORB_INIT.hxx"
-# include "Utils_SINGLETON.hxx"
-
-#include CORBA_SERVER_HEADER(MED)
-#include CORBA_SERVER_HEADER(SALOMEDS)
-#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-
-#include "MEDMEM_Field_i.hxx"
-#include "MEDMEM_Support_i.hxx"
-
-#include "MEDMEM_convert.hxx"
-
-#include "MEDMEM_Support.hxx"
-#include "MEDMEM_Field.hxx"
-
-namespace MEDMEM {
-template <class T> class FIELDOF_i: public FIELD_i
-{
-public :
- static map < int, ::MEDMEM::FIELD<T> * > fieldMap ;
-protected :
- static int fieldIndex ;
-
-protected :
- // C++ object containing values
-
- ::MEDMEM::FIELD<T> * const _fieldTptr;
- const int _corbaIndex;
- string _FieldId;
-
- // CORBA : SUPPORT IOR
- const SALOME_MED::SUPPORT_ptr _support ;
-
-
-public :
- // Constructors and associated internal methods
- FIELDOF_i();
- FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD<T> * const field);
- FIELDOF_i(::FIELD<T> * const f);
- FIELDOF_i(FIELDOF_i & f);
- ~FIELDOF_i();
-
- char * getName() throw (SALOME::SALOME_Exception);
- char * getDescription() throw (SALOME::SALOME_Exception);
- SALOME_MED::SUPPORT_ptr getSupport() throw (SALOME::SALOME_Exception);
- CORBA::Long getNumberOfComponents()
- throw (SALOME::SALOME_Exception);
- char * getComponentName(CORBA::Long i)
- throw (SALOME::SALOME_Exception);
- char * getComponentUnit(CORBA::Long i)
- throw (SALOME::SALOME_Exception);
- CORBA::Long getIterationNumber()
- throw (SALOME::SALOME_Exception);
- CORBA::Long getOrderNumber() throw (SALOME::SALOME_Exception);
- CORBA::Double getTime() throw (SALOME::SALOME_Exception);
- CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception);
-
- SALOME_MED::string_array * getComponentsNames() throw (SALOME::SALOME_Exception);
- SALOME_MED::string_array * getComponentsUnits() throw (SALOME::SALOME_Exception);
- void addInStudy(SALOMEDS::Study_ptr myStudy,
- SALOME_MED::FIELD_ptr myIor)
- throw (SALOME::SALOME_Exception,
- SALOMEDS::StudyBuilder::LockProtection);
-
- CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType,
- const char* fileName, const char* fieldName)
- throw (SALOME::SALOME_Exception);
- void rmDriver (CORBA::Long i) throw (SALOME::SALOME_Exception);
- void read (CORBA::Long i) throw (SALOME::SALOME_Exception);
- void write (CORBA::Long i, const char* driverFieldName)
- throw (SALOME::SALOME_Exception);
-
- // Cuisine Interne
- ::FIELD<T> * constructConstField() const;
-
- };
-}
-using namespace MEDMEM;
-template <class T> map < int, ::FIELD<T> * > FIELDOF_i<T>::fieldMap ;
-template <class T> int FIELDOF_i<T>::fieldIndex = 0;
-//=============================================================================
-/*!
- * Default constructor
- */
-//=============================================================================
-
-//template <class T> FIELDOF_i<T>::FIELDOF_i():_fieldTptr(FIELDOF_i<T>::constructConstField())
-template <class T> FIELDOF_i<T>::FIELDOF_i():_fieldTptr(constructConstField()),
- _support((SALOME_MED::SUPPORT_ptr) NULL)
-{
- BEGIN_OF("Default Constructor Field_i");
- END_OF(" Default Constructor Field_i");
-}
-//=============================================================================
-/*!
- * Destructor
- */
-//=============================================================================
-template <class T> FIELDOF_i<T>::~FIELDOF_i()
-{
-}
-//=============================================================================
-/*!
- * Constructor
- */
-//=============================================================================
-template <class T> FIELDOF_i<T>::FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD<T> * const field):
- _fieldTptr(field),
- _corbaIndex(FIELDOF_i<T>::fieldIndex++),
- _FieldId(""),
- _support(SALOME_MED::SUPPORT::_duplicate(support))
-{
- BEGIN_OF("Constructor FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD<T> * const field)");
- FIELDOF_i<T>::fieldMap[_corbaIndex]=_fieldTptr;
-
- MESSAGE("FIELDOF_i<T>::FIELDOF_i Checking of pointeurs !!!");
-
- SCRUTE(_fieldTptr);
- SCRUTE(_support);
- SCRUTE(_support->getMesh());
-
- END_OF("Constructor FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD<T> * const field)");
-}
-
-
-template <class T> FIELDOF_i<T>::FIELDOF_i( FIELD<T> * const f):
- _fieldTptr(f),
- _corbaIndex(FIELDOF_i<T>::fieldIndex++),
- _FieldId(""),
- _support((SALOME_MED::SUPPORT_ptr) NULL)
-{
- BEGIN_OF("Constructor Field_i");
- FIELDOF_i<T>::fieldMap[_corbaIndex]=_fieldTptr;
- END_OF("Constructor Field_i");
-}
-//=============================================================================
-/*!
- * Constructor par recopie
- */
-//=============================================================================
-template <class T> FIELDOF_i<T>::FIELDOF_i( FIELDOF_i & f):_fieldTptr(f._fieldTptr),
- _corbaIndex(FIELDOF_i<T>::fieldIndex++),
- _FieldId("")
-{
- BEGIN_OF("Constructor Field_i");
- FIELDOF_i<T>::fieldMap[_corbaIndex]=_fieldTptr;
- END_OF("Constructor Field_i");
-}
-//=============================================================================
-/*!
- * Constructor d un pointeur constant
- */
-//=============================================================================
-template <class T> ::FIELD<T> * FIELDOF_i<T>::constructConstField() const
-{
- ::FIELD<T> * const ptrField =new ::FIELD<T>();
- return ptrField;
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for Fields's Name
- */
-//=============================================================================
-template <class T> char * FIELDOF_i<T>::getName()
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- return CORBA::string_dup(_fieldTptr->getName().c_str());
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au nom");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for Fields's Description
- */
-//=============================================================================
-template <class T> char * FIELDOF_i<T>::getDescription()
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- return CORBA::string_dup(_fieldTptr->getDescription().c_str());
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant a la description");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for Fields's Support
- */
-//=============================================================================
-
-template <class T> SALOME_MED::SUPPORT_ptr FIELDOF_i<T>::getSupport()
- throw (SALOME::SALOME_Exception)
-{
- BEGIN_OF("SALOME_MED::SUPPORT_ptr FIELDOF_i<T>::getSupport()");
-
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field",
- SALOME::INTERNAL_ERROR);
- if (_support==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No Support in Field",
- SALOME::INTERNAL_ERROR);
-
- SCRUTE(_fieldTptr);
-
- SCRUTE(_support);
-
- SALOME_MED::SUPPORT_ptr support = SALOME_MED::SUPPORT::_duplicate(_support);
-
- END_OF("SALOME_MED::SUPPORT_ptr FIELDOF_i<T>::getSupport()");
-
- return support ;
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for Fields's Number of components
- */
-//=============================================================================
-template <class T> CORBA::Long FIELDOF_i<T>::getNumberOfComponents()
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- return _fieldTptr->getNumberOfComponents();
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au support");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for names of component I
- */
-//=============================================================================
-template <class T> char * FIELDOF_i<T>::getComponentName(CORBA::Long i)
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- return CORBA::string_dup(_fieldTptr->getComponentName(i).c_str());
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au nom d un component");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for unit of component I
- */
-//=============================================================================
-template <class T> char * FIELDOF_i<T>::getComponentUnit(CORBA::Long i)
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- return CORBA::string_dup(_fieldTptr->getMEDComponentUnit(i).c_str());
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au nom d un component");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for iteration number
- */
-//=============================================================================
-template <class T> CORBA::Long FIELDOF_i<T>::getIterationNumber()
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- return _fieldTptr->getIterationNumber();
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au champ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for Corba Number
- */
-//=============================================================================
-template <class T> CORBA::Long FIELDOF_i<T>::getCorbaIndex()
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- return _corbaIndex;
-
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for iteration number
- */
-//=============================================================================
-template <class T> CORBA::Long FIELDOF_i<T>::getOrderNumber()
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- return _fieldTptr->getOrderNumber();
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au champ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: Accessor
- */
-//=============================================================================
-template <class T> CORBA::Double FIELDOF_i<T>::getTime()
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- return _fieldTptr->getTime();
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au champ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for Fields's Components names
- */
-//=============================================================================
-template <class T> SALOME_MED::string_array * FIELDOF_i<T>::getComponentsNames()
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
- try
- {
- int nbcom = _fieldTptr->getNumberOfComponents();
- myseq->length(nbcom);
- const string * namecom=_fieldTptr->getComponentsNames();
- for (int i=0;i<nbcom;i++)
- {
- myseq[i]=CORBA::string_dup(namecom[i].c_str());
- }
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au champ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
- return myseq._retn();
-}
-//=============================================================================
-/*!
- * CORBA: Accessor for Fields's Components units
- */
-//=============================================================================
-template <class T> SALOME_MED::string_array * FIELDOF_i<T>::getComponentsUnits()
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
- try
- {
- int nbcom = _fieldTptr->getNumberOfComponents();
- myseq->length(nbcom);
- const string * unitcom=_fieldTptr->getMEDComponentsUnits();
- for (int i=0;i<nbcom;i++)
- {
- myseq[i]=CORBA::string_dup(unitcom[i].c_str());
- }
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au champ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
- return myseq._retn();
-}
-//=============================================================================
-/*!
- * CORBA: Add in Study
- */
-//=============================================================================
-template <class T> void FIELDOF_i<T>::addInStudy(SALOMEDS::Study_ptr myStudy,
- SALOME_MED::FIELD_ptr myIor )
- throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
-{
- BEGIN_OF(" FIELDOF_i::addInStudy");
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- if ( _FieldId != "" )
- {
- MESSAGE("Field already in Study");
- THROW_SALOME_CORBA_EXCEPTION("Field already in Study", \
- SALOME::BAD_PARAM);
- };
-
-
- SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- SALOMEDS::AttributeIOR_var aIOR;
-
- // Create SComponent labelled 'Med'
- SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
- if ( CORBA::is_nil(medfather) )
- THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'MED' not Found",SALOME::INTERNAL_ERROR);
-
- // Create SObject labelled 'MEDFIELD' if it doesn't already exit
- SALOMEDS::SObject_var medfieldfather = myStudy->FindObject("MEDFIELD");
- if ( CORBA::is_nil(medfieldfather) )
- {
- MESSAGE("Add Object 'MEDFIELD'");
- medfieldfather = myBuilder->NewObject(medfather);
- anAttr = myBuilder->FindOrCreateAttribute(medfieldfather, "AttributeName");
- aName = SALOMEDS::AttributeName::_narrow(anAttr);
- aName->SetValue("MEDFIELD");
-
- } ;
-
- string fieldName = _fieldTptr->getName();
-
- // Create SObject labelled 'FIELDNAME' if it doesn't already exit
- SALOMEDS::SObject_var medfieldnamefather = myStudy->FindObject(fieldName.c_str());
- if ( CORBA::is_nil(medfieldnamefather) )
- {
- MESSAGE("Add Object "<<fieldName);
- medfieldnamefather = myBuilder->NewObject(medfieldfather);
- anAttr = myBuilder->FindOrCreateAttribute(medfieldnamefather, "AttributeName");
- aName = SALOMEDS::AttributeName::_narrow(anAttr);
- aName->SetValue(fieldName.c_str());
-
- } ;
-
- // Create object labelled according to Field's Name
-
- MESSAGE("Add a Field Object under "<<fieldName);
- myBuilder->NewCommand();
- SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfieldnamefather);
-
- ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
- ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
- CORBA::ORB_var &orb = init(0,0);
-
- int iterationNumber = _fieldTptr->getIterationNumber();
- SCRUTE(iterationNumber);
-
- int orderNumber = _fieldTptr->getOrderNumber();
- SCRUTE(orderNumber);
-
- ostringstream iterationName ;
- iterationName<<"(" << iterationNumber << "," << orderNumber << ")";
- // string supportName = _support->getName();
- string supportName = (_fieldTptr->getSupport())->getName();
- // string meshName = (_support->getMesh())->getName();
- string meshName = ((_fieldTptr->getSupport())->getMesh())->getName();
- string meshNameStudy = meshName;
-
- char * fieldEntryName;
- int lenName = strlen(iterationName.str().c_str()) + 4 +
- strlen(supportName.c_str()) + 4 + strlen(meshName.c_str()) + 1;
-
- fieldEntryName = new char[lenName];
- fieldEntryName = strcpy(fieldEntryName,iterationName.str().c_str());
- fieldEntryName = strcat(fieldEntryName,"_ON_");
- fieldEntryName = strcat(fieldEntryName,supportName.c_str());
- fieldEntryName = strcat(fieldEntryName,"_OF_");
-
- for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
- {
- if (isspace(meshNameStudy[pos])) meshNameStudy[pos] = '_';
- }
-
- SCRUTE(meshNameStudy);
-
- fieldEntryName = strcat(fieldEntryName,meshNameStudy.c_str());
-
- SCRUTE(fieldEntryName);
-
- anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
- aName = SALOMEDS::AttributeName::_narrow(anAttr);
-// aName->SetValue(iterationName.str().c_str());
- aName->SetValue(fieldEntryName);
-
- string iorStr = orb->object_to_string(myIor);
- anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
- aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- aIOR->SetValue(iorStr.c_str());
- myBuilder->CommitCommand();
- _FieldId = newObj->GetID();
-
- MESSAGE("Computing path to Support");
-
- char * supportEntryPath;
- lenName = 28 + 15 + strlen(meshName.c_str()) + 1 +
- strlen(supportName.c_str()) + 1;
- supportEntryPath = new char[lenName];
- supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/MEDSUPPORTS_OF_");
- supportEntryPath = strcat(supportEntryPath,meshNameStudy.c_str());
- supportEntryPath = strcat(supportEntryPath,"/");
- supportEntryPath = strcat(supportEntryPath,supportName.c_str());
-
- SCRUTE(supportEntryPath);
-
- MESSAGE("supportEntryPath in fieldof " << supportEntryPath << " length " << lenName);
-
-// SALOMEDS::SObject_var supportObject = myStudy->FindObject(supportName.c_str());
- SALOMEDS::SObject_var supportObject = myStudy->FindObjectByPath(supportEntryPath);
-
- SCRUTE(supportObject);
-
- if ( CORBA::is_nil(supportObject) )
- {
- MESSAGE("supportObject is a nil corba object");
- MESSAGE("FIELDOF_i::addInStudy : SUPPORT not found") ;
- }
- else
- {
- MESSAGE("supportObject is OK and is now going to be referenced !");
- SALOMEDS::SObject_var newObjSupport = myBuilder->NewObject(newObj);
- myBuilder->Addreference(newObjSupport,supportObject);
- MESSAGE(" OUF !!!");
- }
-
- myBuilder->CommitCommand();
-
- delete [] supportEntryPath;
- delete [] fieldEntryName;
-
- MESSAGE("FIELDOF_i::addInStudy");
-
- //END_OF("FIELDOF_i::addInStudy");
-}
-//=============================================================================
-/*!
- * CORBA: write
- */
-//=============================================================================
-template <class T> void FIELDOF_i<T>::write (CORBA::Long i, const char* driverFieldName)
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- _fieldTptr->write(i,driverFieldName);
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au champ");
- THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
- ,SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: read
- */
-//=============================================================================
-template <class T> void FIELDOF_i<T>::read (CORBA::Long i)
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- _fieldTptr->read(i);
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au champ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: rmDriver
- */
-//=============================================================================
-template <class T> void FIELDOF_i<T>::rmDriver (CORBA::Long i)
-throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- _fieldTptr->rmDriver(i);
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au champ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-//=============================================================================
-/*!
- * CORBA: addDriver
- */
-//=============================================================================
-template <class T> CORBA::Long FIELDOF_i<T>::addDriver (SALOME_MED::medDriverTypes driverType,
- const char* fileName, const char* fieldName) throw (SALOME::SALOME_Exception)
-{
- if (_fieldTptr==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
- SALOME::INTERNAL_ERROR);
- try
- {
- int drivernum=_fieldTptr->addDriver(
- convertIdlDriverToMedDriver(driverType),
- fileName,
- fieldName);
- return drivernum;
- }
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Exception en accedant au champ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
- }
-}
-
-#endif /* MED_FIELDOF_I_HXX_ */
// Copyright : EDF 2002
// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Field_i.cxx
//=============================================================================
-# include "MEDMEM_Field_i.hxx"
-using namespace MEDMEM;
+#include "MEDMEM_Field_i.hxx"
-FIELD_i::FIELD_i()
+map < int, ::FIELD_ * > FIELD_i::fieldMap ;
+int FIELD_i::fieldIndex = 0;
+//=============================================================================
+/*!
+ * Default constructor
+ */
+//=============================================================================
+
+//FIELD_i::FIELD_i():_fieldTptr(FIELD_i::constructConstField())
+FIELD_i::FIELD_i():_fieldTptr(constructConstField())
{
+ BEGIN_OF("Default Constructor Field_i");
+ END_OF(" Default Constructor Field_i");
}
-FIELD_i::FIELD_i(const FIELD_i & x)
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+FIELD_i::~FIELD_i()
{
+ if (_ownCppPtr) delete _fieldTptr;
}
-FIELD_i::~FIELD_i()
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+FIELD_i::FIELD_i(::FIELD_ * const field, bool ownCppPtr):
+ _fieldTptr(field),
+ _corbaIndex(FIELD_i::fieldIndex++),
+ _FieldId(""),
+ _ownCppPtr(ownCppPtr)
+{
+ BEGIN_OF("Constructor FIELD_i(SALOME_MED::SUPPORT_ptr support,::FIELD<T> * const field)");
+ FIELD_i::fieldMap[_corbaIndex]=_fieldTptr;
+
+ MESSAGE("FIELD_i::FIELD_i Checking of pointeurs !!!");
+
+ SCRUTE(_fieldTptr);
+
+ END_OF("Constructor FIELD_i(SALOME_MED::SUPPORT_ptr support,::FIELD<T> * const field)");
+}
+
+//=============================================================================
+/*!
+ * Constructor par recopie
+ */
+//=============================================================================
+FIELD_i::FIELD_i( FIELD_i & f):_fieldTptr(f._fieldTptr),
+ _corbaIndex(FIELD_i::fieldIndex++),
+ _FieldId(""), _ownCppPtr(false)
+{
+ BEGIN_OF("Constructor Field_i");
+ FIELD_i::fieldMap[_corbaIndex]=_fieldTptr;
+ END_OF("Constructor Field_i");
+}
+//=============================================================================
+/*!
+ * Constructor d un pointeur constant
+ */
+//=============================================================================
+ ::FIELD_ * FIELD_i::constructConstField() const
+{
+ ::FIELD_ * const ptrField =new ::FIELD_();
+ return ptrField;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Name
+ */
+//=============================================================================
+char * FIELD_i::getName()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_fieldTptr->getName().c_str());
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au nom");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Description
+ */
+//=============================================================================
+char * FIELD_i::getDescription()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_fieldTptr->getDescription().c_str());
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant a la description");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Support
+ */
+//=============================================================================
+
+SALOME_MED::SUPPORT_ptr FIELD_i::getSupport()
+ throw (SALOME::SALOME_Exception)
+{
+ BEGIN_OF("SALOME_MED::SUPPORT_ptr FIELD_i::getSupport()");
+
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field",
+ SALOME::INTERNAL_ERROR);
+
+ SUPPORT_i* servant = new SUPPORT_i(_fieldTptr->getSupport());
+
+ SALOME_MED::SUPPORT_ptr support=servant->_this();
+
+ SCRUTE(_fieldTptr);
+
+ END_OF("SALOME_MED::SUPPORT_ptr FIELD_i::getSupport()");
+
+ return support ;
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Number of components
+ */
+//=============================================================================
+CORBA::Long FIELD_i::getNumberOfComponents()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _fieldTptr->getNumberOfComponents();
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au support");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for names of component I
+ */
+//=============================================================================
+char * FIELD_i::getComponentName(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_fieldTptr->getComponentName(i).c_str());
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au nom d un component");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for unit of component I
+ */
+//=============================================================================
+char * FIELD_i::getComponentUnit(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_fieldTptr->getMEDComponentUnit(i).c_str());
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au nom d un component");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for description of component I
+ */
+//=============================================================================
+char * FIELD_i::getComponentDescription(CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return CORBA::string_dup(_fieldTptr->getComponentDescription(i).c_str());
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant a la description d un component");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for iteration number
+ */
+//=============================================================================
+CORBA::Long FIELD_i::getIterationNumber()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _fieldTptr->getIterationNumber();
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Corba Number
+ */
+//=============================================================================
+CORBA::Long FIELD_i::getCorbaIndex()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ return _corbaIndex;
+
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for iteration number
+ */
+//=============================================================================
+CORBA::Long FIELD_i::getOrderNumber()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _fieldTptr->getOrderNumber();
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor
+ */
+//=============================================================================
+CORBA::Double FIELD_i::getTime()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ return _fieldTptr->getTime();
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Components names
+ */
+//=============================================================================
+SALOME_MED::string_array * FIELD_i::getComponentsNames()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
+ try
+ {
+ int nbcom = _fieldTptr->getNumberOfComponents();
+ myseq->length(nbcom);
+ const string * namecom=_fieldTptr->getComponentsNames();
+ for (int i=0;i<nbcom;i++)
+ {
+ myseq[i]=CORBA::string_dup(namecom[i].c_str());
+ }
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Components units
+ */
+//=============================================================================
+SALOME_MED::string_array * FIELD_i::getComponentsUnits()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
+ try
+ {
+ int nbcom = _fieldTptr->getNumberOfComponents();
+ myseq->length(nbcom);
+ const string * unitcom=_fieldTptr->getMEDComponentsUnits();
+ for (int i=0;i<nbcom;i++)
+ {
+ myseq[i]=CORBA::string_dup(unitcom[i].c_str());
+ }
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Accessor for Fields's Components descriptions
+ */
+//=============================================================================
+SALOME_MED::string_array * FIELD_i::getComponentsDescriptions()
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
+ try
+ {
+ int nbcom = _fieldTptr->getNumberOfComponents();
+ myseq->length(nbcom);
+ const string * namecom=_fieldTptr->getComponentsDescriptions();
+ for (int i=0;i<nbcom;i++)
+ {
+ myseq[i]=CORBA::string_dup(namecom[i].c_str());
+ }
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+}
+//=============================================================================
+/*!
+ * CORBA: Add in Study
+ */
+//=============================================================================
+void FIELD_i::addInStudy(SALOMEDS::Study_ptr myStudy,
+ SALOME_MED::FIELD_ptr myIor )
+ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+{
+ BEGIN_OF(" FIELD_i::addInStudy");
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ if ( _FieldId != "" )
+ {
+ MESSAGE("Field already in Study");
+ THROW_SALOME_CORBA_EXCEPTION("Field already in Study", \
+ SALOME::BAD_PARAM);
+ };
+
+
+ SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var aIOR;
+
+ // Create SComponent labelled 'Med'
+ SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
+ if ( CORBA::is_nil(medfather) )
+ THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'MED' not Found",SALOME::INTERNAL_ERROR);
+
+ // Create SObject labelled 'MEDFIELD' if it doesn't already exit
+ SALOMEDS::SObject_var medfieldfather = myStudy->FindObject("MEDFIELD");
+ if ( CORBA::is_nil(medfieldfather) )
+ {
+ MESSAGE("Add Object 'MEDFIELD'");
+ medfieldfather = myBuilder->NewObject(medfather);
+ anAttr = myBuilder->FindOrCreateAttribute(medfieldfather, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue("MEDFIELD");
+
+ } ;
+
+ string fieldName = _fieldTptr->getName();
+
+ // Create SObject labelled 'FIELDNAME' if it doesn't already exit
+ SALOMEDS::SObject_var medfieldnamefather = myStudy->FindObject(fieldName.c_str());
+ if ( CORBA::is_nil(medfieldnamefather) )
+ {
+ MESSAGE("Add Object "<<fieldName);
+ medfieldnamefather = myBuilder->NewObject(medfieldfather);
+ anAttr = myBuilder->FindOrCreateAttribute(medfieldnamefather, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue(fieldName.c_str());
+
+ } ;
+
+ // Create object labelled according to Field's Name
+
+ MESSAGE("Add a Field Object under "<<fieldName);
+ myBuilder->NewCommand();
+ SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfieldnamefather);
+
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
+ CORBA::ORB_var &orb = init(0,0);
+
+ int iterationNumber = _fieldTptr->getIterationNumber();
+ SCRUTE(iterationNumber);
+
+ int orderNumber = _fieldTptr->getOrderNumber();
+ SCRUTE(orderNumber);
+
+ ostringstream iterationName ;
+ iterationName<<"(" << iterationNumber << "," << orderNumber << ")";
+ // string supportName = _support->getName();
+ string supportName = (_fieldTptr->getSupport())->getName();
+ // string meshName = (_support->getMesh())->getName();
+ string meshName = ((_fieldTptr->getSupport())->getMesh())->getName();
+ string meshNameStudy = meshName;
+
+ char * fieldEntryName;
+ int lenName = strlen(iterationName.str().c_str()) + 4 +
+ strlen(supportName.c_str()) + 4 + strlen(meshName.c_str()) + 1;
+
+ fieldEntryName = new char[lenName];
+ fieldEntryName = strcpy(fieldEntryName,iterationName.str().c_str());
+ fieldEntryName = strcat(fieldEntryName,"_ON_");
+ fieldEntryName = strcat(fieldEntryName,supportName.c_str());
+ fieldEntryName = strcat(fieldEntryName,"_OF_");
+
+ for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
+ {
+ if (isspace(meshNameStudy[pos])) meshNameStudy[pos] = '_';
+ }
+
+ SCRUTE(meshNameStudy);
+
+ fieldEntryName = strcat(fieldEntryName,meshNameStudy.c_str());
+
+ SCRUTE(fieldEntryName);
+
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+// aName->SetValue(iterationName.str().c_str());
+ aName->SetValue(fieldEntryName);
+
+ string iorStr = orb->object_to_string(myIor);
+ anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ aIOR->SetValue(iorStr.c_str());
+ myBuilder->CommitCommand();
+ _FieldId = newObj->GetID();
+
+ MESSAGE("Computing path to Support");
+
+ char * supportEntryPath;
+ lenName = 28 + 15 + strlen(meshName.c_str()) + 1 +
+ strlen(supportName.c_str()) + 1;
+ supportEntryPath = new char[lenName];
+ supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/MEDSUPPORTS_OF_");
+ supportEntryPath = strcat(supportEntryPath,meshNameStudy.c_str());
+ supportEntryPath = strcat(supportEntryPath,"/");
+ supportEntryPath = strcat(supportEntryPath,supportName.c_str());
+
+ SCRUTE(supportEntryPath);
+
+ MESSAGE("supportEntryPath in field " << supportEntryPath << " length " << lenName);
+
+// SALOMEDS::SObject_var supportObject = myStudy->FindObject(supportName.c_str());
+ SALOMEDS::SObject_var supportObject = myStudy->FindObjectByPath(supportEntryPath);
+
+ SCRUTE(supportObject);
+
+ if ( CORBA::is_nil(supportObject) )
+ {
+ MESSAGE("supportObject is a nil corba object");
+ MESSAGE("FIELD_i::addInStudy : SUPPORT not found") ;
+ }
+ else
+ {
+ MESSAGE("supportObject is OK and is now going to be referenced !");
+ SALOMEDS::SObject_var newObjSupport = myBuilder->NewObject(newObj);
+ myBuilder->Addreference(newObjSupport,supportObject);
+ MESSAGE(" OUF !!!");
+ }
+
+ myBuilder->CommitCommand();
+
+ delete [] supportEntryPath;
+ delete [] fieldEntryName;
+
+ MESSAGE("FIELD_i::addInStudy");
+
+ //END_OF("FIELD_i::addInStudy");
+}
+//=============================================================================
+/*!
+ * CORBA: write
+ */
+//=============================================================================
+void FIELD_i::write (CORBA::Long i, const char* driverFieldName)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _fieldTptr->write(i,driverFieldName);
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\
+ ,SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: read
+ */
+//=============================================================================
+void FIELD_i::read (CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _fieldTptr->read(i);
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: rmDriver
+ */
+//=============================================================================
+void FIELD_i::rmDriver (CORBA::Long i)
+throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ _fieldTptr->rmDriver(i);
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+//=============================================================================
+/*!
+ * CORBA: addDriver
+ */
+//=============================================================================
+CORBA::Long FIELD_i::addDriver (SALOME_MED::medDriverTypes driverType,
+ const char* fileName, const char* fieldName) throw (SALOME::SALOME_Exception)
+{
+ if (_fieldTptr==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Field", \
+ SALOME::INTERNAL_ERROR);
+ try
+ {
+ int drivernum=_fieldTptr->addDriver(
+ convertIdlDriverToMedDriver(driverType),
+ fileName,
+ fieldName);
+ return drivernum;
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Exception en accedant au champ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA: Destructor
+*/
+//=============================================================================
+void FIELD_i::release()
{
+ PortableServer::ObjectId_var oid=_default_POA()->servant_to_id(this);
+ _default_POA()->deactivate_object(oid);
+ _remove_ref();
}
//=============================================================================
// File : MEDMEM_Field_i.hxx
-// Created : mer fév 20 15:47:57 CET 2002
-// Author : EDF
// Project : SALOME
+// Author : EDF
// Copyright : EDF 2002
// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Field_i.hxx
//=============================================================================
-# ifndef __FIELD_I_H__
-# define __FIELD_I_H__
-# include <SALOMEconfig.h>
-# include CORBA_SERVER_HEADER(MED)
-# include "Utils_CorbaException.hxx"
+#ifndef MED_FIELD_I_HXX_
+#define MED_FIELD_I_HXX_
+
+#include <map>
+#include <string>
+#include <sstream>
+
+#include "Utils_CorbaException.hxx"
+#include <SALOMEconfig.h>
+
+# include "Utils_ORB_INIT.hxx"
+# include "Utils_SINGLETON.hxx"
+
+#include CORBA_SERVER_HEADER(MED)
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "MEDMEM_Support_i.hxx"
+
+#include "MEDMEM_convert.hxx"
+
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Field.hxx"
namespace MEDMEM {
-class FIELD_i
+class FIELD_i: public virtual POA_SALOME_MED::FIELD,
+ public PortableServer::RefCountServantBase
{
-
+public :
+ static map < int, ::MEDMEM::FIELD_ * > fieldMap ;
+protected :
+ static int fieldIndex ;
+ bool _ownCppPtr;
protected :
- FIELD_i();
+ // C++ object containing values and Constructor
+ // are protected because it is not supposed to be instancied
+
+ ::MEDMEM::FIELD_ * const _fieldTptr;
+ const int _corbaIndex;
+ string _FieldId;
+ FIELD_i();
+ FIELD_i(::FIELD_ * const field, bool ownCppPtr);
+ FIELD_i(FIELD_i & f);
public :
- FIELD_i( const FIELD_i & x);
- ~FIELD_i();
- virtual char * getName()
- throw (SALOME::SALOME_Exception) = 0;
- virtual char * getDescription()
- throw (SALOME::SALOME_Exception) = 0;
- virtual SALOME_MED::SUPPORT_ptr getSupport()
- throw (SALOME::SALOME_Exception) = 0;
- virtual CORBA::Long getNumberOfComponents()
- throw (SALOME::SALOME_Exception) = 0;
- virtual char * getComponentName(CORBA::Long i)
- throw (SALOME::SALOME_Exception) = 0;
- virtual char * getComponentUnit(CORBA::Long i)
- throw (SALOME::SALOME_Exception) = 0;
- virtual CORBA::Long getIterationNumber()
- throw (SALOME::SALOME_Exception) = 0;
- virtual CORBA::Long getOrderNumber()
- throw (SALOME::SALOME_Exception) = 0;
- virtual CORBA::Double getTime()
- throw (SALOME::SALOME_Exception) = 0;
- virtual CORBA::Long getCorbaIndex()
- throw (SALOME::SALOME_Exception) = 0;
- virtual SALOME_MED::string_array * getComponentsNames()
- throw (SALOME::SALOME_Exception) = 0;
- virtual SALOME_MED::string_array * getComponentsUnits()
- throw (SALOME::SALOME_Exception) = 0;
- virtual void addInStudy(SALOMEDS::Study_ptr myStudy ,
- SALOME_MED::FIELD_ptr myIor)
- throw (SALOME::SALOME_Exception,
- SALOMEDS::StudyBuilder::LockProtection) = 0;
- virtual CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType,
- const char* fileName,
- const char* fieldName)
- throw (SALOME::SALOME_Exception) = 0;
- virtual void rmDriver (CORBA::Long i)
- throw (SALOME::SALOME_Exception) = 0;
- virtual void read (CORBA::Long i)
- throw (SALOME::SALOME_Exception) = 0;
- virtual void write (CORBA::Long i,
- const char* driverFieldName)
- throw (SALOME::SALOME_Exception) = 0;
-};
-};
-# endif /* ifndef ____FIELD_I_H__ */
+ // Associated internal methods
+ ~FIELD_i();
+
+ char * getName() throw (SALOME::SALOME_Exception);
+ char * getDescription() throw (SALOME::SALOME_Exception);
+ SALOME_MED::SUPPORT_ptr getSupport() throw (SALOME::SALOME_Exception);
+ CORBA::Long getNumberOfComponents()
+ throw (SALOME::SALOME_Exception);
+ char * getComponentName(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ char * getComponentUnit(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ char * getComponentDescription(CORBA::Long i)
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getIterationNumber()
+ throw (SALOME::SALOME_Exception);
+ CORBA::Long getOrderNumber() throw (SALOME::SALOME_Exception);
+ CORBA::Double getTime() throw (SALOME::SALOME_Exception);
+ CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception);
+
+ SALOME_MED::string_array * getComponentsNames() throw (SALOME::SALOME_Exception);
+ SALOME_MED::string_array * getComponentsUnits() throw (SALOME::SALOME_Exception);
+ SALOME_MED::string_array * getComponentsDescriptions() throw (SALOME::SALOME_Exception);
+ void addInStudy(SALOMEDS::Study_ptr myStudy,
+ SALOME_MED::FIELD_ptr myIor)
+ throw (SALOME::SALOME_Exception,
+ SALOMEDS::StudyBuilder::LockProtection);
+
+ CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType,
+ const char* fileName, const char* fieldName)
+ throw (SALOME::SALOME_Exception);
+ void rmDriver (CORBA::Long i) throw (SALOME::SALOME_Exception);
+ void read (CORBA::Long i) throw (SALOME::SALOME_Exception);
+ void write (CORBA::Long i, const char* driverFieldName)
+ throw (SALOME::SALOME_Exception);
+ void release();
+ // Cuisine Interne
+ ::FIELD_ * constructConstField() const;
+
+ };
+}
+
+//using namespace MEDMEM;
+
+#endif /* MED_FIELD_I_HXX_ */
for (int i=0;i<nbfam;i++)
{
FAMILY_i * f1=new FAMILY_i(fam[i]);
- SALOME_MED::FAMILY_ptr f2 =
- f1->POA_SALOME_MED::FAMILY::_this();
- f1->_remove_ref();
- myseq[i] = f2;
+ myseq[i] = f1->POA_SALOME_MED::FAMILY::_this();
}
}
catch (MEDEXCEPTION &ex)
{
FAMILY * fam=_group->getFamily(i);
FAMILY_i * f1=new FAMILY_i(fam);
- SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
- f1->_remove_ref();
- return (SALOME_MED::FAMILY::_duplicate(f2));
+ return f1->POA_SALOME_MED::FAMILY::_this();
}
catch (MEDEXCEPTION &ex)
{
MESH_i * myMeshI = new MESH_i(myMesh);
SALOME_MED::MESH_ptr myMeshIOR = myMeshI->_this();
_meshes[meshesNames[i]] = myMeshIOR;
- myMeshI->addInStudy(myStudy,myMeshIOR,fileName);
+// myMeshI->addInStudy(myStudy,myMeshIOR,fileName);
}
// SUPPORTS :
{
FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt);
SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this();
- myFamilyI->addInStudy(myStudy,myFamilyIOR);
+// myFamilyI->addInStudy(myStudy,myFamilyIOR);
}
// group :
{
GROUP_i * myGroupI = new GROUP_i(*groupVectorIt);
SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this();
- myGroupI->addInStudy(myStudy,myGroupIOR);
+// myGroupI->addInStudy(myStudy,myGroupIOR);
}
}
}
SUPPORT_i * mySupportI = new SUPPORT_i((*itSupport).second);
SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this();
mySupportsIOR[(*itSupport).first] = mySupportIOR;
- mySupportI->addInStudy(myStudy,mySupportIOR);
+// mySupportI->addInStudy(myStudy,mySupportIOR);
}
}
case MED_FR::MED_INT32 :
{
((FIELD<int>*)myField)->read();
- FIELDINT_i * myFieldIntI = new FIELDINT_i(mySupportIOR,(FIELD<int>*)myField);
- POA_SALOME_MED::FIELD_tie<FIELD_i> * myFieldTie
- = new POA_SALOME_MED::FIELD_tie<FIELD_i>(myFieldIntI);
- myFieldIOR = myFieldTie->_this();
- myFieldIntI->addInStudy(myStudy,myFieldIOR);
+ FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
+ myFieldIOR = myFieldIntI->_this();
+// myFieldIntI->addInStudy(myStudy,myFieldIOR);
break;
}
case MED_FR::MED_REEL64:
{
((FIELD<double>*)myField)->read();
- FIELDDOUBLE_i * myFieldDoubleI
- = new FIELDDOUBLE_i(mySupportIOR,(FIELD<double>*)myField);
- POA_SALOME_MED::FIELD_tie<FIELD_i> * myFieldTie
- = new POA_SALOME_MED::FIELD_tie<FIELD_i>(myFieldDoubleI);
- myFieldIOR = myFieldTie->_this();
- myFieldDoubleI->addInStudy(myStudy,myFieldIOR);
+ FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
+ myFieldIOR = myFieldDoubleI->_this();
+// myFieldDoubleI->addInStudy(myStudy,myFieldIOR);
break;
}
default:
case MED_FR::MED_INT32:
{
((FIELD<int>*)myField)->read();
- FIELDINT_i * myFieldIntI
- = new FIELDINT_i(mySupportIOR,(FIELD<int>*)myField);
+ FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
SALOME_MED::FIELDINT_ptr myFieldIntIOR;
- POA_SALOME_MED::FIELDINT_tie<FIELDINT_i> * myFieldIntTie
- = new POA_SALOME_MED::FIELDINT_tie<FIELDINT_i>(myFieldIntI);
- myFieldIntIOR = myFieldIntTie->_this();
+ myFieldIntIOR = myFieldIntI->_this();
MESSAGE(LOC << " add in study of the field " << fieldsNames[i].c_str() << " dt = " << dtIt.dt << " it = " << dtIt.it);
case MED_FR::MED_REEL64:
{
((FIELD<double>*)myField)->read();
- FIELDDOUBLE_i * myFieldDoubleI
- = new FIELDDOUBLE_i(mySupportIOR,(FIELD<double>*)myField);
+ FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
SALOME_MED::FIELDDOUBLE_ptr myFieldDoubleIOR;
- POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * myFieldDoubleTie
- = new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(myFieldDoubleI);
- myFieldDoubleIOR = myFieldDoubleTie->_this();
+ myFieldDoubleIOR = myFieldDoubleI->_this();
MESSAGE(LOC << " add in study of the field " << fieldsNames[i].c_str() << " dt = " << dtIt.dt << " it = " << dtIt.it);
}
}
-
MESSAGE("Here we are i="<< i);
}
{
MESH * mesh=_med->getMesh(meshName);
MESH_i * m1 = new MESH_i(mesh);
- SALOME_MED::MESH_ptr m2 = m1->POA_SALOME_MED::MESH::_this();
- m1->_remove_ref();
- return (SALOME_MED::MESH::_duplicate(m2));
+ return m1->POA_SALOME_MED::MESH::_this();
}
catch (MEDEXCEPTION &ex)
{
SALOME_MED::FIELDDOUBLE_var fielddouble =
SALOME_MED::FIELDDOUBLE::_narrow(fieldPtr);
ASSERT(!CORBA::is_nil(fielddouble));
- ASSERT(FIELDOF_i<double>::fieldMap.find(ind)
- !=FIELDOF_i<double>::fieldMap.end());
- ::FIELD<double> * fdouble = FIELDOF_i<double>::fieldMap[ind];
+
+ ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
+
+ ::FIELD<double> * fdouble = (::FIELD<double> *)FIELD_i::fieldMap[ind];
MESH * mesh=_med->getMesh(fdouble);
}
else
{
MESSAGE("Integer");
- ASSERT(FIELDOF_i<int>::fieldMap.find(ind)!=FIELDOF_i<int>::fieldMap.end());
- ::FIELD<int> * fint = FIELDOF_i<int>::fieldMap[ind];
+ ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
+
+ ::FIELD<int> * fint = (::FIELD<int> *)FIELD_i::fieldMap[ind];
MESH * mesh=_med->getMesh(fint);
}
MESH_i * meshi = new MESH_i(mesh);
- SALOME_MED::MESH_ptr meshptr = meshi->POA_SALOME_MED::MESH::_this();
- meshi->_remove_ref();
- return (SALOME_MED::MESH::_duplicate(meshptr));
+ return meshi->POA_SALOME_MED::MESH::_this();
}
//=============================================================================
SALOME_MED::FIELDDOUBLE_var fielddouble =
SALOME_MED::FIELDDOUBLE::_narrow(ptrField);
ASSERT(!CORBA::is_nil(fielddouble));
- ASSERT(FIELDOF_i<double>::fieldMap.find(ind)
- !=FIELDOF_i<double>::fieldMap.end());
- ::FIELD<double> * fdouble = FIELDOF_i<double>::fieldMap[ind];
+
+ ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
+
+ ::FIELD<double> * fdouble = (::FIELD<double> *)FIELD_i::fieldMap[ind];
// A modifier
//_med->addField(fdouble);
}
else
{
MESSAGE("Integer");
- ASSERT(FIELDOF_i<int>::fieldMap.find(ind)!=FIELDOF_i<int>::fieldMap.end());
- ::FIELD<int> * fint = FIELDOF_i<int>::fieldMap[ind];
+ ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
+ ::FIELD<int> * fint = (::FIELD<int> *)FIELD_i::fieldMap[ind];
//_med->addField(fint);
}
}
#include "MEDMEM_Family.hxx"
#include "MEDMEM_Group.hxx"
#include "MEDMEM_CellModel.hxx"
+
+#include "SenderFactory.hxx"
+#include "MultiCommException.hxx"
using namespace MEDMEM;
// Initialisation des variables statiques
return myseq._retn();
}
//=============================================================================
+/*!
+ * CORBA: 2nd Accessor for Coordinates
+ */
+//=============================================================================
+SALOME::Sender_ptr MESH_i::getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch)
+ throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ SALOME::Sender_ptr ret;
+ try
+ {
+ int spaceDimension=_mesh->getSpaceDimension();
+ int nbNodes=_mesh->getNumberOfNodes();
+ const double * coordinates =_mesh->getCoordinates(convertIdlModeToMedMode(typeSwitch));
+ ret=SenderFactory::buildSender(*this,coordinates,nbNodes*spaceDimension);
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Unable to acces the coordinates");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ catch(MultiCommException &ex2)
+ THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
+ return ret;
+}
+//=============================================================================
/*!
* CORBA: Accessor for Coordinates Names
*/
return myseq._retn();
}
//=============================================================================
+/*!
+ * CORBA: 2nd Accessor for connectivities
+ */
+//=============================================================================
+SALOME::Sender_ptr MESH_i::getSenderForConnectivity(SALOME_MED::medModeSwitch typeSwitch,
+ SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement geomElement)
+throw (SALOME::SALOME_Exception)
+{
+ if (_mesh==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
+ SALOME::INTERNAL_ERROR);
+ if (verifieParam(entity,geomElement)==false)
+ THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
+ SALOME::BAD_PARAM);
+ SALOME::Sender_ptr ret;
+ try
+ {
+ int nbelements=_mesh->getConnectivityLength(convertIdlModeToMedMode(typeSwitch),
+ convertIdlConnToMedConn(mode),
+ convertIdlEntToMedEnt(entity),
+ convertIdlEltToMedElt(geomElement));
+ const int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch),
+ convertIdlConnToMedConn(mode),
+ convertIdlEntToMedEnt(entity),
+ convertIdlEltToMedElt(geomElement));
+ ret=SenderFactory::buildSender(*this,numbers,nbelements);
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Unable to acces connectivities");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ catch(MultiCommException &ex2)
+ THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
+ return ret;
+}
+//=============================================================================
/*!
* CORBA: Accessor for connectivities
*/
SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
try
{
- int nbelements;
- if ( mode == SALOME_MED::MED_DESCENDING)
- {
- nbelements =(_mesh->getNumberOfNodes())+1;
- }
- else
- {
- nbelements = _mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS);
- }
+ int nbelements=_mesh->getReverseConnectivityLength(convertIdlConnToMedConn(mode));
SCRUTE(nbelements);
myseq->length(nbelements);
const int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode));
SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
try
{
- int nbelements;
- if ( mode == SALOME_MED::MED_DESCENDING)
- {
- nbelements =_mesh->getNumberOfNodes();
- }
- else
- {
- int dim=_mesh->getMeshDimension();
- if ( dim == 3)
- nbelements = _mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS);
- else
- if (dim == 2)
- nbelements = _mesh->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS);
- else
- THROW_SALOME_CORBA_EXCEPTION("Pb ", \
- SALOME::INTERNAL_ERROR);
- }
-
+ int nbelements=_mesh->getReverseConnectivityIndexLength(convertIdlConnToMedConn(mode));
myseq->length(nbelements);
const int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode));
for (int i=0;i<nbelements;i++)
for (int i=0;i<nbfam;i++)
{
FAMILY_i * f1=new FAMILY_i(fam[i]);
- SALOME_MED::FAMILY_ptr f2 =
- f1->POA_SALOME_MED::FAMILY::_this();
- f1->_remove_ref();
- myseq[i] = f2;
+ myseq[i] = f1->POA_SALOME_MED::FAMILY::_this();
}
}
catch (MEDEXCEPTION &ex)
convertIdlEntToMedEnt(entity));
all->meshTypes.length(nbTypes);
all->numberOfElements.length(nbTypes);
+ all->entityDimension=_mesh->getConnectivityptr()->getEntityDimension();
for (int i=0; i<nbTypes; i++)
{
all->meshTypes[i]=convertMedEltToIdlElt(elemts[i]);
{
const FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i);
FAMILY_i * f1=new FAMILY_i(fam);
- SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
- f1->_remove_ref();
- return (SALOME_MED::FAMILY::_duplicate(f2));
+ return f1->POA_SALOME_MED::FAMILY::_this();
}
catch (MEDEXCEPTION &ex)
{
for (int i=0;i<nbFam;i++)
{
FAMILY_i * f1=new FAMILY_i(vNode[i]);
- SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
- f1->_remove_ref();
- all->famNode[i] = f2;
+ all->famNode[i] = f1->POA_SALOME_MED::FAMILY::_this();
}
nbFam = _mesh->getNumberOfFamilies(MED_EDGE);
for (int i=0;i<nbFam;i++)
{
FAMILY_i * f1=new FAMILY_i(vEdge[i]);
- SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
- f1->_remove_ref();
- all->famEdge[i] = f2;
+ all->famEdge[i] = f1->POA_SALOME_MED::FAMILY::_this();
}
nbFam = _mesh->getNumberOfFamilies(MED_FACE);
for (int i=0;i<nbFam;i++)
{
FAMILY_i * f1=new FAMILY_i(vFace[i]);
- SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
- f1->_remove_ref();
- all->famFace[i] = f2;
+ all->famFace[i] = f1->POA_SALOME_MED::FAMILY::_this();
}
nbFam = _mesh->getNumberOfFamilies(MED_CELL);
for (int i=0;i<nbFam;i++)
{
FAMILY_i * f1=new FAMILY_i(vCell[i]);
- SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
- f1->_remove_ref();
- all->famCell[i] = f2;
+ all->famCell[i] = f1->POA_SALOME_MED::FAMILY::_this();
}
int nbGroup = _mesh->getNumberOfGroups(MED_NODE);
for (int i=0;i<nbGroup;i++)
{
GROUP_i * f1=new GROUP_i(gNode[i]);
- SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
- f1->_remove_ref();
- all->groupNode[i] = f2;
+ all->groupNode[i] = f1->POA_SALOME_MED::GROUP::_this();
}
nbGroup = _mesh->getNumberOfGroups(MED_EDGE);
for (int i=0;i<nbGroup;i++)
{
GROUP_i * f1=new GROUP_i(gEdge[i]);
- SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
- f1->_remove_ref();
- all->groupEdge[i] = f2;
+ all->groupEdge[i] = f1->POA_SALOME_MED::GROUP::_this();
}
nbGroup = _mesh->getNumberOfGroups(MED_FACE);
all->groupFace.length(nbGroup);
for (int i=0;i<nbGroup;i++)
{
GROUP_i * f1=new GROUP_i(gFace[i]);
- SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
- f1->_remove_ref();
- all->groupFace[i] = f2;
+ all->groupFace[i] = f1->POA_SALOME_MED::GROUP::_this();
}
nbGroup = _mesh->getNumberOfGroups(MED_CELL);
for (int i=0;i<nbGroup;i++)
{
GROUP_i * f1=new GROUP_i(gCell[i]);
- SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
- f1->_remove_ref();
- all->groupCell[i] = f2;
+ all->groupCell[i] = f1->POA_SALOME_MED::GROUP::_this();
}
}
for (int i=0;i<nbgroups;i++)
{
GROUP_i * f1=new GROUP_i(groups[i]);
- SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
- f1->_remove_ref();
- myseq[i] = f2;
+ myseq[i] = f1->POA_SALOME_MED::GROUP::_this();
}
}
catch (MEDEXCEPTION &ex)
{
const GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i);
GROUP_i * f1=new GROUP_i(grou);
- SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
- f1->_remove_ref();
- return (SALOME_MED::GROUP::_duplicate(f2));
+ return f1->POA_SALOME_MED::GROUP::_this();
}
catch (MEDEXCEPTION &ex)
{
{
SUPPORT * myNewSupport = _mesh->getBoundaryElements(convertIdlEntToMedEnt(entity));
SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
- SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this() ;
- return (SALOME_MED::SUPPORT::_duplicate(mySupportIOR));
+ return mySupportI->_this();
}
catch (MEDEXCEPTION &ex)
{
ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
::FIELD<double>*f=_mesh->getVolume( myCppSupport);
- FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
- POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
- new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
- SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
- f1->_remove_ref();
- return (SALOME_MED::FIELD::_duplicate(f2));
+ FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+ return medf->_this();
}
catch (MEDEXCEPTION &ex)
{
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
SUPPORT * myNewSupport = _mesh->getSkin(myCppSupport);
SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
- SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this() ;
- return (SALOME_MED::SUPPORT::_duplicate(mySupportIOR));
+ return mySupportI->_this() ;
}
catch (MEDEXCEPTION &ex)
{
ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
::FIELD<double>*f=_mesh->getArea( myCppSupport);
- FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
- POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
- new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
- SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
- f1->_remove_ref();
- return (SALOME_MED::FIELD::_duplicate(f2));
+ FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+ return medf->_this();
}
catch (MEDEXCEPTION &ex)
{
ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
::FIELD<double>*f=_mesh->getLength( myCppSupport);
- FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
- POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
- new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
- SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
- f1->_remove_ref();
- return (SALOME_MED::FIELD::_duplicate(f2));
+ FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+ return medf->_this();
}
catch (MEDEXCEPTION &ex)
{
ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
::FIELD<double>*f=_mesh->getNormal( myCppSupport);
- FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
- POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
- new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
- SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
- f1->_remove_ref();
- return (SALOME_MED::FIELD::_duplicate(f2));
+ FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+ return medf->_this();
}
catch (MEDEXCEPTION &ex)
{
ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
::FIELD<double>*f=_mesh->getBarycenter( myCppSupport);
- FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
- POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
- new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
- SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
- f1->_remove_ref();
- return (SALOME_MED::FIELD::_duplicate(f2));
+ FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
+ return medf->_this();
}
catch (MEDEXCEPTION &ex)
{
}
}
+//=============================================================================
+/*!
+ * CORBA : Servant destruction
+ */
+//=============================================================================
+void MESH_i::release()
+{
+ PortableServer::ObjectId_var oid=_default_POA()->servant_to_id(this);
+ _default_POA()->deactivate_object(oid);
+ _remove_ref();
+}
#include <string>
#include <SALOMEconfig.h>
+#include "SALOMEMultiComm.hxx"
#include CORBA_SERVER_HEADER(MED)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+#include CORBA_SERVER_HEADER(SALOME_Comm)
namespace MEDMEM {
class MESH;
-class MESH_i:
- public POA_SALOME_MED::MESH,
- public PortableServer::RefCountServantBase
-// public SALOME_MED_Component_i
+class MESH_i: public POA_SALOME_MED::MESH,
+ public PortableServer::RefCountServantBase,
+ public SALOMEMultiComm
{
public :
static map < int,::MEDMEM::MESH *> meshMap;
SALOME_MED::double_array* getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
throw (SALOME::SALOME_Exception);
+
+ SALOME::Sender_ptr getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch)
+ throw (SALOME::SALOME_Exception);
CORBA::Double getCoordinate(CORBA::Long Number, CORBA::Long Axis)
throw (SALOME::SALOME_Exception);
SALOME_MED::medEntityMesh entity,
SALOME_MED::medGeometryElement geomElement)
throw (SALOME::SALOME_Exception);
+
+ SALOME::Sender_ptr getSenderForConnectivity(SALOME_MED::medModeSwitch typeSwitch,
+ SALOME_MED::medConnectivity mode,
+ SALOME_MED::medEntityMesh entity,
+ SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
SALOME_MED::long_array* getConnectivityIndex(SALOME_MED::medConnectivity mode,
SALOME_MED::medEntityMesh entity)
SALOME_MED::MESH::connectivityInfos * getConnectGlobal
(SALOME_MED::medEntityMesh entity)
throw (SALOME::SALOME_Exception);
+
+ void release();
};
}
#include "MEDMEM_Support_i.hxx"
#include "MEDMEM_Mesh_i.hxx"
#include "MEDMEM_convert.hxx"
+
+#include "SenderFactory.hxx"
+#include "MultiCommException.hxx"
using namespace MEDMEM;
// Initialisation des variables statiques
all->description = CORBA::string_dup(_support->getDescription().c_str());
const int numberOfTypes = _support->getNumberOfTypes();
all->numberOfGeometricType = numberOfTypes;
+ all->entity = _support->getEntity();
all->types.length(numberOfTypes);
all->nbEltTypes.length(numberOfTypes);
SCRUTE(m1);
SCRUTE(m2);
- m1->_remove_ref();
-
END_OF("SALOME_MED::MESH_ptr SUPPORT_i::getMesh()");
- return (SALOME_MED::MESH::_duplicate(m2));
+ return (m2);
}
catch (MEDEXCEPTION &ex)
{
return myseq._retn();
}
+
+//=============================================================================
+/*!
+ * CORBA: 2nd get Nodes
+ */
+//=============================================================================
+SALOME::Sender_ptr SUPPORT_i::getSenderForNumber(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception)
+{
+ SCRUTE(_support);
+ SCRUTE(geomElement);
+ SCRUTE(convertIdlEltToMedElt(geomElement));
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ SALOME::Sender_ptr ret;
+ try
+ {
+ int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
+ const int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement));
+ ret=SenderFactory::buildSender(*this,numbers,nbelements);
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Unable to access the support optionnal index");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ catch(MultiCommException &ex2)
+ THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
+ return ret;
+}
//=============================================================================
/*!
* CORBA: Global Nodes Index (optionnaly designed by the user)
}
//=============================================================================
+/*!
+ * CORBA: 2nd Global Nodes Index (optionnaly designed by the user)
+ */
+//=============================================================================
+
+SALOME::Sender_ptr SUPPORT_i::getSenderForNumberIndex()
+ throw (SALOME::SALOME_Exception)
+{
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ SALOME::Sender_ptr ret;
+ try
+ {
+ MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
+ int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
+ const int * numbers=_support->getNumberIndex();
+ ret=SenderFactory::buildSender(*this,numbers,nbelements);
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Unable to access the support index");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ catch(MultiCommException &ex2)
+ THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
+ return ret;
+}
+//=============================================================================
/*!
* CORBA:
*/
END_OF(LOC);
}
+
+//=============================================================================
+/*!
+ * CORBA: release <=> remote delete this
+ */
+//=============================================================================
+void SUPPORT_i::release()
+{
+ PortableServer::ObjectId_var oid=_default_POA()->servant_to_id(this);
+ _default_POA()->deactivate_object(oid);
+ _remove_ref();
+}
#include <SALOMEconfig.h>
+#include "SALOMEMultiComm.hxx"
#include CORBA_SERVER_HEADER(MED)
+#include CORBA_SERVER_HEADER(SALOME_Comm)
namespace MEDMEM {
class SUPPORT;
class SALOME_MED::MESH;
-class SUPPORT_i:
- public POA_SALOME_MED::SUPPORT,
- public PortableServer::RefCountServantBase
+class SUPPORT_i: public POA_SALOME_MED::SUPPORT,
+ public PortableServer::RefCountServantBase,
+ public SALOMEMultiComm
{
public :
static map < int,::MEDMEM::SUPPORT *> supportMap;
throw (SALOME::SALOME_Exception);
SALOME_MED::long_array* getNumber(SALOME_MED::medGeometryElement geomElement)
throw (SALOME::SALOME_Exception);
+ SALOME::Sender_ptr getSenderForNumber(SALOME_MED::medGeometryElement geomElement)
+ throw (SALOME::SALOME_Exception);
SALOME_MED::long_array* getNumberIndex()
throw (SALOME::SALOME_Exception);
+ SALOME::Sender_ptr getSenderForNumberIndex()
+ throw (SALOME::SALOME_Exception);
CORBA::Long getNumberOfGaussPoint(SALOME_MED::medGeometryElement geomElement)
throw (SALOME::SALOME_Exception);
SALOME_MED::long_array* getNumbersOfGaussPoint()
SALOME_MED::SUPPORT_ptr myIor)
throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
-
+ void release();
// Cuisine interne
CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception);
SALOME_MED::SUPPORT::supportInfos * getSupportGlobal() throw (SALOME::SALOME_Exception);
MEDMEM_Family_i.hxx \
MEDMEM_FieldDouble_i.hxx \
MEDMEM_FieldInt_i.hxx \
- MEDMEM_FieldOf_i.hxx \
MEDMEM_Field_i.hxx \
MEDMEM_Group_i.hxx \
MEDMEM_Mesh_i.hxx \
LIB=libMEDMEMImpl.la
LIB_SRC = MEDMEM_Med_i.cxx MEDMEM_Family_i.cxx MEDMEM_FieldDouble_i.cxx MEDMEM_FieldInt_i.cxx MEDMEM_Field_i.cxx MEDMEM_Group_i.cxx MEDMEM_Mesh_i.cxx MEDMEM_Support_i.cxx MEDMEM_convert.cxx
LIB_SERVER_IDL = MED.idl
-LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl
+LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_Comm.idl
# Executables targets
BIN_SRC =
CPPFLAGS+= $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
CXXFLAGS+= -I${KERNEL_ROOT_DIR}/include/salome
-LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lmedmem -lOpUtil -L${KERNEL_ROOT_DIR}/lib/salome -lSALOMELocalTrace
+LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lmedmem -lOpUtil -L${KERNEL_ROOT_DIR}/lib/salome -lSALOMELocalTrace -L${KERNEL_ROOT_DIR}/lib/salome -lSALOMELocalTrace -lSalomeCommunication
#LDFLAGS+=-lmedmem -L. -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification
# does we put only -lSalomeContainer and compiler retrieves -lSalomeNS -lRegistry -lOpUtil ????
PyObject *py_list;
const int * connectivity = self->getConnectivity(Mode,ConnectivityType,
Entity,Type);
- int nbOfElm = self->getNumberOfElements(Entity,Type);
- int size;
-
- if (Type == MED_ALL_ELEMENTS)
- {
- size = self->getConnectivityIndex(ConnectivityType,Entity)[nbOfElm]-1;
- }
- else
- {
- size = nbOfElm*(((int) Type)%100);
- }
-
+ int size = self->getConnectivityLength(Mode,ConnectivityType,Entity,Type);
py_list = PyList_New(size);
for (int i=0; i < size; i++)
{
PyObject *py_list;
const int * reverseconnectivity =
self->getReverseConnectivity(ConnectivityType,Entity);
- int spaceDim = self->getSpaceDimension();
- int nb;
-
- if (ConnectivityType == MED_NODAL)
- {
- nb = (self->getNumberOfNodes());
- }
- else
- {
- if (spaceDim == 2)
- nb = (self->getNumberOfElements(MED_EDGE,
- MED_ALL_ELEMENTS));
- else if (spaceDim == 3)
- nb = (self->getNumberOfElements(MED_FACE,
- MED_ALL_ELEMENTS));
- }
-
- int size = self->getReverseConnectivityIndex(ConnectivityType,
- Entity)[nb]-1;
-
+ int size = self->getReverseConnectivityLength(ConnectivityType,Entity);
py_list = PyList_New(size);
for (int i=0; i < size; i++)
{
PyObject *py_list;
const int * reverseconnectivity_index =
self->getReverseConnectivityIndex(ConnectivityType,Entity);
-
- int size;
- int spaceDim = self->getSpaceDimension();
-
- if (ConnectivityType == MED_NODAL)
- {
- size = (self->getNumberOfNodes())+1;
- }
- else
- {
- if (spaceDim == 2)
- size = (self->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS))+1;
- else if (spaceDim == 3)
- size = (self->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS))+1;
- }
-
+ int size=self->getReverseConnectivityIndexLength(ConnectivityType,Entity);
py_list = PyList_New(size);
for (int i=0; i < size; i++)
{
#
# med file list
#
+# from CODE_ASTER
+#
##files.append("maill.0.med")
##meshNameFiles.append("MAILTRQU")
-files.append("maillage_UniSegFam.med")
-meshNameFiles.append("maillage_CHEMVAL_100elts")
-
-##files.append("mesh.med")
-##meshNameFiles.append("Mesh 1")
-
##files.append("zzzz121b.med")
##meshNameFiles.append("MUN")
+#
+# from the SMESH Salome Module
+#
+
+files.append("mesh.med")
+meshNameFiles.append("Mesh 1")
+
+#
+# from other source including LGLS ones
+#
+
+files.append("maillage_UniSegFam.med")
+meshNameFiles.append("maillage_CHEMVAL_100elts")
+
files.append("carre_en_quad4.med")
meshNameFiles.append("carre_en_quad4")
for j in range(nbElemType):
print "Element",(j+1)," ",connectivity[j*nbNodesPerConst:(j+1)*nbNodesPerConst]
- print ""
- print "Show the Face/Edge Reverse Nodal Connectivity:"
- ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL,constituent)
- ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL,constituent)
- print ""
- for j in range(nbNodes):
- begin = ReverseConnectivityIndex[j]-1
- end = ReverseConnectivityIndex[j+1]-1
- print "Node",(j+1),"-->",ReverseConnectivity[begin:end]
-
- print ""
- try:
- print "Show the Face/Edge Descending Connectivity:"
- mesh.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,constituent)
- nbElemts = mesh.getNumberOfElements(constituent,MED_ALL_ELEMENTS)
- Connectivity = mesh.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,constituent,MED_ALL_ELEMENTS)
- ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,constituent)
+ if (meshDim == 3):
print ""
- for j in range(nbElemts):
- begin = ConnectivityIndex[j]-1
- end = ConnectivityIndex[j+1]-1
- print "Element",(j+1),"-->",Connectivity[begin:end]
+ print "Show the Face/Edge Reverse Nodal Connectivity:"
+ ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL,constituent)
+ ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL,constituent)
+ print ""
+ for j in range(nbNodes):
+ begin = ReverseConnectivityIndex[j]-1
+ end = ReverseConnectivityIndex[j+1]-1
+ print "Node",(j+1),"-->",ReverseConnectivity[begin:end]
print ""
- except :
- pass
+ try:
+ print "Show the Face/Edge Descending Connectivity:"
+ mesh.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,constituent)
+ nbElemts = mesh.getNumberOfElements(constituent,MED_ALL_ELEMENTS)
+ Connectivity = mesh.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,constituent,MED_ALL_ELEMENTS)
+ ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,constituent)
+ print ""
+ for j in range(nbElemts):
+ begin = ConnectivityIndex[j]-1
+ end = ConnectivityIndex[j+1]-1
+ print "Element",(j+1),"-->",Connectivity[begin:end]
+
+ print ""
+ except :
+ pass
for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
nbFam = mesh.getNumberOfFamilies(entity)
barycenter.write(idVtk)
print ""
- if spaceDim == 3 :
+ if (spaceDim == 3) and (meshDim == spaceDim) :
print "Getting volume of all Cells of the mesh:"
volume = mesh.getVolume(supportCell)
voltot = 0.
print "but not in vtk format because vtk does not offer the possibility to view a field on edges or faces"
print ""
- elif spaceDim == 2:
+ elif (spaceDim == 2) and (meshDim == spaceDim):
print "Getting area on all Cells of the mesh:"
area = mesh.getArea(supportCell)
areatot = 0.
print ""
print "Building support on Elements of the boundary"
- if spaceDim == 3 :
+ if (spaceDim == 3) and (meshDim == spaceDim) :
suppBound = mesh.getBoundaryElements(MED_FACE)
nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
print "Getting normal field on the boundary",nbElmBound
value3 = normalBoundJ[2]
norm = (value1*value1 + value2*value2 + value3*value3)**(0.5)
print " * ",normalBoundJ[:spaceDim],"norm:",norm
- elif spaceDim == 2:
+ elif (spaceDim == 2) and (meshDim == spaceDim):
suppBound = mesh.getBoundaryElements(MED_EDGE)
nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
print "Getting normal field on the boundary",nbElmBound
@COMMENCE@
-SUBDIRS = MEDMEM MEDMEM_SWIG MEDMEM_I MED MEDGUI MedCorba_Swig MED_SWIG MedClient
+SUBDIRS = MEDMEM MEDMEM_SWIG MEDMEM_I MED MEDGUI MedCorba_Swig MED_SWIG MedClient INTERPOLATION
@MODULE@
#include "UtilClient.hxx"
#include "CONNECTIVITYClient.hxx"
+#include "ReceiverFactory.hxx"
using namespace MEDMEM;
//=============================================================================
/*!
void CONNECTIVITYClient::blankCopy()
{
BEGIN_OF("CONNECTIVITYClient::blankCopy()");
-
- SALOME_MED::MESH::connectivityInfos *all = new SALOME_MED::MESH::connectivityInfos;
+ SALOME_MED::MESH::connectivityInfos_var all;
medEntityMesh Entity = getEntity();
try
{
//_numberOfNodes = IOR_Mesh->getNumberOfNodes();
_numberOfNodes = all->numberOfNodes;
-
+ _entityDimension = all->entityDimension;
medGeometryElement * Types;
long iT, nT;
int kT = Count[iT+1]-Count[iT];
SCRUTE(kT);
- convertCorbaArray(pC, nC, IOR_Mesh->getConnectivity
- (MED_FULL_INTERLACE, MED_NODAL, Entity, T[iT]));
+ pC=(int *)ReceiverFactory::getValue(IOR_Mesh->getSenderForConnectivity(MED_FULL_INTERLACE, MED_NODAL, Entity, T[iT]),nC);
SCRUTE(nC);
ASSERT(nC == (T[iT]%100) * kT);
#include "UtilClient.hxx"
#include "Utils_CorbaException.hxx"
+#include "ReceiverFactory.hxx"
+
using namespace MEDMEM;
//=============================================================================
/*!
std::string *tA;
long nA;
- SALOME_MED::MESH::coordinateInfos *all = new SALOME_MED::MESH::coordinateInfos;
+ SALOME_MED::MESH::coordinateInfos_var all;
try
{
- all= IOR_Mesh->getCoordGlobal();
+ all = IOR_Mesh->getCoordGlobal();
}
catch (const exception & ex)
{
long nN = IOR_Mesh->getNumberOfNodes();
double *tC;
long nC;
- convertCorbaArray(tC, nC, IOR_Mesh->getCoordinates(MED_FULL_INTERLACE));
+ tC=(double *)ReceiverFactory::getValue(IOR_Mesh->getSenderForCoordinates(MED_FULL_INTERLACE),nC);
ASSERT(nC == (getSpaceDimension() * nN));
- MEDARRAY<double> mC(tC, getSpaceDimension(), nN);
- setCoordinates(&mC);
+ MEDARRAY<double> mC(tC, getSpaceDimension(), nN,MED_FULL_INTERLACE,true);
+ setCoordinates(&mC,true);
_complete = true;
-#include "FIELDClient.hxx"
+//#include "ReceiverFactory.hxx"
-using namespace MEDMEM;
+//using namespace MEDMEM;
-//=============================================================================
-/*!
- * Transfert les valeurs du "Champ Corba" dans le "Champ local"
- * (version FIELD<double>)
- */
-//=============================================================================
-void FIELDClient_value(FIELD<double> *F, const SALOME_MED::FIELD_ptr IOR_Field)
+template<class T1,class T2>
+FIELDClient<T1,T2>::FIELDClient(typename T2::_ptr_type ptrCorba,SUPPORT * S):_fieldPtr(T2::_duplicate(ptrCorba)),_ownSupport(false)
{
- BEGIN_OF("FIELDClient_value(double)");
+ if (!S)
+ {
+ _ownSupport=true;
+ S=new SUPPORTClient(_fieldPtr->getSupport());
+ }
+ FIELD<T1>::setSupport(S);
- F->setValueType(MED_REEL64);
+ setName(_fieldPtr->getName());
- const SALOME_MED::FIELDDOUBLE_var IOR_FieldDouble
- = SALOME_MED::FIELDDOUBLE::_narrow(IOR_Field);
- SCRUTE(IOR_FieldDouble);
+ FIELD<T1>::setDescription(_fieldPtr->getDescription());
+ int nc = _fieldPtr->getNumberOfComponents();
+ FIELD<T1>::setNumberOfComponents(nc);
- SALOME_MED::double_array_var v_corba
- = IOR_FieldDouble->getValue(MED_FULL_INTERLACE);
+ FIELD<T1>::setNumberOfValues( S->getNumberOfElements(MED_ALL_ELEMENTS));
- long i, n = v_corba->length();
- SCRUTE(n);
- double *v = new double[n];
+ string * _s = new string[nc];
- for (i=0; i<n; i++) v[i] = v_corba[i];
- MEDARRAY<double> * M = new MEDARRAY<double>
- (v, F->getNumberOfComponents(),F->getNumberOfValues(), MED_FULL_INTERLACE);
- F->setValue(M);
+ SALOME_MED::string_array_var s;
+ s = _fieldPtr->getComponentsNames();
+ for (int i=0; i<nc; i++)
+ _s[i] = s[i];
+ FIELD<T1>::setComponentsNames(_s);
- END_OF("FIELDClient_value(double)");
-}
-
-//=============================================================================
-/*!
- * Transfert les valeurs du "Champ Corba" dans le "Champ local"
- * (version FIELD<int>)
- */
-//=============================================================================
-void FIELDClient_value(FIELD<int> *F, const SALOME_MED::FIELD_ptr IOR_Field)
-{
- BEGIN_OF("FIELDClient_value(int)");
+ s = _fieldPtr->getComponentsDescriptions();
+ for (int i=0; i<nc; i++)
+ _s[i] = s[i];
+ FIELD<T1>::setComponentsDescriptions(_s);
- F->setValueType(MED_INT32);
+ s = _fieldPtr->getComponentsUnits();
+ for (int i=0; i<nc; i++)
+ _s[i] = s[i];
+ FIELD<T1>::setMEDComponentsUnits(_s);
- const SALOME_MED::FIELDINT_var IOR_FieldInt
- = SALOME_MED::FIELDINT::_narrow(IOR_Field);
+ delete [] _s;
- SALOME_MED::long_array_var v_corba
- = IOR_FieldInt->getValue(MED_FULL_INTERLACE);
+// s = _fieldPtr->getComponentsDescriptions();
+// for (int i=0; i<nc; i++)
+// _s[i] = s[i];
+// F->setComponentsDescriptions(_s);
+ setIterationNumber(_fieldPtr->getIterationNumber());
+ setTime(_fieldPtr->getTime());
+ setOrderNumber(_fieldPtr->getOrderNumber());
+ fillCopy();
+}
- long i, n = v_corba->length();
- SCRUTE(n);
- int *v = new int[n];
- for (i=0; i<n; i++) v[i] = v_corba[i];
+template<class T1,class T2>
+void FIELDClient<T1,T2>::fillCopy()
+{
+ //setValueType(typeChamps); WARNING TO DO.....
+ //setValueType(_fieldPtr->getValueType());
+ long n;
+ T1 *v = (T1 *)ReceiverFactory::getValue(_fieldPtr->getSenderForValue(MED_FULL_INTERLACE),n);
+ MEDARRAY<T1> * M = new MEDARRAY<T1>(v, FIELD<T1>::getNumberOfComponents(),FIELD<T1>::getNumberOfValues(),MED_FULL_INTERLACE,true,true);
+ setValue(M);
+}
- MEDARRAY<int> * M = new MEDARRAY<int>
- (v, F->getNumberOfComponents(),F->getNumberOfValues(), MED_FULL_INTERLACE);
- F->setValue(M);
-
- END_OF("FIELDClient_value(int)");
+template<class T1,class T2>
+FIELDClient<T1,T2>::~FIELDClient()
+{
+ _fieldPtr->release();
+ CORBA::release(_fieldPtr);
+ if(_ownSupport)
+ delete FIELD<T1>::_support;
}
+
#include <utilities.h>
#include "MEDMEM_Field.hxx"
#include "SUPPORTClient.hxx"
+#include "ReceiverFactory.hxx"
#include CORBA_CLIENT_HEADER(MED)
-
-
-
-void FIELDClient_value(FIELD<double> *F,
- const SALOME_MED::FIELD_ptr IOR_Field);
-void FIELDClient_value(FIELD<int> *F,
- const SALOME_MED::FIELD_ptr IOR_Field);
-
-
-template <typename T>
-FIELD<T> * FIELDClient(const SALOME_MED::FIELD_ptr IOR_Field,
- SUPPORT * S = NULL)
+//exemple _FIELDClient<double,FIELDDOUBLE_ptr>
+//_FIELDClient<int,FIELDINT_ptr>
+template<class T1,class T2>
+class FIELDClient : public FIELD<T1>
{
- BEGIN_OF("FIELDClient<T>");
-
- if (!S) S = new SUPPORTClient(IOR_Field->getSupport());
-
- FIELD<T> *F = new FIELD<T>();
- F->setSupport(S);
-
- F->setName(IOR_Field->getName());
- SCRUTE(F->getName());
-
- F->setDescription(IOR_Field->getDescription());
- SCRUTE(F->getDescription());
-
- int nc = IOR_Field->getNumberOfComponents();
- F->setNumberOfComponents(nc);
- SCRUTE(F->getNumberOfComponents());
-
- F->setNumberOfValues(nc * S->getNumberOfElements(MED_ALL_ELEMENTS));
- SCRUTE(F->getNumberOfValues());
-
- string * _s = new string[nc];
-
- SALOME_MED::string_array_var s;
-
- s = IOR_Field->getComponentsNames();
- for (int i=0; i<nc; i++)
- _s[i] = s[i];
- F->setComponentsNames(_s);
-
-// s = IOR_Field->getComponentsDescriptions();
-// for (int i=0; i<nc; i++)
-// _s[i] = s[i];
-// F->setComponentsDescriptions(_s);
-
- F->setIterationNumber(IOR_Field->getIterationNumber());
- F->setTime(IOR_Field->getTime());
- F->setOrderNumber(IOR_Field->getOrderNumber());
-
- FIELDClient_value(F, IOR_Field);
-
- END_OF("FIELDClient<T>");
- return F;
-}
+private:
+ typename T2::_ptr_type _fieldPtr;
+ bool _ownSupport;
+public:
+ FIELDClient(typename T2::_ptr_type ptrCorba,SUPPORT * S = NULL);
+ ~FIELDClient();
+private:
+ void fillCopy();
+};
+
+#include "FIELDClient.cxx"
#endif
--- /dev/null
+#include "FIELDDOUBLEClient.hxx"
+
+//=============================================================================
+/*!
+ * Constructor with arguments
+ */
+//=============================================================================
+FIELDDOUBLEClient::FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba,
+ SUPPORT * S) :
+ FIELDClient<double,SALOME_MED::FIELDDOUBLE>(ptrCorba,S)
+{
+ BEGIN_OF("Constructor with arguments (for Python API) FIELDDOUBLEClient");
+
+ END_OF("Constructor with arguments (for Python API) FIELDDOUBLEClient");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+FIELDDOUBLEClient::~FIELDDOUBLEClient()
+{
+ BEGIN_OF("Default Destructor (for Python API) FIELDDOUBLEClient");
+
+ END_OF("Default Destructor (for Python API) FIELDDOUBLEClient");
+}
--- /dev/null
+#ifndef _FIELDDOUBLECLIENT_HXX
+#define _FIELDDOUBLECLIENT_HXX
+
+#include "FIELDClient.hxx"
+
+class FIELDDOUBLEClient :
+ public FIELDClient<double,SALOME_MED::FIELDDOUBLE>
+{
+public:
+ FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba,
+ SUPPORT * S = NULL);
+ ~FIELDDOUBLEClient();
+};
+
+#endif
--- /dev/null
+#include "FIELDINTClient.hxx"
+
+//=============================================================================
+/*!
+ * Constructor with arguments
+ */
+//=============================================================================
+FIELDINTClient::FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba,
+ SUPPORT * S) :
+ FIELDClient<int,SALOME_MED::FIELDINT>(ptrCorba,S)
+{
+ BEGIN_OF("Constructor with arguments (for Python API) FIELDINTClient");
+
+ END_OF("Constructor with arguments (for Python API) FIELDINTClient");
+}
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+FIELDINTClient::~FIELDINTClient()
+{
+ BEGIN_OF("Default Destructor (for Python API) FIELDINTClient");
+
+ END_OF("Default Destructor (for Python API) FIELDINTClient");
+}
--- /dev/null
+#ifndef _FIELDINTCLIENT_HXX
+#define _FIELDINTCLIENT_HXX
+
+#include "FIELDClient.hxx"
+
+class FIELDINTClient :
+ public FIELDClient<int,SALOME_MED::FIELDINT>
+{
+public:
+ FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba,
+ SUPPORT * S = NULL);
+ ~FIELDINTClient();
+};
+
+#endif
void MESHClient::blankCopy()
{
BEGIN_OF("MESHClient::blankCopy()");
- SALOME_MED::MESH::meshInfos * all = new SALOME_MED::MESH::meshInfos;
- all = IOR_Mesh->getMeshGlobal();
+ SALOME_MED::MESH::meshInfos_var all = IOR_Mesh->getMeshGlobal();
//CORBA::String_var s;
//s= IOR_Mesh->getName(); _name = s;
MESHClient::~MESHClient()
{
BEGIN_OF("MESHClient::~MESHClient()");
+ IOR_Mesh->release();
END_OF("MESHClient::~MESHClient()");
}
FAMILYClient.hxx \
GROUPClient.hxx \
FIELDClient.hxx \
+ FIELDClient.cxx \
+ FIELDDOUBLEClient.hxx \
+ FIELDINTClient.hxx \
libMEDClient.i
SWIG_DEF = libMEDClient.i
MESHClient.cxx \
SUPPORTClient.cxx \
FAMILYClient.cxx \
- FIELDClient.cxx \
- GROUPClient.cxx
+ GROUPClient.cxx \
+ FIELDDOUBLEClient.cxx \
+ FIELDINTClient.cxx
LIB_CLIENT_IDL= \
SALOME_Component.idl \
SALOMEDS.idl \
SALOMEDS_Attributes.idl \
SALOME_Exception.idl \
+ SALOME_Comm.idl \
MED.idl
# Executables targets
--- /dev/null
+IDL = TESTMEDCLIENT_Gen.idl
+
+INC_IDL = $(patsubst %.idl,%.hh, $(IDL))
+
+OBJ = TESTMEDCLIENT_GenSK.o TESTMEDCLIENT_Gen_i.o MemorySpy.o
+
+INC = -I$(KERNEL_ROOT_DIR)/include/salome -I$(MED_ROOT_DIR)/include/salome
+
+LINK = -L$(MED_ROOT_DIR)/lib/salome -lmedmem -lMEDClientcmodule -lMedCorba_Swigcmodule
+
+OPT = -D__x86__ -D__linux__ -DPCLINUX -DCOMPAT_DOUBLE_CORBA_DOUBLE
+
+OPTIONIDL = -bcxx -Wbexample
+
+INCIDL= -I$(KERNEL_ROOT_DIR)/idl/salome -I$(MED_ROOT_DIR)/idl/salome
+
+OMNIIDL = omniidl
+
+all : libTESTMEDCLIENTEngine.so TESTMEDCLIENTCatalog.xml pyTESTMEDCLIENT
+
+libTESTMEDCLIENTEngine.so : $(OBJ)
+ g++ -shared $(OBJ) $(LINK) -o $@
+ mv $@ lib/salome
+
+pyTESTMEDCLIENT : TESTMEDCLIENT_Gen.idl
+ omniidl -bpython $(INCIDL) $<
+ rm -rf lib/python2.2/site-packages/salome/*
+ mv SALOME_TESTMEDCLIENT SALOME_TESTMEDCLIENT__POA TESTMEDCLIENT_Gen_idl.py lib/python2.2/site-packages/salome
+
+TESTMEDCLIENTCatalog.xml : TESTMEDCLIENT_Gen.idl
+ omniidl -bIDLparser $(INCIDL) -Wbcatalog=$@,name='TESTMEDCLIENT',username='TESTMEDCLIENT' $^
+ sed -e 's/TESTMEDCLIENT_Gen/TESTMEDCLIENT/g' $@ > toto
+ mv toto ./share/salome/resources/$@
+ rm *.xml
+
+TESTMEDCLIENT_GenSK.o : $(INC_IDL) TESTMEDCLIENT_GenSK.cc
+ g++ -c $(INC) $(OPT) -Wno-deprecated TESTMEDCLIENT_GenSK.cc -o $@
+
+%.o : %.cxx %.hxx $(INC_IDL)
+ g++ -c $(INC) $(OPT) -Wno-deprecated $< -o $@
+
+%.o : %.cc $(INC_IDL)
+ g++ -c $(INC) $(OPT) -Wno-deprecated $< -o $@
+
+%.hh : %.idl
+ $(OMNIIDL) $(OPTIONIDL) $(INCIDL) $<
+
+%.cc : %.idl
+ $(OMNIIDL) $(OPTIONIDL) $(INCIDL) $<
+
+clean:
+ rm -f *.o *.so *.hh *.cc *.xml
--- /dev/null
+#include "MemorySpy.hxx"
+
+#ifdef PCLINUX
+#include <unistd.h>
+#include <string.h>
+
+#define MAXMEM 7
+
+MemorySpy::MemorySpy()
+{
+ _currentPid=getpid();
+ _sizeofPage=getpagesize();
+ char workStr[38];
+ sprintf( workStr, "/proc/%d/statm", _currentPid);
+ _statmFile=fopen ( workStr, "r" );
+}
+
+MemorySpy::~MemorySpy()
+{
+ if(_statmFile)
+ free(_statmFile);
+}
+
+long MemorySpy::getCurrentMemoryUsage()
+{
+ if (!_statmFile)
+ return -1;
+ fseek( _statmFile, 0L, 0 );
+ char workStr[52];
+ if(!fread( workStr, 1, 50, _statmFile ))
+ return -1;
+ return parseString(workStr);
+}
+
+long MemorySpy::parseString(char* line)
+{
+ char *po, *po2,hstr[0x100];
+ int i;
+ long tab[MAXMEM];
+
+ memset( hstr, 0, sizeof( hstr ));
+ po2 = hstr;
+ po = line;
+ i = 0;
+ while ( *po != 0x0 )
+ {
+ if ( ( *po != 0x20 ) )
+ {
+ *po2 = *po;
+ po++;
+ po2++;
+ }
+ else
+ {
+ tab[i] = atol( hstr ) * _sizeofPage;
+ i++;
+ memset( hstr, 0, sizeof( hstr ));
+ while ( *po != 0x0 )
+ {
+ if ( ( *po != 0x20 )&&( *po != '\n' ) )
+ break;
+ po++;
+ }
+ po2 = hstr;
+ }
+ }
+ if ( strlen( hstr ) != 0 )
+ {
+ tab[i] = atol( hstr ) * _sizeofPage;
+ }
+ return tab[0];
+}
+#endif
+
+#ifdef HP
+#include <sys/param.h>
+#include <sys/pstat.h>
+#include <sys/unistd.h>
+
+MemorySpy::MemorySpy()
+{
+}
+
+MemorySpy::~MemorySpy()
+{
+}
+
+long MemorySpy::getCurrentMemoryUsage()
+{
+ struct pst_dynamic dyn;
+ if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1)
+ return -1;
+ else {
+ return dyn.psd_vm * getpagesize();
+}
+#endif
--- /dev/null
+#ifndef __MEMORYSPY_HXX__
+#define __MEMORYSPY_HXX__
+
+#include <stdio.h>
+#include <stdlib.h>
+
+class MemorySpy
+{
+public:
+ MemorySpy();
+ ~MemorySpy();
+ long getCurrentMemoryUsage();
+#ifdef PCLINUX
+ //SOLARIS
+private:
+ long parseString(char* line);
+private:
+ int _currentPid;
+ long _sizeofPage;
+ FILE *_statmFile;
+#endif
+};
+
+#endif
+
--- /dev/null
+TEST en construction...
+
+TEST des classes MedClient :
+----------------------------
+
+- FieldClient
+- MeshClient
+- SupportClient
+- FamilyClient
+- GroupClient
+
+Le test utilise un composant nommé TESTMEDCLIENT qui tire à distance sur des objets MEDMEM en utilisant les classes MedClient.
+
+Le test repose sur l'echange d'information entre le composant MED et le composant TESTMEDClient.
+
+Les objets MEDMEM (Mesh, Field, Support), plus ou moins volumineux, sont obtenus à partir des executables de générations de fichiers MED.
+Ces executables sont abetenus apres compilation des fichiers :
+ - create_mesh_c2q4.c
+ - create_mesh_c2t3.c
+ - create_mesh_c3h8.c
+ - create_mesh_c2t4.c
+
+Le test chasse les fuites mémoires grace à un espion de mémoire dont le code est contenu dans :
+ - MemorySpy.hxx
+ - MemorySpy.cxx
+
+Le code du composant se trouve dans les fichiers :
+ - TESTMEDCLIENT_Gen.idl
+ - TESTMEDCLIENT_Gen_i.hxx
+ - TESTMEDCLIENT_Gen_i.cxx
+
+Le lancement du test est effectué par le script python :
+ - test_medclient.py
+
+Enfin MakefileForTest est une ébauche de Makefile nécessaire pour compiler completement le nouveau composant.
\ No newline at end of file
#include "UtilClient.hxx"
#include "SUPPORTClient.hxx"
#include "MESHClient.hxx"
+#include "ReceiverFactory.hxx"
using namespace MEDMEM;
SUPPORTClient::SUPPORTClient(const SALOME_MED::SUPPORT_ptr S,
MESH * M) :
SUPPORT(),
- IOR_Support(SALOME_MED::SUPPORT::_duplicate(S))
+ IOR_Support(SALOME_MED::SUPPORT::_duplicate(S)),
+ _ownMesh(false)
{
BEGIN_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)");
SCRUTE(S);
SCRUTE(M);
-
- setMesh(M ? M : new MESHClient(IOR_Support->getMesh()));
-
+ if(M)
+ _mesh=M;
+ else
+ {
+ _mesh=new MESHClient(IOR_Support->getMesh());
+ _ownMesh=true;
+ }
blankCopy();
END_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)");
try
{
- SALOME_MED::SUPPORT::supportInfos *all = new SALOME_MED::SUPPORT::supportInfos;
- all= IOR_Support->getSupportGlobal();
+ SALOME_MED::SUPPORT::supportInfos_var all = IOR_Support->getSupportGlobal();
_name = all->name;
_description = all->description;
nE[i] = all->nbEltTypes[i];
}
setNumberOfElements(nE);
+
+ delete [] nE;
+
SCRUTE(_totalNumberOfElements);
_complete_support = false;
}
if (!_complete_support) {
- int * index, * value;
+ const int * index, * value;
long n_index, n_value;
- convertCorbaArray(value, n_value,
- IOR_Support->getNumber(MED_ALL_ELEMENTS));
- convertCorbaArray(index, n_index,
- IOR_Support->getNumberIndex());
+ value=(const int *)ReceiverFactory::getValue(IOR_Support->getSenderForNumber(MED_ALL_ELEMENTS),n_value);
+ index=(const int *)ReceiverFactory::getValue(IOR_Support->getSenderForNumberIndex(),n_index);
SCRUTE(n_index);
SCRUTE(n_value);
- setNumber(index, value);
-
- delete [] index;
- delete [] value;
+ setNumber(index, value,true);
_complete_support = true;
}
SUPPORTClient::~SUPPORTClient()
{
BEGIN_OF("SUPPORTClient::~SUPPORTClient");
-
+ IOR_Support->release();
+ if(_ownMesh)
+ delete _mesh;
END_OF("SUPPORTClient::~SUPPORTClient");
}
const SALOME_MED::SUPPORT_var IOR_Support;
+ bool _ownMesh;
+
mutable bool _complete_support;
public :
--- /dev/null
+#ifndef _TESTMEDCLIENT_GEN_IDL_
+#define _TESTMEDCLIENT_GEN_IDL_
+
+#include "SALOME_Exception.idl"
+#include "SALOME_Component.idl"
+#include "SALOMEDS.idl"
+#include "MED.idl"
+
+module SALOME_TESTMEDCLIENT
+{
+ interface TESTMEDCLIENT_Gen : Engines::Component
+ {
+ void go(in SALOME_MED::MED objMed);
+ void go2(in SALOME_MED::MED objMed);
+ };
+};
+
+#endif
--- /dev/null
+#define private public
+#define protected public
+#include "TESTMEDCLIENT_Gen_i.hxx"
+#include "MESHClient.hxx"
+#include "FIELDClient.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Field.hxx"
+
+#include "MEDMEM_Family.hxx"
+#include "FAMILYClient.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Array.hxx"
+#include "MEDMEM_PointerOf.hxx"
+
+#include "MemorySpy.hxx"
+
+using namespace std;
+
+extern "C"
+{
+ PortableServer::ObjectId *TESTMEDCLIENTEngine_factory(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName)
+ {
+ TESTMEDCLIENT_Gen_i *ret=new TESTMEDCLIENT_Gen_i(orb,poa,contId,instanceName,interfaceName);
+ return ret->getId();
+ }
+}
+
+TESTMEDCLIENT_Gen_i::TESTMEDCLIENT_Gen_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName):Engines_Component_i(orb,poa,contId,instanceName,interfaceName)
+{
+ _thisObj = this ;
+ _id = _poa->activate_object(_thisObj);
+}
+
+TESTMEDCLIENT_Gen_i::~TESTMEDCLIENT_Gen_i()
+{
+}
+
+void TESTMEDCLIENT_Gen_i::go(SALOME_MED::MED_ptr objMed)
+{
+ cerr << "Begin of test 1" << endl;
+ SALOME_MED::MESH_ptr maillagePtr=objMed->getMeshByName("CUBE_EN_HEXA8_QUAD4");
+ MESHClient mesh(maillagePtr);
+ maillagePtr->setProtocol(SALOME::SOCKET_);
+ mesh.fillCopy();
+
+ long n=mesh.getNumberOfNodes();
+ long dim=mesh.getMeshDimension();
+ cout << "Mesh nodes nb :" << n << " dim : " << dim << endl;
+ const double *tabRet=mesh.getCoordinates(MED_NO_INTERLACE);
+ for(int k=0;k<n;k++)
+ {
+ for(int l=0;l<dim;l++)
+ cout << *(tabRet++) << " ";
+ cout << endl;
+ }
+ int nbOfElt=mesh.getNumberOfTypes(MED_FACE);
+ cout << "____" << nbOfElt << endl;
+ SUPPORT* sup1=new SUPPORT(&mesh,"MonSup",MED_FACE);
+ nbOfElt=sup1->getNumberOfElements(MED_QUAD4);
+ FIELD<double>* fd=mesh.getArea(sup1);
+ delete sup1;
+ int nbOfVal=fd->getNumberOfValues();
+ int nbOfCpt=fd->getNumberOfComponents();
+ cout << "nbOfVal " << nbOfVal << " nbOfCpt " << nbOfCpt << endl;
+ const double *tabAera=fd->getValue(MED_NO_INTERLACE);
+ for(int m=0;m<nbOfVal;m++)
+ cout << "Aera " << m << " = " << tabAera[m] << endl;
+ delete fd;
+
+ const vector<FAMILY*> fams=mesh.getFamilies(MED_FACE);
+ cout << "Nb Of FACES families :" << fams.size() << " " << mesh.getNumberOfFamilies(MED_FACE) << endl;
+ MEDSKYLINEARRAY *numb=fams[0]->getnumber();
+ cout << "const MEDSKYLINEARRAY *numb" << endl;
+ cout << "Length of : " << numb->getLength() << endl;
+ const int *vec2=numb->getValue();
+ for(int m=0;m<numb->getLength();m++)
+ {
+ cout << vec2[m] << " " << endl;
+ }
+ const vector<GROUP*> groups=mesh.getGroups(MED_FACE);
+ cout << "Nb Of FACES groups :" << groups.size() << endl;
+ const int * tabConec=mesh.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_FACE,MED_QUAD4);
+ for(int p=0;p<nbOfElt;p++){
+ for(int p1=0;p1<4;p1++)
+ {
+ cout << tabConec[4*p+p1] << " ";
+ }
+ cout << endl;
+ }
+ cout << endl;
+
+
+ SALOME_MED::string_array* strArray=objMed->getFieldNames();
+ for(int r=0;r<strArray->length();r++)
+ cout << (*strArray)[r] << endl;
+ SALOME_MED::FIELD_var myField=objMed->getField((*strArray)[1],2,-1);
+ if(myField==SALOME_MED::FIELD::_nil())
+ cout << "big problem ... " << endl;
+ SALOME_MED::FIELDDOUBLE_ptr myFieldD=SALOME_MED::FIELDDOUBLE::_narrow(myField);
+ if(myFieldD==SALOME_MED::FIELDDOUBLE::_nil())
+ cout << "not fielddouble " << (*strArray)[1] << endl;
+ FIELDClient<double,SALOME_MED::FIELDDOUBLE_ptr> myFieldDouble(myFieldD);
+ delete strArray;
+ const SUPPORT *supField=myFieldDouble.getSupport();
+ int nbOfValField=supField->getNumberOfElements(MED_NONE);
+
+ const double * values = myFieldDouble.getValue(MED_FULL_INTERLACE);
+ for(int r2=0;r2<myFieldDouble.getNumberOfComponents()*nbOfValField;r2++)
+ cout << values[r2] << " ";
+ cout << endl;
+}
+
+void TESTMEDCLIENT_Gen_i::go2(SALOME_MED::MED_ptr objMed)
+{
+ cerr << "Begin of test 2" << endl;
+ SALOME_MED::string_array_var strA=objMed->getMeshNames();
+ cout << strA[0] << endl;
+ SALOME_MED::MESH_ptr maillagePtr;
+ MemorySpy spy;
+ cout << "Mem0 : " << spy.getCurrentMemoryUsage() << endl;
+ maillagePtr=objMed->getMeshByName("cube_tetra4");
+ MESHClient* mesh=new MESHClient(maillagePtr);
+ cout << "Mem1 : " << spy.getCurrentMemoryUsage() << endl;
+ mesh->fillCopy();
+ cout << "Mem2 : " << spy.getCurrentMemoryUsage() << endl;
+ delete mesh;
+ cout << "Mem3 : " << spy.getCurrentMemoryUsage() << endl;
+ SALOME_MED::string_array_var strB=objMed->getFieldNames();
+ cout << "________________" << endl;
+ cout << "il y a " << strB->length() << " champs" << endl;
+ for(int i=0;i<strB->length();i++)
+ cout << strB[i] << endl;
+ cout << "Field beeing get " << strB[0] << endl;
+ SALOME_MED::FIELD_var myField=objMed->getField(strB[0],-1,-1);
+ SALOME_MED::FIELDDOUBLE_ptr myFieldD=SALOME_MED::FIELDDOUBLE::_narrow(myField);
+ if(myFieldD==SALOME_MED::FIELDDOUBLE::_nil())
+ cout << "not fielddouble " << strB[0] << endl;
+ else
+ cout << "Field " << strB[0] << " is double" << endl;
+ //myFieldD->setProtocol(SALOME::MPI_);
+ FIELDClient<double,SALOME_MED::FIELDDOUBLE_ptr> *myFieldDouble=new FIELDClient<double,SALOME_MED::FIELDDOUBLE_ptr>(myFieldD);
+ cout << "Mem3bis : " << spy.getCurrentMemoryUsage() << endl;
+ const SUPPORT *supField=myFieldDouble->getSupport();
+ int nbOfValField=supField->getNumberOfElements(MED_TETRA4);
+
+ cout << "Mem4 : " << spy.getCurrentMemoryUsage() << endl;
+ const double * values = myFieldDouble->getValue(MED_FULL_INTERLACE);
+// values= myFieldDouble->getValue(MED_FULL_INTERLACE);
+// const MEDARRAY<double>* valAr=myFieldDouble->getvalue();
+// double* ptOf=valAr->_valuesNo._pointer;
+// double* ptOf2=valAr->_valuesFull._pointer;
+ cout << "Mem5 : " << spy.getCurrentMemoryUsage() << " -- " << myFieldDouble->getNumberOfComponents() << " " << nbOfValField << endl;
+// cout << valAr->_ldValues << " " << valAr->_lengthValues << endl;
+ for(int r2=0;r2<myFieldDouble->getNumberOfComponents()*nbOfValField;r2++)
+ {
+// for(int r2j=0;r2j<nbOfValField;r2j++)
+ {
+// cout << ptOf2[r2j*3+r2i] << " " << ptOf[r2i*nbOfValField+r2j] << " | ";
+ double val = values[r2];
+ if ( (val < 1.0) || (val > 100.0))
+ cout << val << " ";
+ }
+ }
+ delete myFieldDouble;
+ cout << "Mem6 : " << spy.getCurrentMemoryUsage() << endl;
+}
--- /dev/null
+#ifndef _TESTMEDCLIENT_GEN_I_HXX_
+#define _TESTMEDCLIENT_GEN_I_HXX_
+
+#include <TESTMEDCLIENT_Gen.hh>
+#include <iostream.h>
+#include "SALOME_Component_i.hxx"
+
+class TESTMEDCLIENT_Gen_i :
+ public virtual POA_SALOME_TESTMEDCLIENT::TESTMEDCLIENT_Gen,
+ public virtual Engines_Component_i
+{
+public:
+ TESTMEDCLIENT_Gen_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName);
+ virtual ~TESTMEDCLIENT_Gen_i();
+
+ void go(SALOME_MED::MED_ptr objMed);
+ void go2(SALOME_MED::MED_ptr objMed);
+};
+
+#endif
--- /dev/null
+/*
+ creation d'une geometrie 2d : un cube [0,1]^2
+ maillé uniformement en quadrangle reguliers;
+ avec n (=argv[1]) noeuds dans chaque direction.
+ 2 champs:
+ - DbleVectNode champ vectoriel reel sur les noeuds
+ - DbleVectCell champ vectoriel reel sur les cellules
+
+ En sortie, il y aura production d'un fichier MED
+ carre_quad4_n.med qui contiendra un seul maillage et 2 champs
+ avec une seule famille la FAMILLE_0
+*/
+
+#include <med.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <time.h>
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "carre_quad4";
+ med_int mdim = 2;
+ int nnoe_dir;
+ int nelt_dir;
+ med_int nnoe;
+ int i, j, ij;
+
+ med_float * coo;
+ med_int * numnoe;
+ med_int * nufano;
+
+ med_float hxsize;
+ med_float hysize;
+
+ med_float * DbleVectNode;
+ med_float * DbleVectCell;
+
+ time_t t1;
+
+ /*
+ Le maillage
+ */
+
+ char nomcoo[2*MED_TAILLE_PNOM+1] = "x y ";
+ char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm ";
+ /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+
+ med_int nquad4;
+ med_int * quad4;
+ med_int * numquad4;
+ med_int * nufaquad4;
+ /* char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 ";*/
+ char * nomquad4;
+ int indexN1, indexN2, indexN3, indexN4;
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int nfame = 0;
+ int nfamn = 0;
+
+ char MedFile[100] = "carre_quad4_";
+ char buff[100];
+
+ /*
+ Les champs
+ */
+
+ char champDbleVectNode[MED_TAILLE_NOM+1] = "DbleVectNode";
+ char compDbleVectNode[MED_TAILLE_PNOM*2+1] = "comp1 comp2 " ;
+ char unitDbleVectNode[MED_TAILLE_PNOM*2+1] = "unit1 unit2 " ;
+
+ char champDbleVectCell[MED_TAILLE_NOM+1] = "DbleVectCell";
+ char compDbleVectCell[MED_TAILLE_PNOM*2+1] = "comp1 comp2 " ;
+ char unitDbleVectCell[MED_TAILLE_PNOM*2+1] = "unit1 unit2 " ;
+
+ if (argc != 2)
+ {
+ printf("Usage: %s <n> \n",argv[0]);
+ printf(" where\n");
+ printf(" - n is the number of nodes in each direction.\n");
+ printf("\n");
+ printf("This program will produce a MED file carre_quad4_n.med\n");
+ exit(0);
+ }
+
+ nnoe_dir = atoi(argv[1]);
+ nelt_dir = nnoe_dir-1;
+ nnoe = nnoe_dir*nnoe_dir;
+
+ coo = malloc(mdim*nnoe*sizeof(med_float));
+ numnoe = malloc(nnoe*sizeof(med_int));
+ nufano = malloc(nnoe*sizeof(med_int));
+ nomnoe = malloc((MED_TAILLE_PNOM*nnoe+1)*sizeof(char));
+
+ hxsize = 1./((med_float) (nnoe_dir - 1));
+ hysize = hxsize;
+
+ nquad4 = nelt_dir*nelt_dir;
+ quad4 = malloc(4*nquad4*sizeof(med_int));
+ numquad4 = malloc(nquad4*sizeof(med_int));
+ nufaquad4 = malloc(nquad4*sizeof(med_int));
+ nomquad4 = malloc((MED_TAILLE_PNOM*nquad4+1)*sizeof(char));
+
+ DbleVectNode = malloc(mdim*nnoe*sizeof(med_float));
+ DbleVectCell = malloc(mdim*nquad4*sizeof(med_float));
+
+ /*
+ les noeuds:
+ */
+
+ for(j=0;j<nnoe_dir;j++)
+ {
+ for (i=0;i<nnoe_dir;i++)
+ {
+ int ij = j*nnoe_dir+i;
+
+ numnoe[ij] = ij+1;
+ nufano[ij] = 0;
+
+ coo[mdim*ij] = ((med_float) i)*hxsize;
+ coo[mdim*ij+1] = ((med_float) j)*hysize;
+
+ /*
+ printf("Coordonnées %d X = %lf Y = %lf\n",(ij+1),coo[mdim*ij],coo[mdim*ij+1]);
+ */
+ }
+ }
+
+ /*
+ les elements:
+ */
+
+ for(j=0;j<nelt_dir;j++)
+ {
+ for (i=0;i<nelt_dir;i++)
+ {
+ int ij = j*nelt_dir+i;
+
+ numquad4[ij] = ij+1;
+ nufaquad4[ij] = 0;
+
+ indexN4 = j*nnoe_dir+i+1;
+ indexN3 = indexN4+1;
+ indexN1 = indexN4+nnoe_dir;
+ indexN2 = indexN3+nnoe_dir;
+
+ quad4[4*ij] = indexN1;
+ quad4[4*ij+1] = indexN2;
+ quad4[4*ij+2] = indexN3;
+ quad4[4*ij+3] = indexN4;
+
+ /*
+ printf("Connectivitée %d i1 = %d i2 = %d i3 = %d i4 = %d\n",(ij+1),quad4[4*ij],quad4[4*ij+1],quad4[4*ij+2],quad4[4*ij+3]);
+ */
+
+ }
+ }
+
+ /*
+ Les champs
+ */
+
+ (void) time(&t1);
+
+ srand((int) t1); /* use time in seconds to set seed */
+
+ for(i=0;i<nnoe;i++)
+ {
+ DbleVectNode[mdim*i] =
+ (med_float) (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectNode[mdim*i+1] =
+ (med_float) (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ /*
+ printf("i %d DbleVectNode %lf %lf\n",i,DbleVectNode[mdim*i],
+ DbleVectNode[mdim*i+1]);
+ */
+ }
+
+ for(i=0;i<nquad4;i++)
+ {
+ DbleVectCell[mdim*i] =
+ (med_float) (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectCell[mdim*i+1] =
+ (med_float) (1+(int) (1000*rand()/(RAND_MAX+1.0)));
+
+ /*
+ printf("i %d DbleVectCell %lf %lf\n",i,DbleVectCell[mdim*i],
+ DbleVectCell[mdim*i+1]);
+ */
+ }
+
+ /***************************************************************************/
+
+ sprintf(buff,"%d",nnoe_dir);
+ strcat(MedFile,buff);
+ strcat(MedFile,".med");
+
+ fid = MEDouvrir(MedFile,MED_REMP);
+
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim);
+ printf("%d\n",ret);
+
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe,MED_ECRI);
+ printf("%d\n",ret);
+
+ /*
+ ecriture des mailles MED_QUAD4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles
+ */
+
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
+ nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
+ MED_MAILLE,MED_QUAD4,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /*
+ Les Champs
+ */
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champDbleVectNode,MED_REEL64,compDbleVectNode,
+ unitDbleVectNode,mdim);
+
+ printf("MEDchampCr DbleVectNode : %d \n",ret);
+
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champDbleVectNode,
+ (unsigned char *)DbleVectNode,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr DbleVectNode : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champDbleVectCell,MED_REEL64,compDbleVectCell,
+ unitDbleVectCell,mdim);
+
+ printf("MEDchampCr DbleVectCell : %d \n",ret);
+
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champDbleVectCell,
+ (unsigned char *)DbleVectCell,
+ MED_NO_INTERLACE, nquad4,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_QUAD4, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr DbleVectCell : %d \n",ret);
+ }
+ }
+
+ /***************************************************************************/
+
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+ free(coo);
+ free(numnoe);
+ free(nufano);
+ free(nomnoe);
+ free(quad4);
+ free(numquad4);
+ free(nufaquad4);
+ free(nomquad4);
+ free(DbleVectNode);
+ free(DbleVectCell);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ creation d'une geometrie 2d : un cube [0,1]^2
+ maillé uniformement en triangles reguliers;
+ avec n (=argv[1]) noeuds dans chaque direction.
+ 2 champs:
+ - DbleVectNode champ vectoriel reel sur les noeuds
+ - DbleVectCell champ vectoriel reel sur les cellules
+
+ En sortie, il y aura production d'un fichier MED
+ carre_tria3_n.med qui contiendra un seul maillage et 2 champs
+ avec une seule famille la FAMILLE_0
+*/
+
+#include <med.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <time.h>
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "carre_tria3";
+ med_int mdim = 2;
+ int nnoe_dir;
+ int nelt_dir;
+ med_int nnoe;
+ int i, j, ij;
+
+ med_float * coo;
+ med_int * numnoe;
+ med_int * nufano;
+
+ med_float hxsize;
+ med_float hysize;
+
+ med_float * DbleVectNode;
+ med_float * DbleVectCell;
+
+ time_t t1;
+
+ /*
+ Le maillage
+ */
+
+ char nomcoo[2*MED_TAILLE_PNOM+1] = "x y ";
+ char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm ";
+ /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+
+ med_int ntria3;
+ med_int * tria3;
+ med_int * numtria3;
+ med_int * nufatria3;
+ char * nomtria3;
+ int indexN1, indexN2, indexN3, indexN4;
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int nfame = 0;
+ int nfamn = 0;
+
+ char MedFile[100] = "carre_tria3_";
+ char buff[100];
+
+ /*
+ Les champs
+ */
+
+ char champDbleVectNode[MED_TAILLE_NOM+1] = "DbleVectNode";
+ char compDbleVectNode[MED_TAILLE_PNOM*2+1] = "comp1 comp2 " ;
+ char unitDbleVectNode[MED_TAILLE_PNOM*2+1] = "unit1 unit2 " ;
+
+ char champDbleVectCell[MED_TAILLE_NOM+1] = "DbleVectCell";
+ char compDbleVectCell[MED_TAILLE_PNOM*2+1] = "comp1 comp2 " ;
+ char unitDbleVectCell[MED_TAILLE_PNOM*2+1] = "unit1 unit2 " ;
+
+ if (argc != 2)
+ {
+ printf("Usage: %s <n> \n",argv[0]);
+ printf(" where\n");
+ printf(" - n is the number of nodes in each direction.\n");
+ printf("\n");
+ printf("This program will produce a MED file carre_tria3_n.med\n");
+ exit(0);
+ }
+
+ nnoe_dir = atoi(argv[1]);
+ nelt_dir = nnoe_dir-1;
+ nnoe = nnoe_dir*nnoe_dir;
+
+ coo = malloc(mdim*nnoe*sizeof(med_float));
+ numnoe = malloc(nnoe*sizeof(med_int));
+ nufano = malloc(nnoe*sizeof(med_int));
+ nomnoe = malloc((MED_TAILLE_PNOM*nnoe+1)*sizeof(char));
+
+ hxsize = 1./((med_float) (nnoe_dir - 1));
+ hysize = hxsize;
+
+ ntria3 = 2*nelt_dir*nelt_dir;
+ tria3 = malloc(3*ntria3*sizeof(med_int));
+ numtria3 = malloc(ntria3*sizeof(med_int));
+ nufatria3 = malloc(ntria3*sizeof(med_int));
+ nomtria3 = malloc((MED_TAILLE_PNOM*ntria3+1)*sizeof(char));
+
+ DbleVectNode = malloc(mdim*nnoe*sizeof(med_float));
+ DbleVectCell = malloc(mdim*ntria3*sizeof(med_float));
+
+ /*
+ les noeuds:
+ */
+
+ for(j=0;j<nnoe_dir;j++)
+ {
+ for (i=0;i<nnoe_dir;i++)
+ {
+ int ij = j*nnoe_dir+i;
+
+ numnoe[ij] = ij+1;
+ nufano[ij] = 0;
+
+ coo[mdim*ij] = ((med_float) i)*hxsize;
+ coo[mdim*ij+1] = ((med_float) j)*hysize;
+
+ /*
+ printf("Coordonnées %d X = %lf Y = %lf\n",(ij+1),coo[mdim*ij],coo[mdim*ij+1]);
+ */
+ }
+ }
+
+ /*
+ les elements:
+ */
+
+ for(j=0;j<nelt_dir;j++)
+ {
+ for (i=0;i<nelt_dir;i++)
+ {
+ int ij = j*nelt_dir+i;
+ int ij1 = 2*ij;
+ int ij2 = ij1+1;
+
+ numtria3[ij1] = ij1+1;
+ numtria3[ij2] = ij2+1;
+
+ nufatria3[ij1] = 0;
+ nufatria3[ij2] = 0;
+
+ indexN4 = j*nnoe_dir+i+1;
+ indexN3 = indexN4+1;
+ indexN1 = indexN4+nnoe_dir;
+ indexN2 = indexN3+nnoe_dir;
+
+ tria3[3*ij1] = indexN1;
+ tria3[3*ij1+1] = indexN2;
+ tria3[3*ij1+2] = indexN3;
+
+ tria3[3*ij2] = indexN1;
+ tria3[3*ij2+1] = indexN3;
+ tria3[3*ij2+2] = indexN4;
+ }
+ }
+
+ /*
+ for (i=0;i<ntria3;i++)
+ {
+ printf("Connectivitée %d i1 = %d i2 = %d i3 = %d\n",(i+1),tria3[3*i],tria3[3*i+1],tria3[3*i+2]);
+ }
+ */
+
+ /*
+ Les champs
+ */
+
+ (void) time(&t1);
+
+ srand((int) t1); /* use time in seconds to set seed */
+
+ for(i=0;i<nnoe;i++)
+ {
+ DbleVectNode[mdim*i] =
+ (med_float) (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectNode[mdim*i+1] =
+ (med_float) (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ /*
+ printf("i %d DbleVectNode %lf %lf\n",i,DbleVectNode[mdim*i],
+ DbleVectNode[mdim*i+1]);
+ */
+ }
+
+ for(i=0;i<ntria3;i++)
+ {
+ DbleVectCell[mdim*i] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectCell[mdim*i+1] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ /*
+ printf("i %d DbleVectCell %lf %lf\n",i,DbleVectCell[mdim*i],
+ DbleVectCell[mdim*i+1]);
+ */
+ }
+
+ /***************************************************************************/
+
+ sprintf(buff,"%d",nnoe_dir);
+ strcat(MedFile,buff);
+ strcat(MedFile,".med");
+
+ fid = MEDouvrir(MedFile,MED_REMP);
+
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim);
+ printf("%d\n",ret);
+
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe,MED_ECRI);
+ printf("%d\n",ret);
+
+ /*
+ ecriture des mailles MED_TRIA3 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles
+ */
+
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,tria3,MED_FULL_INTERLACE,
+ nomtria3,MED_FAUX,numtria3,MED_VRAI,nufatria3,ntria3,
+ MED_MAILLE,MED_TRIA3,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /*
+ Les Champs
+ */
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champDbleVectNode,MED_REEL64,compDbleVectNode,
+ unitDbleVectNode,mdim);
+
+ printf("MEDchampCr DbleVectNode : %d \n",ret);
+
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champDbleVectNode,
+ (unsigned char *)DbleVectNode,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr DbleVectNode : %d \n",ret);
+ }
+ }
+
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champDbleVectCell,MED_REEL64,compDbleVectCell,
+ unitDbleVectCell,mdim);
+
+ printf("MEDchampCr DbleVectCell : %d \n",ret);
+
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champDbleVectCell,
+ (unsigned char *)DbleVectCell,
+ MED_NO_INTERLACE, ntria3,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_TRIA3, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr DbleVectCell : %d \n",ret);
+ }
+ }
+
+ /***************************************************************************/
+
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+ free(coo);
+ free(numnoe);
+ free(nufano);
+ free(nomnoe);
+ free(tria3);
+ free(numtria3);
+ free(nufatria3);
+ free(nomtria3);
+ free(DbleVectNode);
+ free(DbleVectCell);
+
+ return 0;
+}
--- /dev/null
+/*
+ creation d'une geometrie 3d : un cube [0,1]^3
+ maillé uniformement en hexahedres reguliers;
+ avec n (=argv[1]) noeuds dans chaque direction.
+ 2 champs:
+ - DbleVectNode champ vectoriel reel sur les noeuds
+ - DbleVectCell champ vectoriel reel sur les cellules
+
+ En sortie, il y aura production d'un fichier MED
+ cube_hexa8_n.med qui contiendra un seul maillage et 2 champs
+ avec une seule famille la FAMILLE_0
+*/
+
+#include <med.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <time.h>
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "cube_hexa8";
+ med_int mdim = 3;
+
+ int nnoe_dir;
+ int nelt_dir;
+ med_int nnoe;
+ int i, j, k, ijk;
+
+ med_float * coo;
+ med_int * numnoe;
+ med_int * nufano;
+
+ med_float hxsize;
+ med_float hysize;
+ med_float hzsize;
+
+ med_float * DbleVectNode;
+ med_float * DbleVectCell;
+
+ time_t t1;
+
+ /*
+ Le maillage
+ */
+
+ char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z ";
+ char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm ";
+ /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+
+ med_int nhexa8;
+ med_int * hexa8;
+ med_int * numhexa8;
+ med_int * nufahexa8;
+
+ char * nomhexa8;
+ int indexN1, indexN2, indexN3, indexN4, indexN5, indexN6, indexN7, indexN8;
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int nfame = 0;
+ int nfamn = 0;
+
+ char MedFile[100] = "cube_hexa8_";
+ char buff[100];
+
+ /*
+ Les champs
+ */
+
+ char champDbleVectNode[MED_TAILLE_NOM+1] = "DbleVectNode";
+ char compDbleVectNode[MED_TAILLE_PNOM*3+1] = "comp1 comp2 comp3 " ;
+ char unitDbleVectNode[MED_TAILLE_PNOM*3+1] = "unit1 unit2 unit3 " ;
+
+ char champDbleVectCell[MED_TAILLE_NOM+1] = "DbleVectCell";
+ char compDbleVectCell[MED_TAILLE_PNOM*3+1] = "comp1 comp2 comp3 " ;
+ char unitDbleVectCell[MED_TAILLE_PNOM*3+1] = "unit1 unit2 unit3 " ;
+
+ if (argc != 2)
+ {
+ printf("Usage: %s <n> \n",argv[0]);
+ printf(" where\n");
+ printf(" - n is the number of nodes in each direction.\n");
+ printf("\n");
+ printf("This program will produce a MED file cube_hexa8_n.med\n");
+ exit(0);
+ }
+
+ nnoe_dir = atoi(argv[1]);
+ nelt_dir = nnoe_dir-1;
+ nnoe = nnoe_dir*nnoe_dir*nnoe_dir;
+
+ coo = malloc(mdim*nnoe*sizeof(med_float));
+ numnoe = malloc(nnoe*sizeof(med_int));
+ nufano = malloc(nnoe*sizeof(med_int));
+ nomnoe = malloc((MED_TAILLE_PNOM*nnoe+1)*sizeof(char));
+
+ hxsize = 1./((med_float) (nnoe_dir - 1));
+ hysize = hxsize;
+ hzsize = hxsize;
+
+ nhexa8 = nelt_dir*nelt_dir*nelt_dir;
+ hexa8 = malloc(8*nhexa8*sizeof(med_int));
+ numhexa8 = malloc(nhexa8*sizeof(med_int));
+ nufahexa8 = malloc(nhexa8*sizeof(med_int));
+ nomhexa8 = malloc((MED_TAILLE_PNOM*nhexa8+1)*sizeof(char));
+
+ DbleVectNode = malloc(mdim*nnoe*sizeof(med_float));
+ DbleVectCell = malloc(mdim*nhexa8*sizeof(med_float));
+
+ /*
+ les noeuds:
+ */
+
+ for(k=0;k<nnoe_dir;k++)
+ {
+ for(j=0;j<nnoe_dir;j++)
+ {
+ for (i=0;i<nnoe_dir;i++)
+ {
+ int ijk = k*nnoe_dir*nnoe_dir+j*nnoe_dir+i;
+
+ numnoe[ijk] = ijk+1;
+ nufano[ijk] = 0;
+
+ coo[mdim*ijk] = ((med_float) i)*hxsize;
+ coo[mdim*ijk+1] = ((med_float) j)*hysize;
+ coo[mdim*ijk+2] = ((med_float) k)*hzsize;
+
+ /*
+ printf("Coordonnées %d X = %lf Y = %lf Z = %lf\n",(ijk+1),coo[mdim*ijk],coo[mdim*ijk+1],coo[mdim*ijk+2]);
+ */
+ }
+ }
+ }
+
+ /*
+ les elements:
+ */
+
+ for(k=0;k<nelt_dir;k++)
+ {
+ for(j=0;j<nelt_dir;j++)
+ {
+ for (i=0;i<nelt_dir;i++)
+ {
+ int ijk = k*nelt_dir*nelt_dir+j*nelt_dir+i;
+
+ numhexa8[ijk] = ijk+1;
+ nufahexa8[ijk] = 0;
+
+ indexN5 = k*nnoe_dir*nnoe_dir+j*nnoe_dir+i+1;
+ indexN8 = indexN5+1;
+ indexN1 = indexN5+nnoe_dir;
+ indexN4 = indexN8+nnoe_dir;
+
+ indexN6 = indexN5+nnoe_dir*nnoe_dir;
+ indexN7 = indexN8+nnoe_dir*nnoe_dir;
+ indexN2 = indexN1+nnoe_dir*nnoe_dir;
+ indexN3 = indexN4+nnoe_dir*nnoe_dir;
+
+ hexa8[8*ijk] = indexN1;
+ hexa8[8*ijk+1] = indexN2;
+ hexa8[8*ijk+2] = indexN3;
+ hexa8[8*ijk+3] = indexN4;
+ hexa8[8*ijk+4] = indexN5;
+ hexa8[8*ijk+5] = indexN6;
+ hexa8[8*ijk+6] = indexN7;
+ hexa8[8*ijk+7] = indexN8;
+
+ /*
+ printf("Connectivitée %d i1 = %d i2 = %d i3 = %d i4 = %d i5 = %d i6 = %d i7 = %d i8 = %d\n",(ijk+1),hexa8[8*ijk],hexa8[8*ijk+1],hexa8[8*ijk+2],hexa8[8*ijk+3],hexa8[8*ijk+4],hexa8[8*ijk+5],hexa8[8*ijk+6],hexa8[8*ijk+7]);
+ */
+ }
+ }
+ }
+
+ /*
+ Les champs
+ */
+
+ (void) time(&t1);
+
+ srand((int) t1); /* use time in seconds to set seed */
+
+ for(i=0;i<nnoe;i++)
+ {
+ DbleVectNode[mdim*i] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectNode[mdim*i+1] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectNode[mdim*i+2] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ /*
+ printf("i %d DbleVectNode %lf %lf\n",i,DbleVectNode[mdim*i],
+ DbleVectNode[mdim*i+1],DbleVectNode[mdim*i+2]);
+ */
+ }
+
+ for(i=0;i<nhexa8;i++)
+ {
+ DbleVectCell[mdim*i] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectCell[mdim*i+1] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectCell[mdim*i+2] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ /*
+ printf("i %d DbleVectCell %lf %lf\n",i,DbleVectCell[mdim*i],
+ DbleVectCell[mdim*i+1],DbleVectCell[mdim*i+2]);
+ */
+ }
+
+ /***************************************************************************/
+
+ sprintf(buff,"%d",nnoe_dir);
+ strcat(MedFile,buff);
+ strcat(MedFile,".med");
+
+ fid = MEDouvrir(MedFile,MED_REMP);
+
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim);
+ printf("%d\n",ret);
+
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe,MED_ECRI);
+ printf("%d\n",ret);
+
+ /*
+ ecriture des mailles MED_HEXA8 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles
+ */
+
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,hexa8,MED_FULL_INTERLACE,
+ nomhexa8,MED_FAUX,numhexa8,MED_VRAI,nufahexa8,nhexa8,
+ MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /*
+ Les Champs
+ */
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champDbleVectNode,MED_REEL64,compDbleVectNode,
+ unitDbleVectNode,mdim);
+
+ printf("MEDchampCr DbleVectNode : %d \n",ret);
+
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champDbleVectNode,
+ (unsigned char *)DbleVectNode,
+ MED_NO_INTERLACE, nnoe,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr DbleVectNode : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champDbleVectCell,MED_REEL64,compDbleVectCell,
+ unitDbleVectCell,mdim);
+
+ printf("MEDchampCr DbleVectCell : %d \n",ret);
+
+ if (ret == 0)
+ {
+ ret = MEDchampEcr(fid, maa, champDbleVectCell,
+ (unsigned char *)DbleVectCell,
+ MED_NO_INTERLACE, nhexa8,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr DbleVectCell : %d \n",ret);
+ }
+ }
+
+ /***************************************************************************/
+
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+ free(coo);
+ free(numnoe);
+ free(nufano);
+ free(nomnoe);
+ free(hexa8);
+ free(numhexa8);
+ free(nufahexa8);
+ free(nomhexa8);
+ free(DbleVectNode);
+ free(DbleVectCell);
+
+ return 0;
+}
+
+
--- /dev/null
+/*
+ creation d'une geometrie 3d : un cube [0,1]^3
+ maillé uniformement en tetrahedres reguliers;
+ avec n (=argv[1]) noeuds dans chaque direction.
+ 2 champs:
+ - DbleVectNode champ vectoriel reel sur les noeuds
+ - DbleVectCell champ vectoriel reel sur les cellules
+
+ En sortie, il y aura production d'un fichier MED
+ cube_tetra_n.med qui contiendra un seul maillage et 2 champs
+ avec une seule famille la FAMILLE_0
+*/
+
+#include <med.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <time.h>
+
+int main (int argc, char **argv)
+{
+ med_err ret;
+ med_idt fid;
+ char maa[MED_TAILLE_NOM+1] = "cube_tetra4";
+ med_int mdim = 3;
+ int dimTot;
+
+ int nnoe_dir;
+ int nelt_dir;
+ med_int nnoe;
+ int i, j, k, ijk;
+
+ med_float * coo;
+ med_int * numnoe;
+ med_int * nufano;
+
+ med_float hxsize;
+ med_float hysize;
+ med_float hzsize;
+
+ med_float * DbleVectNode;
+ med_float * DbleVectCell;
+
+ time_t t1;
+
+ /*
+ Le maillage
+ */
+
+ char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z ";
+ char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm ";
+ /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
+ char *nomnoe ;
+
+ med_int ntetra4;
+ med_int * tetra4;
+ med_int * numtetra4;
+ med_int * nufatetra4;
+
+ char * nomtetra4;
+ int indexN1, indexN2, indexN3, indexN4, indexN5, indexN6, indexN7, indexN8;
+
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int nfame = 0;
+ int nfamn = 0;
+
+ char MedFile[100] = "cube_tetra4_";
+ char buff[100];
+
+ /*
+ Les champs
+ */
+
+ char champDbleVectNode[MED_TAILLE_NOM+1] = "DbleVectNode";
+ char compDbleVectNode[MED_TAILLE_PNOM*3+1] = "comp1 comp2 comp3 " ;
+ char unitDbleVectNode[MED_TAILLE_PNOM*3+1] = "unit1 unit2 unit3 " ;
+
+ char champDbleVectCell[MED_TAILLE_NOM+1] = "DbleVectCell";
+ char compDbleVectCell[MED_TAILLE_PNOM*3+1] = "comp1 comp2 comp3 " ;
+ char unitDbleVectCell[MED_TAILLE_PNOM*3+1] = "unit1 unit2 unit3 " ;
+
+ if (argc != 2)
+ {
+ printf("Usage: %s <n> \n",argv[0]);
+ printf(" where\n");
+ printf(" - n is the number of nodes in each direction.\n");
+ printf("\n");
+ printf("This program will produce a MED file cube_tetra4_n.med\n");
+ exit(0);
+ }
+
+ nnoe_dir = atoi(argv[1]);
+ nelt_dir = nnoe_dir-1;
+ nnoe = (med_int) nnoe_dir*nnoe_dir*nnoe_dir;
+
+ dimTot = (int) mdim*nnoe*sizeof(med_float);
+ coo = malloc(dimTot);
+
+ dimTot = (int) (MED_TAILLE_PNOM*nnoe+1)*sizeof(char);
+ nomnoe = malloc(dimTot);
+
+ dimTot = (int) nnoe*sizeof(med_int);
+ numnoe = malloc(dimTot);
+ nufano = malloc(dimTot);
+
+ hxsize = 1./((med_float) (nnoe_dir - 1));
+ hysize = hxsize;
+ hzsize = hxsize;
+
+ ntetra4 = (med_int) 6*nelt_dir*nelt_dir*nelt_dir;
+
+ dimTot = (int) 4*ntetra4*sizeof(med_int);
+ tetra4 = malloc(dimTot);
+
+ dimTot = (int) (MED_TAILLE_PNOM*ntetra4+1)*sizeof(char);
+ nomtetra4 = malloc(dimTot);
+
+ dimTot = (int) ntetra4*sizeof(med_int);
+ numtetra4 = malloc(dimTot);
+ nufatetra4 = malloc(dimTot);
+
+ dimTot = (int) mdim*nnoe*sizeof(med_float);
+ DbleVectNode = malloc(dimTot);
+
+ dimTot = (int) mdim*ntetra4*sizeof(med_float);
+ DbleVectCell = malloc(dimTot);
+
+ /*
+ les noeuds:
+ */
+
+ for(k=0;k<nnoe_dir;k++)
+ {
+ for(j=0;j<nnoe_dir;j++)
+ {
+ for (i=0;i<nnoe_dir;i++)
+ {
+ int ijk = k*nnoe_dir*nnoe_dir+j*nnoe_dir+i;
+
+ numnoe[ijk] = ijk+1;
+ nufano[ijk] = 0;
+
+ coo[mdim*ijk] = ((med_float) i)*hxsize;
+ coo[mdim*ijk+1] = ((med_float) j)*hysize;
+ coo[mdim*ijk+2] = ((med_float) k)*hzsize;
+
+ /*
+ printf("Coordonnées %d X = %lf Y = %lf Z = %lf\n",(ijk+1),coo[mdim*ijk],coo[mdim*ijk+1],coo[mdim*ijk+2]);
+ */
+ }
+ }
+ }
+
+ /*
+ les elements:
+ */
+
+ for(k=0;k<nelt_dir;k++)
+ {
+ for(j=0;j<nelt_dir;j++)
+ {
+ for (i=0;i<nelt_dir;i++)
+ {
+ int ijk = k*nelt_dir*nelt_dir+j*nelt_dir+i;
+ int ijk1 = 6*ijk;
+ int ijk2 = ijk1+1;
+ int ijk3 = ijk2+1;
+ int ijk4 = ijk3+1;
+ int ijk5 = ijk4+1;
+ int ijk6 = ijk5+1;
+
+ numtetra4[ijk1] = ijk1+1;
+ numtetra4[ijk2] = ijk2+1;
+ numtetra4[ijk3] = ijk3+1;
+ numtetra4[ijk4] = ijk4+1;
+ numtetra4[ijk5] = ijk5+1;
+ numtetra4[ijk6] = ijk6+1;
+
+ nufatetra4[ijk1] = 0;
+ nufatetra4[ijk2] = 0;
+ nufatetra4[ijk3] = 0;
+ nufatetra4[ijk4] = 0;
+ nufatetra4[ijk5] = 0;
+ nufatetra4[ijk6] = 0;
+
+ indexN5 = k*nnoe_dir*nnoe_dir+j*nnoe_dir+i+1;
+ indexN8 = indexN5+1;
+ indexN1 = indexN5+nnoe_dir;
+ indexN4 = indexN8+nnoe_dir;
+
+ indexN6 = indexN5+nnoe_dir*nnoe_dir;
+ indexN7 = indexN8+nnoe_dir*nnoe_dir;
+ indexN2 = indexN1+nnoe_dir*nnoe_dir;
+ indexN3 = indexN4+nnoe_dir*nnoe_dir;
+
+ tetra4[4*ijk1] = indexN1;
+ tetra4[4*ijk1+1] = indexN3;
+ tetra4[4*ijk1+2] = indexN4;
+ tetra4[4*ijk1+3] = indexN5;
+
+ tetra4[4*ijk2] = indexN3;
+ tetra4[4*ijk2+1] = indexN7;
+ tetra4[4*ijk2+2] = indexN4;
+ tetra4[4*ijk2+3] = indexN5;
+
+ tetra4[4*ijk3] = indexN4;
+ tetra4[4*ijk3+1] = indexN7;
+ tetra4[4*ijk3+2] = indexN8;
+ tetra4[4*ijk3+3] = indexN5;
+
+ tetra4[4*ijk4] = indexN1;
+ tetra4[4*ijk4+1] = indexN2;
+ tetra4[4*ijk4+2] = indexN3;
+ tetra4[4*ijk4+3] = indexN5;
+
+ tetra4[4*ijk5] = indexN2;
+ tetra4[4*ijk5+1] = indexN6;
+ tetra4[4*ijk5+2] = indexN3;
+ tetra4[4*ijk5+3] = indexN5;
+
+ tetra4[4*ijk6] = indexN3;
+ tetra4[4*ijk6+1] = indexN6;
+ tetra4[4*ijk6+2] = indexN7;
+ tetra4[4*ijk6+3] = indexN5;
+ }
+ }
+ }
+
+ /*
+ Les champs
+ */
+
+ (void) time(&t1);
+
+ srand((int) t1); /* use time in seconds to set seed */
+
+ for(i=0;i<nnoe;i++)
+ {
+ DbleVectNode[mdim*i] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectNode[mdim*i+1] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectNode[mdim*i+2] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ /*
+ printf("i %d DbleVectNode %lf %lf %lf\n",i,DbleVectNode[mdim*i],
+ DbleVectNode[mdim*i+1],DbleVectNode[mdim*i+2]);
+ */
+ }
+
+ for(i=0;i<ntetra4;i++)
+ {
+ DbleVectCell[mdim*i] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectCell[mdim*i+1] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ DbleVectCell[mdim*i+2] = (med_float)
+ (1+(int) (100.0*rand()/(RAND_MAX+1.0)));
+
+ /*
+ printf("i %d DbleVectCell %lf %lf %lf\n",i,DbleVectCell[mdim*i],
+ DbleVectCell[mdim*i+1],DbleVectCell[mdim*i+2]);
+ */
+ }
+
+ /***************************************************************************/
+
+ sprintf(buff,"%d",nnoe_dir);
+ strcat(MedFile,buff);
+ strcat(MedFile,".med");
+
+ fid = MEDouvrir(MedFile,MED_REMP);
+
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim);
+ printf("%d\n",ret);
+
+ if (ret == 0)
+ ret = MEDunvCr(fid,maa);
+ printf("%d\n",ret);
+
+ /***************************************************************************/
+
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+ nufano,nnoe,MED_ECRI);
+ printf("%d\n",ret);
+
+ /*
+ ecriture des mailles MED_TETRA4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles
+ */
+
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,tetra4,MED_FULL_INTERLACE,
+ nomtetra4,MED_FAUX,numtetra4,MED_VRAI,nufatetra4,
+ ntetra4,MED_MAILLE,MED_TETRA4,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+ /***************************************************************************/
+ /*
+ Les Champs
+ */
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champDbleVectNode,MED_REEL64,compDbleVectNode,
+ unitDbleVectNode,mdim);
+
+ printf("MEDchampCr DbleVectNode : %d \n",ret);
+
+ if (ret == 0)
+ {
+ dimTot = (int) nnoe;
+
+ ret = MEDchampEcr(fid, maa, champDbleVectNode,
+ (unsigned char *) DbleVectNode,
+ MED_NO_INTERLACE, dimTot,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
+ 0, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr DbleVectNode : %d \n",ret);
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champDbleVectCell,MED_REEL64,compDbleVectCell,
+ unitDbleVectCell,mdim);
+
+ printf("MEDchampCr DbleVectCell : %d \n",ret);
+
+ if (ret == 0)
+ {
+ dimTot = (int) ntetra4;
+
+ ret = MEDchampEcr(fid, maa, champDbleVectCell,
+ (unsigned char *) DbleVectCell,
+ MED_NO_INTERLACE, dimTot,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_TETRA4, MED_NOPDT," ", 0., MED_NONOR);
+
+ printf("MEDchampEcr DbleVectCell : %d \n",ret);
+ }
+ }
+
+ /***************************************************************************/
+
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+ free(coo);
+ free(numnoe);
+ free(nufano);
+ free(nomnoe);
+ free(tetra4);
+ free(numtetra4);
+ free(nufatetra4);
+ free(nomtetra4);
+ free(DbleVectNode);
+ free(DbleVectCell);
+
+ return 0;
+}
%{
#include "MESHClient.hxx"
#include "SUPPORTClient.hxx"
-#include "FIELDClient.hxx"
+#include "FIELDDOUBLEClient.hxx"
+#include "FIELDINTClient.hxx"
#include CORBA_CLIENT_HEADER(MED)
-#define FIELDDOUBLEClient FIELDClient<double>
-#define FIELDINTClient FIELDClient<int>
+/* #define FIELDDOUBLEClient FIELDClient<double,SALOME_MED::FIELDDOUBLE_ptr> */
+/* #define FIELDINTClient FIELDClient<int,SALOME_MED::FIELDINT_ptr> */
%}
%include "libMedCorba_Swig.i"
};
-%rename(FIELDDOUBLEClient) FIELDClient<double>;
-FIELDDOUBLE * FIELDDOUBLEClient(const SALOME_MED::FIELDDOUBLE_ptr IOR_Field,
- SUPPORT * S = NULL);
+class FIELDDOUBLEClient : public FIELDDOUBLE {
+public:
+ FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba,
+ SUPPORT * S = NULL);
-%rename(FIELDINTClient) FIELDClient<int>;
-FIELDDOUBLE * FIELDINTClient (const SALOME_MED::FIELDINT_ptr IOR_Field,
- SUPPORT * S = NULL);
+ ~FIELDDOUBLEClient();
+};
+
+class FIELDINTClient : public FIELDINT {
+public:
+ FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba,
+ SUPPORT * S = NULL);
+
+ ~FIELDINTClient();
+};
+
+FIELDDOUBLE * getDoublePointer(FIELDDOUBLEClient * input);
+
+FIELDINT * getIntPointer(FIELDINTClient * input);
+
+%{
+ FIELDDOUBLE * getDoublePointer(FIELDDOUBLEClient * input)
+ {
+ return (FIELDDOUBLE *) input;
+ }
+
+ FIELDINT * getIntPointer(FIELDINTClient * input)
+ {
+ return (FIELDINT *) input;
+ }
+%}
--- /dev/null
+import salome
+import SALOME_TESTMEDCLIENT
+import SALOME_MED
+
+def getMedObjectFromStudy():
+ mySO = salome.myStudy.FindObject("Objet MED")
+ Builder = salome.myStudy.NewBuilder()
+ anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR")
+ obj = salome.orb.string_to_object(anAttr.Value())
+ myObj = obj._narrow(SALOME_MED.MED)
+ return myObj
+
+#Truc1,Truc2 are Containers launched with SALOME_Container exe.
+
+med_comp = salome.lcc.FindOrLoadComponent("Truc1", "MED")
+my_comp = salome.lcc.FindOrLoadComponent("Truc2","TESTMEDCLIENT")
+studyCurrent = salome.myStudyName
+
+## First test
+
+##med_obj = med_comp.readStructFile("cube_tetra4_12.med",studyCurrent)
+##my_comp.go2(med_obj)
+
+## Second test
+
+med_obj = med_comp.readStructFile("cube_hexa8_quad4.med",studyCurrent)
+my_comp.go(med_obj)