-// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef MEDMEM_DTREE_HXX
#define MEDMEM_DTREE_HXX
#include "MEDMEM_dTreeSommet.hxx"
+#include <list>
#define DTREE_FANTOME -1
#define DTREE_RACINE 0
#define DTREE_NBR_MIN_NOEUDS 2
#define DTREE_NBR_MAX_DESC 8
// pour meilleu re lecture
-#define _TEMPLATE_ template <class NOEUD,class NUAGENOEUD,int DIMENSION,int NBR_NOEUDS_PAR_CASE>
-#define _DTREE_ dTree<NOEUD,NUAGENOEUD,DIMENSION,NBR_NOEUDS_PAR_CASE>
+#define _TEMPLATE_ \
+template <class NOEUD,class NUAGENOEUD,int DIMENSION,int NBR_NOEUDS_PAR_CASE, int MAX_DEPTH>
+#define _DTREE_ dTree<NOEUD,NUAGENOEUD,DIMENSION,NBR_NOEUDS_PAR_CASE,MAX_DEPTH>
//////////////////////////////////////////////////////////////////
/// ///
// - NBR_NOEUDS_PAR_CASE ne doit pas être modifié sauf peut-être dans le cas où l'utilisateur veut utiliser des d-Tree parallèles
// ou utilise des nuages de noeud trop grands
-template <class NOEUD,class NUAGENOEUD,int DIMENSION,int NBR_NOEUDS_PAR_CASE=DTREE_NBR_MIN_NOEUDS> class dTree
+template <class NOEUD,class NUAGENOEUD,int DIMENSION,int NBR_NOEUDS_PAR_CASE=DTREE_NBR_MIN_NOEUDS, int MAX_DEPTH=DTREE_NBR_MAX_DESC>
+class dTree
{
protected :
// types
int Get_Nbr_Descendants_Non_Vides() const;
int Get_Nbr_Descendants_Vides() const;
int Get_Profondeur_Max() const;
+
+ // return numbers of nodes close to P within tolerance d
+ int get_all_close(NOEUD P, double d, list<int> & closeNumbers) const;
};
niveau=0;
}
- if (noeud_contenu->size()<=NBR_NOEUDS_PAR_CASE)
+ if (noeud_contenu->size()<=NBR_NOEUDS_PAR_CASE ||
+ niveau > MAX_DEPTH) // badly needed for the case with coincident nodes
{
etat=DTREE_TERMINAL;
}
}
}
+// return numbers of nodes close to P within tolerance d
+_TEMPLATE_ int _DTREE_::get_all_close(NOEUD P, double d, list<int> & closeNumbers) const
+{
+ int i, nbAdded = 0;
+ if (Localise_Point(P,d))
+ {
+ if (etat==DTREE_TERMINAL)
+ {
+ int nb = noeud_contenu->size();
+ for (i=0;i<nb;i++)
+ {
+ double dist=DistanceL2(P,(*nuage)[(*noeud_contenu)[i]]);
+ if (dist < d )
+ {
+ nbAdded++;
+ closeNumbers.push_back( (*noeud_contenu)[i] );
+ }
+ }
+ }
+ else
+ {
+ for (i=0;i<nbr_descendants;i++)
+ {
+ nbAdded += descendant[i]->get_all_close(P,d,closeNumbers);
+ }
+ }
+ }
+ return nbAdded;
+}
+
#undef _TEMPLATE_
#undef _DTREE_