Salome HOME
Copyrights update
[modules/med.git] / src / INTERPOLATION / MEDMEM_dTreeSommet.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/
19 //
20 #ifndef SOMMET_HPP
21 #define SOMMET_HPP
22
23
24 // La classe qui suit sert UNIQUEMENT pour les sommets du dTree
25
26 template <int DIMENSION> class Sommet_dTree
27 {
28 protected :
29         double coord[DIMENSION];
30 public :
31         Sommet_dTree() 
32                 {
33                 }
34         Sommet_dTree(double *c) 
35                 {
36                 for (int i=0;i<DIMENSION;i++) coord[i]=c[i];
37                 }
38         Sommet_dTree(double c)
39                 {
40                 for (int i=0;i<DIMENSION;i++) coord[i]=c;
41                 }
42         Sommet_dTree(const Sommet_dTree & SO) 
43                 {
44                 for (int i=0;i<DIMENSION;i++) coord[i]=SO.coord[i];
45                 }
46         Sommet_dTree(const Sommet_dTree &s1,const Sommet_dTree &s2) 
47                 {
48                 for (int i=0;i<DIMENSION;i++) coord[i]=0.5*(s1[i]+s2[i]);
49                 }
50         ~Sommet_dTree() 
51                 {
52                 }
53         const double operator[](int i) const 
54                 {
55                 return coord[i];
56                 }
57         double & operator[](int i) 
58                 {
59                 return coord[i];
60                 }
61         Sommet_dTree & operator=(const Sommet_dTree &f) 
62                 {
63                 for (int i=0;i<DIMENSION;i++) coord[i]=f.coord[i];return *this;
64                 }
65         friend double DistanceInf(const Sommet_dTree<DIMENSION> &A,const Sommet_dTree<DIMENSION> &B) 
66                 {
67                 double max=0;
68                 double tmp;
69                 for (int i=0;i<DIMENSION;i++)
70                         {
71                         tmp=fabs(A[i]-B[i]);
72                         if (tmp>max) max=tmp;
73                         }
74                 return max;
75                 }
76 };
77
78 #endif