0023945: GeomAdaptor_Surface fails to compute the first derivatives on the surface...
[occt.git] / src / QABugs / QABugs_19.cxx
index 492b375..7d575f4 100755 (executable)
@@ -387,8 +387,107 @@ static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const
  return 0;
 }
 
-#include <Geom_SurfaceOfRevolution.hxx> 
+#include <GeomConvert_ApproxSurface.hxx>
+#include <Geom_BSplineSurface.hxx>
+#include <Draw.hxx>
+#include <OSD_Thread.hxx>
+static void GeomConvertTest (Draw_Interpretor& di, Standard_Integer theTargetNbUPoles, Standard_CString theFileName)
+{
+       Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theFileName);
+       GeomConvert_ApproxSurface aGAS (aSurf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
+       if (!aGAS.IsDone()) {
+               di << "ApproxSurface is not done!" << "\n";
+               return;
+       }
+       const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
+       if (aBSurf.IsNull()) {
+               di << "BSplineSurface is not created!" << "\n";
+               return;
+       }
+       di << "Number of UPoles:" << aBSurf->NbUPoles() << "\n";
+       QCOMPARE (aBSurf->NbUPoles(), theTargetNbUPoles);
+}
+
+struct aData {
+       Draw_Interpretor* di;
+       Standard_Integer nbupoles;
+       Standard_CString filename;
+};
+
+Standard_EXPORT Standard_Address convert(Standard_Address data)
+{
+       aData* info = (aData*) data;
+       GeomConvertTest(*(info->di),info->nbupoles,info->filename);
+       return NULL;
+}
+
+static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+       if (argc != 3) {
+               di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
+               return 1;
+       }
+       struct aData aStorage;
+       aStorage.di = &di;
+       aStorage.nbupoles = Draw::Atoi(argv[1]); 
+       aStorage.filename = argv[2];
+
+       OSD_Thread aThread1(convert);
+       aThread1.Run(&aStorage);
+       GeomConvertTest(di,aStorage.nbupoles,aStorage.filename);
+
+       return 0;
+}
+
+#include <GeomInt_IntSS.hxx>
+static void GeomIntSSTest (Draw_Interpretor& di, Standard_Integer theNbSol, Standard_CString theFileName1, Standard_CString theFileName2)
+{
+       Handle(Geom_Surface) aSurf1 = DrawTrSurf::GetSurface(theFileName1);
+       Handle(Geom_Surface) aSurf2 = DrawTrSurf::GetSurface(theFileName2);
+       GeomInt_IntSS anInter;
+       anInter.Perform(aSurf1, aSurf2, Precision::Confusion(), Standard_True);
+       if (!anInter.IsDone()) {
+               di << "An intersection is not done!" << "\n";
+               return;
+       }
+
+       di << "Number of Lines:" << anInter.NbLines() << "\n";
+       QCOMPARE (anInter.NbLines(), theNbSol);
+}
+
+struct aNewData {
+       Draw_Interpretor* di;
+       Standard_Integer nbsol;
+       Standard_CString filename1;
+       Standard_CString filename2;
+};
+Standard_EXPORT Standard_Address convert_inter(Standard_Address data)
+{
+       aNewData* info = (aNewData*) data;
+       GeomIntSSTest(*(info->di),info->nbsol,info->filename1,info->filename2);
+       return NULL;
+}
 
+static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+       if (argc != 4) {
+               di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
+               return 1;
+       }
+       struct aNewData aStorage;
+       aStorage.di = &di;
+       aStorage.nbsol = Draw::Atoi(argv[1]); 
+       aStorage.filename1 = argv[2];
+       aStorage.filename2 = argv[3];
+
+       OSD_Thread aThread1(convert_inter);
+       aThread1.Run(&aStorage);
+       GeomIntSSTest(di,aStorage.nbsol,aStorage.filename1,aStorage.filename2);
+
+       return 0;
+}
+
+#include <Geom_SurfaceOfRevolution.hxx> 
 static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
 {
   if (argc < 2) {
@@ -466,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";
 
@@ -479,7 +641,15 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
   theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
   theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
+  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