OCC22540 Regression: Exception during building of patch by GeomPlate
authorABV <>
Mon, 30 May 2011 14:38:43 +0000 (14:38 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:29:09 +0000 (19:29 +0400)
src/Extrema/Extrema_GenExtPS.cxx
src/Extrema/Extrema_HUBTreeOfSphere.cxx [deleted file]
src/Extrema/Extrema_HUBTreeOfSphere.hxx
src/Extrema/FILES
src/NCollection/NCollection_UBTree.hxx

index 1a1b132..0cf3008 100755 (executable)
@@ -322,7 +322,7 @@ void Extrema_GenExtPS::Initialize(const Adaptor3d_Surface& S,
 
   myF.Initialize(S);
 
-  mySphereUBTree.Clear();
+  mySphereUBTree.Nullify();
 
   if(myAlgo == Extrema_ExtAlgo_Grad)
   {
@@ -364,44 +364,37 @@ a- Constitution du tableau des distances (TbDist(0,myusample+1,0,myvsample+1)):
 
 void Extrema_GenExtPS::BuildTree()
 {
-       if(mySphereUBTree.IsEmpty())
-       {
-         Standard_Real PasU = myusup - myumin;
-         Standard_Real PasV = myvsup - myvmin;
-         Standard_Real U0 = PasU / myusample / 100.;
-         Standard_Real V0 = PasV / myvsample / 100.;
-         gp_Pnt P1;
-         PasU = (PasU - U0) / (myusample - 1);
-         PasV = (PasV - V0) / (myvsample - 1);
-         U0 = U0/2. + myumin;
-         V0 = V0/2. + myvmin;
-
-       // Calcul des distances
-
-         Standard_Integer NoU, NoV;
-         //mySphereUBTree.Clear();
-         Extrema_UBTreeFillerOfSphere aFiller(mySphereUBTree.ChangeTree());
-         Standard_Integer i = myusample * myvsample;
-         Standard_Real U, V;
-         /*for ( NoU = 1; NoU <= myusample; NoU++) {
-               for ( NoV = 1; NoV <= myvsample; NoV++) {
-                       i++;
-               }
-         }*/
-         mySphereArray = new Bnd_HArray1OfSphere(0, i);
-         i = 0;
-         for ( NoU = 1, U = U0; NoU <= myusample; NoU++, U += PasU) {
-               for ( NoV = 1, V = V0; NoV <= myvsample; NoV++, V += PasV) {
-                 P1 = myS->Value(U, V);
-                 //mypoints->SetValue(NoU, NoV, P1);
-                 Bnd_Sphere aSph(P1.XYZ(), 0/*mytolu < mytolv ? mytolu : mytolv*/, NoU, NoV);
-                 aFiller.Add(i, aSph);
-                 mySphereArray->SetValue( i, aSph );
-                 i++;
-               }
-         }
-         aFiller.Fill();
-       }
+  // if tree already exists, assume it is already correctly filled
+  if ( ! mySphereUBTree.IsNull() )
+    return;
+
+  Standard_Real PasU = myusup - myumin;
+  Standard_Real PasV = myvsup - myvmin;
+  Standard_Real U0 = PasU / myusample / 100.;
+  Standard_Real V0 = PasV / myvsample / 100.;
+  gp_Pnt P1;
+  PasU = (PasU - U0) / (myusample - 1);
+  PasV = (PasV - V0) / (myvsample - 1);
+  U0 = U0/2. + myumin;
+  V0 = V0/2. + myvmin;
+
+  // Calcul des distances
+  mySphereUBTree = new Extrema_UBTreeOfSphere;
+  Extrema_UBTreeFillerOfSphere aFiller(*mySphereUBTree);
+  Standard_Integer i = 0;
+  Standard_Real U, V;
+  mySphereArray = new Bnd_HArray1OfSphere(0, myusample * myvsample);
+  Standard_Integer NoU, NoV;
+  for ( NoU = 1, U = U0; NoU <= myusample; NoU++, U += PasU) {
+    for ( NoV = 1, V = V0; NoV <= myvsample; NoV++, V += PasV) {
+      P1 = myS->Value(U, V);
+      Bnd_Sphere aSph(P1.XYZ(), 0/*mytolu < mytolv ? mytolu : mytolv*/, NoU, NoV);
+      aFiller.Add(i, aSph);
+      mySphereArray->SetValue( i, aSph );
+      i++;
+    }
+  }
+  aFiller.Fill();
 }
 
 void Extrema_GenExtPS::FindSolution(const gp_Pnt& P, const math_Vector& UV, const Standard_Real PasU, const Standard_Real PasV, const Extrema_ExtFlag f)
@@ -611,7 +604,7 @@ void Extrema_GenExtPS::Perform(const gp_Pnt& P)
       Bnd_SphereUBTreeSelectorMin aSelector(mySphereArray, aSol);
       //aSelector.SetMaxDist( RealLast() );
       aSelector.DefineCheckPoint( P );
-      Standard_Integer aNbSel = mySphereUBTree.Select( aSelector );
+      Standard_Integer aNbSel = mySphereUBTree->Select( aSelector );
       //TODO: check if no solution in binary tree
       Bnd_Sphere& aSph = aSelector.Sphere();
 
@@ -626,7 +619,7 @@ void Extrema_GenExtPS::Perform(const gp_Pnt& P)
       Bnd_SphereUBTreeSelectorMax aSelector(mySphereArray, aSol);
       //aSelector.SetMaxDist( RealLast() );
       aSelector.DefineCheckPoint( P );
-      Standard_Integer aNbSel = mySphereUBTree.Select( aSelector );
+      Standard_Integer aNbSel = mySphereUBTree->Select( aSelector );
       //TODO: check if no solution in binary tree
       Bnd_Sphere& aSph = aSelector.Sphere();
 
diff --git a/src/Extrema/Extrema_HUBTreeOfSphere.cxx b/src/Extrema/Extrema_HUBTreeOfSphere.cxx
deleted file mode 100644 (file)
index 7efecee..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// File:      BestFitBnd_HUBTreeOfSphere.cxx
-// Created:   Thu Mar 17 14:30:42 2005
-// Author:    OPEN CASCADE Support
-// Copyright: OPEN CASCADE SA 2005
-
-#include <Extrema_HUBTreeOfSphere.hxx>
-
-IMPLEMENT_HUBTREE(Extrema_HUBTreeOfSphere,MMgt_TShared)
index 3ac845c..babe938 100644 (file)
@@ -8,10 +8,11 @@
 
 #include <NCollection_UBTree.hxx>
 #include <NCollection_UBTreeFiller.hxx>
+#include <NCollection_Handle.hxx>
 #include <Bnd_Sphere.hxx>
 
 typedef NCollection_UBTree<Standard_Integer,Bnd_Sphere> Extrema_UBTreeOfSphere;
 typedef NCollection_UBTreeFiller<Standard_Integer,Bnd_Sphere> Extrema_UBTreeFillerOfSphere;
-DEFINE_HUBTREE(Extrema_HUBTreeOfSphere, Standard_Integer, Bnd_Sphere, MMgt_TShared)
+typedef NCollection_Handle<Extrema_UBTreeOfSphere> Extrema_HUBTreeOfSphere;
 
 #endif //_Extrema_HUBTreeOfSphere_HeaderFile
index d9705ff..9aa286e 100644 (file)
@@ -1,2 +1 @@
 Extrema_HUBTreeOfSphere.hxx
-Extrema_HUBTreeOfSphere.cxx
index 3999278..f4e7545 100755 (executable)
@@ -485,9 +485,11 @@ class _HUBTREE : public _HPARENT                                        \
   DEFINE_STANDARD_RTTI (_HUBTREE)                                       \
   /* Type management */                                                 \
                                                                         \
- protected:                                                             \
-  _HUBTREE (UBTree *theTree) : myTree(theTree) {}                       \
-  /* Constructor from an existing tree. */                              \
+ private:                                                               \
+  /* Copying and assignment are prohibited  */                          \
+  _HUBTREE (UBTree*);                                                   \
+  _HUBTREE (const _HUBTREE&);                                           \
+  void operator = (const _HUBTREE&);                                    \
                                                                         \
  private:                                                               \
   UBTree       *myTree;        /* pointer to the tree algorithm */      \