]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/INTERPOLATION/MEDMEM_WrapperNodes.hxx
Salome HOME
update from the MedMemory V1.0.1
[modules/med.git] / src / MEDMEM / INTERPOLATION / MEDMEM_WrapperNodes.hxx
1
2 #ifndef MEDMEM_WRAPPER_NODES_HXX
3 #define MEDMEM_WRAPPER_NODES_HXX
4
5 #ifndef NULL
6 #define NULL 0
7 #endif
8
9 // les classes de wrapping
10
11 template <int DIMENSION> class Wrapper_Noeud
12 {
13 protected :
14         double * coordonnees;
15 public :
16         Wrapper_Noeud():coordonnees(NULL) 
17                 {
18                 }
19         Wrapper_Noeud(double * coord):coordonnees(coord) 
20                 {
21                 }
22         ~Wrapper_Noeud() 
23                 {
24                 }
25         void positionne(double *place) 
26                 {
27                 coordonnees=place;
28                 }
29         const double & operator[] (int i) const
30                 {
31                 return coordonnees[i];
32                 }
33         double operator[] (int i)
34                 {
35                 return coordonnees[i];
36                 }
37         friend double DistanceInf(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B) 
38                 {
39                 double max=0;
40                 double tmp;
41                 for (int i=0;i<DIMENSION;i++)
42                         {
43                         tmp=fabs(A[i]-B[i]);
44                         if (tmp>max) max=tmp;
45                         }
46                 return max;
47                 }
48         friend double DistanceL2(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B)  
49                 {
50                 double tmp,somme=0;
51                 for (int i=0;i<DIMENSION;i++)
52                         {
53                         tmp=(A[i]-B[i]);
54                         somme+=tmp*tmp;
55                         }
56                 return sqrt(somme);
57                 }
58         friend int operator==(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B)
59                 {
60                 for (int i=0;i<DIMENSION;i++) if (A[i]!=B[i]) return 1;
61                 return 0;
62                 }
63         friend ostream & operator<<(ostream &os,const Wrapper_Noeud<DIMENSION> &A)
64                 {
65                 os<<"( "<<flush;
66                 for (int i=0;i<DIMENSION;i++) os<<A[i]<<" "<<flush;
67                 os<<")"<<flush;
68                 return os;
69                 }
70         };
71         
72 template <int DIMENSION> class Wrapper_Nuage_Noeud
73         {
74         protected : 
75                 int nbr_noeuds;
76                 double *noeuds;
77                 Wrapper_Noeud<DIMENSION> show;
78         public :
79                 Wrapper_Nuage_Noeud():nbr_noeuds(0),noeuds(NULL) {}
80                 Wrapper_Nuage_Noeud(int nn, double *n):nbr_noeuds(nn),noeuds(n),show(noeuds) {}
81                 ~Wrapper_Nuage_Noeud() {}
82                 Wrapper_Noeud<DIMENSION> & operator [] (int i)
83                         {
84                         if ((i<0)||(i>=nbr_noeuds))
85                                 {
86                                 cerr<<"Outbound call dans Wrapper Nuage Noeud"<<endl;
87                                 cerr<<"Inférior Bound = "<<0<<endl;
88                                 cerr<<"Supérior Bound = "<<nbr_noeuds-1<<endl;
89                                 cerr<<"Call = "<<i<<endl;
90                                 exit(-1);
91                                 }
92                         show.positionne((double *) &noeuds[DIMENSION*i]);
93                         return show;
94                         }
95                 int size() const {return nbr_noeuds;}
96                 int SIZE() const {return nbr_noeuds;}
97                 void affiche()
98                         {
99                         int i,j;
100                         for (i=0;i<nbr_noeuds;i++)
101                                 {
102                                 cout<<"Noeud "<<i<<" : "<<flush;
103                                 for (j=0;j<DIMENSION;j++) cout<<noeuds[i*DIMENSION+j]<<" "<<flush;
104                                 cout<<endl;
105                                 }
106                         }
107         };
108
109 #endif