From 824694116aa51dd70d6453c54e141dc26feb8f67 Mon Sep 17 00:00:00 2001 From: ABV <> Date: Mon, 30 May 2011 14:38:43 +0000 Subject: [PATCH] OCC22540 Regression: Exception during building of patch by GeomPlate --- src/Extrema/Extrema_GenExtPS.cxx | 71 +++++++++++-------------- src/Extrema/Extrema_HUBTreeOfSphere.cxx | 8 --- src/Extrema/Extrema_HUBTreeOfSphere.hxx | 3 +- src/Extrema/FILES | 1 - src/NCollection/NCollection_UBTree.hxx | 8 +-- 5 files changed, 39 insertions(+), 52 deletions(-) delete mode 100644 src/Extrema/Extrema_HUBTreeOfSphere.cxx diff --git a/src/Extrema/Extrema_GenExtPS.cxx b/src/Extrema/Extrema_GenExtPS.cxx index 1a1b13231c..0cf3008b47 100755 --- a/src/Extrema/Extrema_GenExtPS.cxx +++ b/src/Extrema/Extrema_GenExtPS.cxx @@ -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; + // if tree already exists, assume it is already correctly filled + if ( ! mySphereUBTree.IsNull() ) + return; - // Calcul des distances + 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; - 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(); - } + // 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 index 7efecee57f..0000000000 --- a/src/Extrema/Extrema_HUBTreeOfSphere.cxx +++ /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 - -IMPLEMENT_HUBTREE(Extrema_HUBTreeOfSphere,MMgt_TShared) diff --git a/src/Extrema/Extrema_HUBTreeOfSphere.hxx b/src/Extrema/Extrema_HUBTreeOfSphere.hxx index 3ac845c289..babe93838b 100644 --- a/src/Extrema/Extrema_HUBTreeOfSphere.hxx +++ b/src/Extrema/Extrema_HUBTreeOfSphere.hxx @@ -8,10 +8,11 @@ #include #include +#include #include typedef NCollection_UBTree Extrema_UBTreeOfSphere; typedef NCollection_UBTreeFiller Extrema_UBTreeFillerOfSphere; -DEFINE_HUBTREE(Extrema_HUBTreeOfSphere, Standard_Integer, Bnd_Sphere, MMgt_TShared) +typedef NCollection_Handle Extrema_HUBTreeOfSphere; #endif //_Extrema_HUBTreeOfSphere_HeaderFile diff --git a/src/Extrema/FILES b/src/Extrema/FILES index d9705ffca9..9aa286ee6d 100644 --- a/src/Extrema/FILES +++ b/src/Extrema/FILES @@ -1,2 +1 @@ Extrema_HUBTreeOfSphere.hxx -Extrema_HUBTreeOfSphere.cxx diff --git a/src/NCollection/NCollection_UBTree.hxx b/src/NCollection/NCollection_UBTree.hxx index 39992787e4..f4e7545d2f 100755 --- a/src/NCollection/NCollection_UBTree.hxx +++ b/src/NCollection/NCollection_UBTree.hxx @@ -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 */ \