Salome HOME
DCQ : Merge with Ecole Ete a6.
[modules/med.git] / src / MEDMEM / INTERPOLATION / MEDMEM_dTreeSommet.hxx
1 #ifndef SOMMET_HPP
2 #define SOMMET_HPP
3
4
5 // La classe qui suit sert UNIQUEMENT pour les sommets du dTree
6
7 template <int DIMENSION> class Sommet_dTree
8 {
9 protected :
10         double coord[DIMENSION];
11 public :
12         Sommet_dTree() 
13                 {
14                 }
15         Sommet_dTree(double *c) 
16                 {
17                 for (int i=0;i<DIMENSION;i++) coord[i]=c[i];
18                 }
19         Sommet_dTree(double c)
20                 {
21                 for (int i=0;i<DIMENSION;i++) coord[i]=c;
22                 }
23         Sommet_dTree(const Sommet_dTree & SO) 
24                 {
25                 for (int i=0;i<DIMENSION;i++) coord[i]=SO.coord[i];
26                 }
27         Sommet_dTree(const Sommet_dTree &s1,const Sommet_dTree &s2) 
28                 {
29                 for (int i=0;i<DIMENSION;i++) coord[i]=0.5*(s1[i]+s2[i]);
30                 }
31         ~Sommet_dTree() 
32                 {
33                 }
34         const double operator[](int i) const 
35                 {
36                 return coord[i];
37                 }
38         double & operator[](int i) 
39                 {
40                 return coord[i];
41                 }
42         Sommet_dTree & operator=(const Sommet_dTree &f) 
43                 {
44                 for (int i=0;i<DIMENSION;i++) coord[i]=f.coord[i];return *this;
45                 }
46         friend double DistanceInf(const Sommet_dTree<DIMENSION> &A,const Sommet_dTree<DIMENSION> &B) 
47                 {
48                 double max=0;
49                 double tmp;
50                 for (int i=0;i<DIMENSION;i++)
51                         {
52                         tmp=fabs(A[i]-B[i]);
53                         if (tmp>max) max=tmp;
54                         }
55                 return max;
56                 }
57 };
58
59 #endif