Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / INTERPOLATION / MEDMEM_InterpolationHighLevelObjects.hxx.old
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX
24
25 #define MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX
26 #include "MEDMEM_Connectivity.hxx"
27 #include "MEDMEM_WrapperConnectivity.hxx"
28 #include "MEDMEM_dTree.hxx"
29 #include "MEDMEM_WrapperNodes.hxx"
30 #include "MEDMEM_WrapperMesh.hxx"
31 #include "MEDMEM_WrapperCells.hxx"
32 #include "MEDMEM_Mapping.hxx"
33
34 // DECLARATIONS
35
36 template <int DIMENSION> class Meta_dTree : public dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>
37 {
38 protected :
39         Wrapper_Nuage_Noeud<DIMENSION> * nuagetmp;
40 public :
41         Meta_dTree(int nn,double * fullinterlace);
42         ~Meta_dTree() {if ((etat==DTREE_RACINE)&&(nuagetmp)) delete nuagetmp;}
43         inline int trouve_plus_proche_point(double *node);
44 };
45
46 class Meta_Nuage_Maille : public Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>
47 {
48 protected :
49         Wrapper_Med_Connectivity * connectivite_med;
50 public :
51         Meta_Nuage_Maille(CONNECTIVITY * connmed); 
52         Meta_Nuage_Maille():Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>(connectivite_med=new Wrapper_Med_Connectivity) {}
53         ~Meta_Nuage_Maille() {if (connectivite_med) delete connectivite_med;}
54 };
55
56
57 typedef Wrapper_Maillage<Meta_Nuage_Maille> Meta_Maillage;
58
59 template <int DIMENSION> class Meta_Mapping : public Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>
60 {
61 protected : 
62         Wrapper_Nuage_Noeud<DIMENSION> * wrapping_nuage_source;
63         Wrapper_Nuage_Noeud<DIMENSION> * wrapping_nuage_cible;
64 public :
65         Meta_Mapping(Meta_Maillage * mb,double * noeudssource,int ns,double * noeudscible,int nc);
66         ~Meta_Mapping() {if (wrapping_nuage_source) delete wrapping_nuage_source;if (wrapping_nuage_cible) delete wrapping_nuage_cible;}
67         inline int Trouve_Maille_Contenant_Noeud(double * node,int num_maille, int flag_convexe=0);
68         double donne_valeur_interpolee_P1(double * node,vector<double> vals);
69 };
70
71 // CODE
72
73 template <int DIMENSION> Meta_dTree<DIMENSION>::Meta_dTree(int nn,double * fullinterlace)
74 :dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>
75 (nuagetmp=new Wrapper_Nuage_Noeud<DIMENSION>(nn,fullinterlace))
76         {
77         }
78
79 template <int DIMENSION> inline int Meta_dTree<DIMENSION>::trouve_plus_proche_point(double *node)
80         {
81         static Wrapper_Noeud<DIMENSION> nodetmp;
82         nodetmp.positionne(node);
83         return dTree<Wrapper_Noeud<DIMENSION>,Wrapper_Nuage_Noeud<DIMENSION>,DIMENSION>::trouve_plus_proche_point(Wrapper_Noeud<DIMENSION>(nodetmp));
84         }
85         
86 //*     
87 Meta_Nuage_Maille::Meta_Nuage_Maille(CONNECTIVITY * conmed):Wrapper_Nuage_Maille<Wrapper_Med_Connectivity>(connectivite_med=new Wrapper_Med_Connectivity(conmed))
88         {
89         }
90 //*/
91
92 template <int DIMENSION> Meta_Mapping<DIMENSION>::Meta_Mapping(Meta_Maillage * mb,double * noeudssource,int ns,double * noeudscible,int nc)
93 :Mapping<Meta_Maillage,Meta_Nuage_Maille,Wrapper_Nuage_Noeud<DIMENSION>,Wrapper_Noeud<DIMENSION>,DIMENSION>
94 (mb,
95 wrapping_nuage_source=new Wrapper_Nuage_Noeud<DIMENSION>(ns,noeudssource),
96 wrapping_nuage_cible=new Wrapper_Nuage_Noeud<DIMENSION>(nc,noeudscible))
97         {
98         }
99
100 template <int DIMENSION> inline int Meta_Mapping<DIMENSION>::Trouve_Maille_Contenant_Noeud(double * node,int num_maille,int flag_convexe)
101         {
102         int interdit=num_maille;
103         int max_loop=100;
104         int nme=0;
105         static Wrapper_Noeud<DIMENSION> nodetmp;
106         nodetmp.positionne(node);
107         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);
108         }
109 template <int DIMENSION> double Meta_Mapping<DIMENSION>::donne_valeur_interpolee_P1(double * node,vector<double> vals)
110         {
111         int num_maille_contenant=Trouve_Maille_Contenant_Noeud(node,0);
112         double valeur_interpol=0;
113         vector<double> valeurs=CB->Calcule_Coord_Baryc(num_maille_contenant,node);
114         int i;
115         int num_som;
116         for (i=0;i<valeurs.size();i++) 
117                 {
118                 cout<<"Lambda(M):"<<i<<" = "<<valeurs[i]<<endl;
119                 num_som=mailles_back->DONNE_SOMMET_MAILLE(num_maille_contenant,i);
120                 valeur_interpol+=vals[num_som]*valeurs[i];
121                 }
122         
123         return valeur_interpol;
124         }
125
126 #endif