239343: OCC fails to work with offset surfaces with singularities
authorRoman Lygin <roman.lygin@gmail.com>
Thu, 23 May 2013 10:52:21 +0000 (14:52 +0400)
committerRoman Lygin <roman.lygin@gmail.com>
Thu, 23 May 2013 10:52:21 +0000 (14:52 +0400)
Add test cases for this fix

src/Geom/Geom_OsculatingSurface.cxx
src/ShapeAnalysis/ShapeAnalysis_Surface.cxx
tests/bugs/moddata_3/bug23943_1 [new file with mode: 0755]
tests/bugs/moddata_3/bug23943_2 [new file with mode: 0755]
tests/bugs/moddata_3/bug23943_3 [new file with mode: 0755]
tests/bugs/moddata_3/bug23943_4 [new file with mode: 0755]

index 5cc6f50..a358db9 100755 (executable)
@@ -62,7 +62,7 @@ void Geom_OsculatingSurface::Init(const Handle(Geom_Surface)& BS,
 {
   ClearOsculFlags();
   myTol=Tol; 
-  Standard_Real TolMin=1.e-12; 
+  Standard_Real TolMin=0.;//consider all singularities below Tol, not just above 1.e-12 (id23943)
   Standard_Boolean OsculSurf = Standard_True;
   myBasisSurf = Handle(Geom_Surface)::DownCast(BS->Copy());
   myOsculSurf1 = new Geom_HSequenceOfBSplineSurface();
@@ -78,7 +78,7 @@ void Geom_OsculatingSurface::Init(const Handle(Geom_Surface)& BS,
       myAlong.SetValue(2,IsQPunctual(BS,V2,GeomAbs_IsoV,TolMin,Tol));
       myAlong.SetValue(3,IsQPunctual(BS,U1,GeomAbs_IsoU,TolMin,Tol));
       myAlong.SetValue(4,IsQPunctual(BS,U2,GeomAbs_IsoU,TolMin,Tol));
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
       cout<<myAlong(1)<<endl<<myAlong(2)<<endl<<myAlong(3)<<endl<<myAlong(4)<<endl;
 #endif
       if (myAlong(1) || myAlong(2) || myAlong(3) || myAlong(4)) 
@@ -111,7 +111,7 @@ void Geom_OsculatingSurface::Init(const Handle(Geom_Surface)& BS,
            {
              InitSurf = Handle(Geom_BSplineSurface)::DownCast(myBasisSurf);
            }
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
          cout<<"UDEG: "<<InitSurf->UDegree()<<endl;
          cout<<"VDEG: "<<InitSurf->VDegree()<<endl;
 #endif
@@ -139,7 +139,7 @@ void Geom_OsculatingSurface::Init(const Handle(Geom_Surface)& BS,
                              OsculSurf  = BuildOsculatingSurface(V1,UKnot,VKnot,S,L);
                              if(!OsculSurf) break;
                              k++;
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
                              cout<<"1.k = "<<k<<endl;
 #endif
                              IsQPunc=IsQPunctual(L,V1,GeomAbs_IsoV,0.,Tol);
@@ -163,7 +163,7 @@ void Geom_OsculatingSurface::Init(const Handle(Geom_Surface)& BS,
                                  OsculSurf = BuildOsculatingSurface(V2,UKnot,VKnot,S,L);
                                  if(!OsculSurf) break;
                                  k++;
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
                                  cout<<"2.k = "<<k<<endl;
 #endif
                                  IsQPunc=IsQPunctual(L,V2,GeomAbs_IsoV,0.,Tol);
@@ -189,7 +189,7 @@ void Geom_OsculatingSurface::Init(const Handle(Geom_Surface)& BS,
                              OsculSurf = BuildOsculatingSurface(V2,UKnot,VKnot,S,L);
                              if(!OsculSurf) break;
                              k++;
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
                              cout<<"2.k = "<<k<<endl;
 #endif
                              IsQPunc=IsQPunctual(L,V2,GeomAbs_IsoV,0.,Tol);
@@ -222,7 +222,7 @@ void Geom_OsculatingSurface::Init(const Handle(Geom_Surface)& BS,
                              OsculSurf = BuildOsculatingSurface(U1,UKnot,VKnot,S,L);
                              if(!OsculSurf) break;
                              k++;
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
                              cout<<"1.k = "<<k<<endl;
 #endif
                              IsQPunc=IsQPunctual(L,U1,GeomAbs_IsoU,0.,Tol);
@@ -244,7 +244,7 @@ void Geom_OsculatingSurface::Init(const Handle(Geom_Surface)& BS,
                                  OsculSurf  = BuildOsculatingSurface(U2,UKnot,VKnot,S,L);
                                  if(!OsculSurf) break;
                                  k++;
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
                                  cout<<"2.k = "<<k<<endl;
 #endif
                                  IsQPunc=IsQPunctual(L,U2,GeomAbs_IsoU,0.,Tol);
@@ -269,7 +269,7 @@ void Geom_OsculatingSurface::Init(const Handle(Geom_Surface)& BS,
                              OsculSurf  = BuildOsculatingSurface(U2,UKnot,VKnot,S,L);
                              if(!OsculSurf) break;
                              k++;
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
                              cout<<"2.k = "<<k<<endl;
 #endif
                              IsQPunc=IsQPunctual(L,U2,GeomAbs_IsoU,0.,Tol);
@@ -447,7 +447,7 @@ Standard_Boolean  Geom_OsculatingSurface::BuildOsculatingSurface
 {
   Standard_Integer i, j;
   Standard_Boolean OsculSurf=Standard_True;
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
   cout<<"t = "<<Param<<endl;
   cout<<"======================================"<<endl<<endl;
 #endif
@@ -460,7 +460,7 @@ Standard_Boolean  Geom_OsculatingSurface::BuildOsculatingSurface
   vdeg = BS->VDegree();
   if( (IsAlongU() && vdeg <=1) || (IsAlongV() && udeg <=1))
   {
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
       cout<<" surface osculatrice nulle "<<endl;
 #endif
       //Standard_ConstructionError::Raise("Geom_OsculatingSurface");
@@ -503,7 +503,7 @@ Standard_Boolean  Geom_OsculatingSurface::BuildOsculatingSurface
       Standard_Integer OscUNumCoeff=0, OscVNumCoeff=0;
       if (IsAlongU()) 
       {
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
         cout<<">>>>>>>>>>> AlongU"<<endl;
 #endif
         OscUNumCoeff = (Standard_Integer ) udeg + 1;  
@@ -511,7 +511,7 @@ Standard_Boolean  Geom_OsculatingSurface::BuildOsculatingSurface
       }
       if (IsAlongV()) 
       {
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
         cout<<">>>>>>>>>>> AlongV"<<endl;
 #endif
         OscUNumCoeff = (Standard_Integer ) udeg;  
@@ -650,7 +650,7 @@ Standard_Boolean  Geom_OsculatingSurface::BuildOsculatingSurface
                                Data.UDegree(),
                                Data.VDegree(),
                                0, 0);
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
       cout<<"^====================================^"<<endl<<endl;
 #endif
 
@@ -687,7 +687,7 @@ Standard_Boolean Geom_OsculatingSurface::IsQPunctual
         D1NormMax=Max(D1NormMax,D1U.Magnitude());
       }
 
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
       cout << " D1NormMax = " << D1NormMax << endl;
 #endif
       if (D1NormMax >TolMax || D1NormMax < TolMin ) 
@@ -702,7 +702,7 @@ Standard_Boolean Geom_OsculatingSurface::IsQPunctual
        S->D1(Param,T,P,D1U,D1V);
         D1NormMax=Max(D1NormMax,D1V.Magnitude());
       }
-#ifdef DEB
+#if defined(DEB) && defined(OCCT_DEVELOPMENT)
       cout << " D1NormMax = " << D1NormMax << endl;
 #endif
       if (D1NormMax >TolMax || D1NormMax < TolMin ) 
index f365dc8..6230b39 100755 (executable)
@@ -997,9 +997,14 @@ gp_Pnt2d ShapeAnalysis_Surface::ValueOfUV(const gp_Pnt& P3D,const Standard_Real
 //  Forcer appel a IsU-VClosed
        if (myUCloseVal < 0) IsUClosed();
        if (myVCloseVal < 0) IsVClosed();
-       //modified by rln during fixing CSR # BUC60035 entity #D231
-       Standard_Real du = Min (myUDelt, SurfAdapt.UResolution (preci)),
-                     dv = Min (myVDelt, SurfAdapt.VResolution (preci));
+    Standard_Real du = 0., dv = 0.;
+    //extension of the surface range is limited to non-offset surfaces as the latter
+    //can throw exception (e.g. Geom_UndefinedValue) when computing value - see id23943
+    if (!mySurf->IsKind (STANDARD_TYPE (Geom_OffsetSurface))) {
+      //modified by rln during fixing CSR # BUC60035 entity #D231
+      du = Min (myUDelt, SurfAdapt.UResolution (preci));
+      dv = Min (myVDelt, SurfAdapt.VResolution (preci));
+    }
         myExtSrf = mySurf;
        Standard_Real Tol = Precision::PConfusion();
         myExtPS.SetFlag (Extrema_ExtFlag_MIN);
diff --git a/tests/bugs/moddata_3/bug23943_1 b/tests/bugs/moddata_3/bug23943_1
new file mode 100755 (executable)
index 0000000..2e0c9d7
--- /dev/null
@@ -0,0 +1,28 @@
+puts "============"
+puts "OCC23943"
+puts "============"
+puts ""
+#######################################################################
+# OCC fails to work with offset surfaces with singularities
+#######################################################################
+
+set BugNumber OCC23943
+
+pload XDE
+
+restore [locate_data_file bug23943_a.brep] s
+
+fixshape result s
+checkshape result
+
+regexp {EDGE +: +([-0-9.+eE]+)} [numshapes s] full EDGE_num_s
+
+regexp {EDGE +: +([-0-9.+eE]+)} [numshapes result] full EDGE_num_result
+
+if {${EDGE_num_result} != ${EDGE_num_s} || ${EDGE_num_result} == 0} {
+    puts "Faulty ${BugNumber}"
+} else {
+    puts "OK ${BugNumber}"
+}
+
+set 2dviewer 0
diff --git a/tests/bugs/moddata_3/bug23943_2 b/tests/bugs/moddata_3/bug23943_2
new file mode 100755 (executable)
index 0000000..4a3809b
--- /dev/null
@@ -0,0 +1,28 @@
+puts "============"
+puts "OCC23943"
+puts "============"
+puts ""
+#######################################################################
+# OCC fails to work with offset surfaces with singularities
+#######################################################################
+
+set BugNumber OCC23943
+
+pload XDE
+
+restore [locate_data_file bug23943_b.brep] s
+
+fixshape result s
+checkshape result
+
+regexp {EDGE +: +([-0-9.+eE]+)} [numshapes s] full EDGE_num_s
+
+regexp {EDGE +: +([-0-9.+eE]+)} [numshapes result] full EDGE_num_result
+
+if {${EDGE_num_result} != ${EDGE_num_s} || ${EDGE_num_result} == 0} {
+    puts "Faulty ${BugNumber}"
+} else {
+    puts "OK ${BugNumber}"
+}
+
+set 2dviewer 0
diff --git a/tests/bugs/moddata_3/bug23943_3 b/tests/bugs/moddata_3/bug23943_3
new file mode 100755 (executable)
index 0000000..771446d
--- /dev/null
@@ -0,0 +1,13 @@
+puts "============"
+puts "OCC23943"
+puts "============"
+puts ""
+#######################################################################
+# OCC fails to work with offset surfaces with singularities
+#######################################################################
+
+set BugNumber OCC23943
+
+restore [locate_data_file bug23943_s.brep] s
+
+proj s 12.0565, 36.7424, -9.68517
diff --git a/tests/bugs/moddata_3/bug23943_4 b/tests/bugs/moddata_3/bug23943_4
new file mode 100755 (executable)
index 0000000..3e6f5ae
--- /dev/null
@@ -0,0 +1,13 @@
+puts "============"
+puts "OCC23943"
+puts "============"
+puts ""
+#######################################################################
+# OCC fails to work with offset surfaces with singularities
+#######################################################################
+
+set BugNumber OCC23943
+
+restore [locate_data_file bug23943_s.brep] s
+
+proj s 4.99019, 38.0944, -11.244