0023945: GeomAdaptor_Surface fails to compute the first derivatives on the surface...
authorifv <ifv@opencascade.com>
Fri, 31 May 2013 13:13:38 +0000 (17:13 +0400)
committerifv <ifv@opencascade.com>
Fri, 31 May 2013 13:13:38 +0000 (17:13 +0400)
Add test case for this fix
Add new draw-command OCC23945 for testing this fix
Add new draw-command for testing tis fix

src/GeomAdaptor/GeomAdaptor_Surface.cdl
src/GeomAdaptor/GeomAdaptor_Surface.cxx
src/QABugs/QABugs_19.cxx
tests/bugs/moddata_3/bug23945 [new file with mode: 0755]

index b4b98c4..680c926 100755 (executable)
@@ -377,7 +377,7 @@ is
   
     Span (me;Side :Integer; Ideb,Ifin:Integer; 
             OutIdeb,OutIfin:out Integer; 
-            NbKnots : Integer ) 
+            FKIndx, LKIndx : Integer ) 
     is  private; 
 
     IfUVBound (me;U,V :Real;Ideb,Ifin,IVdeb,IVfin :out Integer; 
index c70ca8c..80bf9a6 100755 (executable)
@@ -1254,20 +1254,22 @@ Standard_Boolean GeomAdaptor_Surface::IfUVBound(const Standard_Real U,
                                                 const Standard_Integer VSide) const
 {
   Standard_Integer Ideb,Ifin;
+  Standard_Integer anUFKIndx = myBspl->FirstUKnotIndex(), 
+    anULKIndx = myBspl->LastUKnotIndex(), 
+    aVFKIndx = myBspl->FirstVKnotIndex(), aVLKIndx = myBspl->LastVKnotIndex();
   myBspl->LocateU(U, PosTol, Ideb, Ifin, Standard_False);
   Standard_Boolean Local = (Ideb == Ifin);
-  Span(USide,Ideb,Ifin,Ideb,Ifin,myBspl->NbUKnots());
+  Span(USide,Ideb,Ifin,Ideb,Ifin,anUFKIndx,anULKIndx);
   Standard_Integer IVdeb,IVfin;
   myBspl->LocateV(V, PosTol, IVdeb, IVfin, Standard_False); 
   if(IVdeb == IVfin) Local = Standard_True;
-  Span(VSide,IVdeb,IVfin,IVdeb,IVfin,myBspl->NbVKnots());
+  Span(VSide,IVdeb,IVfin,IVdeb,IVfin,aVFKIndx,aVLKIndx);
 
   IOutDeb=Ideb;   IOutFin=Ifin; 
   IOutVDeb=IVdeb; IOutVFin=IVfin;
 
   return Local;
 }     
-
 //=======================================================================
 //function : Span <private>
 //purpose  : locates U,V parameters if U=UFirst or U=ULast, 
@@ -1280,21 +1282,22 @@ void GeomAdaptor_Surface::Span(const Standard_Integer Side,
                                const Standard_Integer Ifin,
                                Standard_Integer& OutIdeb,
                                Standard_Integer& OutIfin,
-                               const Standard_Integer NbKnots) const
+                               const Standard_Integer theFKIndx,
+                               const Standard_Integer theLKIndx) const
 {
   if(Ideb!=Ifin)//not a knot
   { 
-    if(Ideb<1)                 { OutIdeb=1; OutIfin=2; }
-       else if(Ifin>NbKnots)      { OutIdeb=NbKnots-1; OutIfin=NbKnots; }
-       else if(Ideb>=(NbKnots-1)) { OutIdeb=NbKnots-1; OutIfin=NbKnots; }
-       else if(Ifin<=2)           { OutIdeb=1; OutIfin=2; }
+    if(Ideb<theFKIndx)                 { OutIdeb=theFKIndx; OutIfin=theFKIndx+1; }
+       else if(Ifin>theLKIndx)      { OutIdeb=theLKIndx-1; OutIfin=theLKIndx; }
+       else if(Ideb>=(theLKIndx-1)) { OutIdeb=theLKIndx-1; OutIfin=theLKIndx; }
+       else if(Ifin<=theFKIndx+1)           { OutIdeb=theFKIndx; OutIfin=theFKIndx+1; }
        else if(Ideb>Ifin)         { OutIdeb=Ifin-1;   OutIfin=Ifin; }
        else                       { OutIdeb=Ideb;   OutIfin=Ifin; }
   }
   else
   {
-    if(Ideb<=1){ OutIdeb=1;   OutIfin=2;}//first knot
-    else if(Ifin>=NbKnots) { OutIdeb=NbKnots-1;OutIfin=NbKnots;}//last knot
+    if(Ideb<=theFKIndx){ OutIdeb=theFKIndx;   OutIfin=theFKIndx+1;}//first knot
+    else if(Ifin>=theLKIndx) { OutIdeb=theLKIndx-1;OutIfin=theLKIndx;}//last knot
     else
     {
          if(Side==-1){OutIdeb=Ideb-1;   OutIfin=Ifin;}
index 70d1025..7d575f4 100755 (executable)
@@ -565,6 +565,69 @@ static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char**
   return 0;
 }
 
+#include <GeomAdaptor_Surface.hxx>
+#include <Draw.hxx>
+//=======================================================================
+//function : OCC23945
+//purpose  : 
+//=======================================================================
+
+static Standard_Integer OCC23945 (Draw_Interpretor& di,Standard_Integer n, const char** a)
+{
+  if (n < 5) return 1;
+
+  Handle(Geom_Surface) aS = DrawTrSurf::GetSurface(a[1]);
+  if (aS.IsNull()) return 1;
+
+  GeomAdaptor_Surface GS(aS);
+
+  Standard_Real U = Draw::Atof(a[2]);
+  Standard_Real V = Draw::Atof(a[3]);
+
+  Standard_Boolean DrawPoint = ( n%3 == 2);
+  if ( DrawPoint) n--;
+
+  gp_Pnt P;
+  if (n >= 13) {
+    gp_Vec DU,DV;
+    if (n >= 22) {
+      gp_Vec D2U,D2V,D2UV;
+      GS.D2(U,V,P,DU,DV,D2U,D2V,D2UV);
+      Draw::Set(a[13],D2U.X());
+      Draw::Set(a[14],D2U.Y());
+      Draw::Set(a[15],D2U.Z());
+      Draw::Set(a[16],D2V.X());
+      Draw::Set(a[17],D2V.Y());
+      Draw::Set(a[18],D2V.Z());
+      Draw::Set(a[19],D2UV.X());
+      Draw::Set(a[20],D2UV.Y());
+      Draw::Set(a[21],D2UV.Z());
+    }
+    else
+      GS.D1(U,V,P,DU,DV);
+
+    Draw::Set(a[7],DU.X());
+    Draw::Set(a[8],DU.Y());
+    Draw::Set(a[9],DU.Z());
+    Draw::Set(a[10],DV.X());
+    Draw::Set(a[11],DV.Y());
+    Draw::Set(a[12],DV.Z());
+  }
+  else 
+    GS.D0(U,V,P);
+
+  if ( n > 6) {
+    Draw::Set(a[4],P.X());
+    Draw::Set(a[5],P.Y());
+    Draw::Set(a[6],P.Z());
+  }
+  if ( DrawPoint) {
+    DrawTrSurf::Set(a[n],P);
+  }
+
+  return 0;
+}
+
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -581,5 +644,12 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC23952sweep", "OCC23952sweep nbupoles shape", __FILE__, OCC23952sweep, group);
   theCommands.Add ("OCC23952intersect", "OCC23952intersect nbsol shape1 shape2", __FILE__, OCC23952intersect, group);
   theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
+<<<<<<< HEAD
+  theCommands.Add("OCC23945", "OCC23945 surfname U V X Y Z [DUX DUY DUZ DVX DVY DVZ [D2UX D2UY D2UZ D2VX D2VY D2VZ D2UVX D2UVY D2UVZ]]", __FILE__, OCC23945,group);
+  return;}
+=======
+  theCommands.Add ("OCC23945", "OCC23945 surfname U V X Y Z [DUX DUY DUZ DVX DVY DVZ [D2UX D2UY D2UZ D2VX D2VY D2VZ D2UVX D2UVY D2UVZ]]", __FILE__, OCC23945, group);
+
   return;
 }
+>>>>>>> d003487... Add new draw-command for testing tis fix
diff --git a/tests/bugs/moddata_3/bug23945 b/tests/bugs/moddata_3/bug23945
new file mode 100755 (executable)
index 0000000..49c8bd6
--- /dev/null
@@ -0,0 +1,17 @@
+puts "================"
+puts "OCC23945"
+puts "================"
+puts ""
+###################################################
+## GeomAdaptor_Surface fails to compute the first derivatives on the surface of the attached face
+###################################################
+
+pload QAcommands
+
+restore [locate_data_file bug23945_f.brep] f
+
+mksurface s f
+
+OCC23945 s 0. -6.337359082e-009 x y z dux duy duz dvx dvy dvz
+
+set 2dviewer 0