src/INTERPOLATION/MEDMEM_dTreeSommet.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00002 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00003 // 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either 
00007 // version 2.1 of the License.
00008 // 
00009 // This library is distributed in the hope that it will be useful 
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00012 // Lesser General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Lesser General Public  
00015 // License along with this library; if not, write to the Free Software 
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00017 //
00018 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00019 //
00020 #ifndef SOMMET_HPP
00021 #define SOMMET_HPP
00022 
00023 
00024 // La classe qui suit sert UNIQUEMENT pour les sommets du dTree
00025 
00026 template <int DIMENSION> class Sommet_dTree
00027 {
00028 protected :
00029      double coord[DIMENSION];
00030 public :
00031      Sommet_dTree() 
00032           {
00033           }
00034      Sommet_dTree(double *c) 
00035           {
00036           for (int i=0;i<DIMENSION;i++) coord[i]=c[i];
00037           }
00038      Sommet_dTree(double c)
00039           {
00040           for (int i=0;i<DIMENSION;i++) coord[i]=c;
00041           }
00042      Sommet_dTree(const Sommet_dTree & SO) 
00043           {
00044           for (int i=0;i<DIMENSION;i++) coord[i]=SO.coord[i];
00045           }
00046      Sommet_dTree(const Sommet_dTree &s1,const Sommet_dTree &s2) 
00047           {
00048           for (int i=0;i<DIMENSION;i++) coord[i]=0.5*(s1[i]+s2[i]);
00049           }
00050      ~Sommet_dTree() 
00051           {
00052           }
00053      const double operator[](int i) const 
00054           {
00055           return coord[i];
00056           }
00057      double & operator[](int i) 
00058           {
00059           return coord[i];
00060           }
00061      Sommet_dTree & operator=(const Sommet_dTree &f) 
00062           {
00063           for (int i=0;i<DIMENSION;i++) coord[i]=f.coord[i];return *this;
00064           }
00065      friend double DistanceInf(const Sommet_dTree<DIMENSION> &A,const Sommet_dTree<DIMENSION> &B) 
00066           {
00067           double max=0;
00068           double tmp;
00069           for (int i=0;i<DIMENSION;i++)
00070                {
00071                tmp=fabs(A[i]-B[i]);
00072                if (tmp>max) max=tmp;
00073                }
00074           return max;
00075           }
00076 };
00077 
00078 #endif