]> OCCT Git - occt-copy.git/commitdiff
0023475: Wrong result of Geom_BSpline_Surface::IsVClosed()
authorgka <gka@opencascade.com>
Thu, 15 Nov 2012 11:35:03 +0000 (15:35 +0400)
committergka <gka@opencascade.com>
Thu, 15 Nov 2012 11:35:03 +0000 (15:35 +0400)
Modifications:
Definition closure surface by U and V by distance between isolines on bounds
Comparison to isolines on identity
Implementation of short dump of surface and curves
Change order of comparison

Fix and test script for bug 0023475
Modification of script to restore surface
Modification for correction regression ( UIso and VIso were confused)
Modified test case and test surface for bug 0023475

src/Geom/Geom_BSplineCurve.cdl
src/Geom/Geom_BSplineCurve_1.cxx
src/Geom/Geom_BSplineSurface_1.cxx
src/GeomliteTest/GeomliteTest_SurfaceCommands.cxx
tests/bugs/moddata/bug23475 [new file with mode: 0755]

index 83711c391f53022bb7df0145379fb413f81199e1..faf46d553c09e189db6b1b296baede988f879996 100755 (executable)
@@ -992,6 +992,9 @@ is
     is static private;
        ---Purpose : updates the cache and validates it
 
+  IsEqual(me; theOther : BSplineCurve from Geom; 
+  thePreci : Real from Standard  ) returns Boolean;
+    ---Purpose : Comapare two Bspline curve on identity;
   
        
 
index bdd16cc365d5a8e2f78aa93f6f8d48ae30e91072..f7c6405005ffb035f868e7de8d458a676bf07332 100755 (executable)
@@ -37,6 +37,7 @@
 #include <Standard_DomainError.hxx>
 #include <Standard_RangeError.hxx>
 #include <Standard_Mutex.hxx>
+#include <Precision.hxx>
 
 #define  POLES    (poles->Array1())
 #define  KNOTS    (knots->Array1())
@@ -827,3 +828,56 @@ void Geom_BSplineCurve::Resolution(const Standard_Real Tolerance3D,
   }
   UTolerance = Tolerance3D * maxderivinv;
 }
+
+//=======================================================================
+//function : IsEqual
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean Geom_BSplineCurve::IsEqual(const Handle(Geom_BSplineCurve)& theOther,
+                                            const Standard_Real thePreci) const
+{
+  if(  knots.IsNull() || poles.IsNull() || mults.IsNull() )
+    return Standard_False;
+  if( deg != theOther->Degree())
+    return Standard_False;
+  if( knots->Length() != theOther->NbKnots() ||
+    poles->Length() !=  theOther->NbPoles())
+    return Standard_False;
+
+  Standard_Integer i = 1;
+   for( i = 1 ; i <= poles->Length(); i++ )
+  {
+    const gp_Pnt& aPole1 = poles->Value(i);
+    const gp_Pnt& aPole2 =theOther->Pole(i);
+    if( fabs( aPole1.X() - aPole2.X() ) > thePreci ||
+      fabs( aPole1.Y() - aPole2.Y() ) > thePreci ||
+      fabs( aPole1.Z() - aPole2.Z() ) > thePreci )
+      return Standard_False;
+  }
+
+  for( ; i <= knots->Length(); i++ )
+  {
+    if( fabs(knots->Value(i) - theOther->Knot(i)) > Precision::Parametric(thePreci) )
+      return Standard_False;
+  }
+  
+  for( i = 1 ; i <= mults->Length(); i++ )
+  {
+    if( mults->Value(i) != theOther->Multiplicity(i) )
+      return Standard_False;
+  }
+
+  if( rational != theOther->IsRational())
+    return Standard_False;
+
+  if(!rational)
+    return Standard_True;
+
+  for( i = 1 ; i <= weights->Length(); i++ )
+  {
+    if( fabs( Standard_Real(weights->Value(i) - theOther->Weight(i))) > Epsilon(weights->Value(i)) )
+      return Standard_False;
+  }
+  return Standard_True;
+}
index 9ffc3a17d89d9915cd66130c64d71d2616736461..864c997f005e0d38f592f15033a8c46279d87411 100755 (executable)
@@ -1283,38 +1283,15 @@ Standard_Boolean Geom_BSplineSurface::IsUClosed () const
   if (uperiodic)
     return Standard_True;
 
-  Standard_Boolean Closed     = Standard_True;
-  TColgp_Array2OfPnt & VPoles = poles->ChangeArray2();
-  Standard_Integer PLower     = VPoles.LowerRow();
-  Standard_Integer PUpper     = VPoles.UpperRow();
-  Standard_Integer PLength    = VPoles.RowLength();
-  Standard_Integer j = VPoles.LowerCol();
-  if ( urational || vrational) {
-    TColStd_Array2OfReal & VWeights = weights->ChangeArray2();
-    Standard_Integer WLower = VWeights.LowerRow();
-    Standard_Integer WUpper = VWeights.UpperRow();
-    Standard_Real    Alfa = VWeights(WLower,VWeights.LowerCol());
-    Alfa /= VWeights(WUpper,VWeights.LowerCol());
-
-    Standard_Integer k = VWeights.LowerCol();
-    while (Closed && j <= PLength) {
-      Closed = 
-       (VPoles (PLower, j).Distance (VPoles (PUpper, j)) <= Precision::Confusion());
-      j++;
-      Closed = (Closed &&
-              ((VWeights(WLower,k) / VWeights(WUpper,k)) - Alfa) 
-                < Epsilon(Alfa));
-      k++;
-    }
-  }
-  else {
-    while (Closed && j <= PLength) {
-      Closed = 
-       (VPoles (PLower, j).Distance (VPoles (PUpper, j)) <= Precision::Confusion());
-      j++;
-    }
-  }
-  return Closed; 
+  Standard_Real aU1, aU2, aV1, aV2;
+  Bounds( aU1, aU2, aV1, aV2 );
+  Handle(Geom_Curve) aCUF = UIso( aU1 );
+  Handle(Geom_Curve) aCUL = UIso( aU2 );
+  if(aCUF.IsNull() || aCUL.IsNull())
+    return Standard_False;
+  Handle(Geom_BSplineCurve) aBsF = Handle(Geom_BSplineCurve)::DownCast(aCUF);
+  Handle(Geom_BSplineCurve) aBsL = Handle(Geom_BSplineCurve)::DownCast(aCUL);
+  return (!aBsF.IsNull() && !aBsL.IsNull() && aBsF->IsEqual( aBsL, Precision::Confusion()) ); 
 }
 
 //=======================================================================
@@ -1326,39 +1303,16 @@ Standard_Boolean Geom_BSplineSurface::IsVClosed () const
 {
   if (vperiodic)
     return Standard_True;
-
-  Standard_Boolean Closed     = Standard_True;
-  TColgp_Array2OfPnt & VPoles = poles->ChangeArray2();
-  Standard_Integer PLower     = VPoles.LowerCol();
-  Standard_Integer PUpper     = VPoles.UpperCol();
-  Standard_Integer PLength    = VPoles.ColLength();
-  Standard_Integer i = VPoles.LowerRow();
-  if ( urational || vrational) {
-    TColStd_Array2OfReal & VWeights = weights->ChangeArray2();
-    Standard_Integer WLower = VWeights.LowerCol();
-    Standard_Integer WUpper = VWeights.UpperCol();
-    Standard_Real    Alfa = VWeights(VWeights.LowerRow(),WLower);
-    Alfa /= VWeights(VWeights.LowerRow(),WUpper);
-
-    Standard_Integer k = VWeights.LowerRow();
-    while (Closed && i <= PLength) {
-      Closed = 
-       (VPoles (i, PLower).Distance (VPoles (i, PUpper)) <= Precision::Confusion());
-      i++;
-      Closed = (Closed &&
-              ((VWeights(k,WLower) / VWeights(k,WUpper)) - Alfa) 
-                < Epsilon(Alfa));
-      k++;
-    }
-  }
-  else {
-    while (Closed && i <= PLength) {
-      Closed = 
-       (VPoles (i, PLower).Distance (VPoles (i, PUpper)) <= Precision::Confusion());
-      i++;
-    }
-  }
-  return Closed; 
+  
+  Standard_Real aU1, aU2, aV1, aV2;
+  Bounds( aU1, aU2, aV1, aV2 );
+  Handle(Geom_Curve) aCVF = VIso( aV1 );
+  Handle(Geom_Curve) aCVL = VIso( aV2 );
+  if(aCVF.IsNull() || aCVL.IsNull())
+    return Standard_False;
+  Handle(Geom_BSplineCurve) aBsF = Handle(Geom_BSplineCurve)::DownCast(aCVF);
+  Handle(Geom_BSplineCurve) aBsL = Handle(Geom_BSplineCurve)::DownCast(aCVL);
+  return (!aBsF.IsNull() && !aBsL.IsNull() && aBsF->IsEqual(aBsL, Precision::Confusion())); 
 }
 
 //=======================================================================
index 566ae9e3bdfc9a81998281df53d3ccbce6da6a2a..ed4529530fdee958c8b36ada0b26680e2807aa12 100755 (executable)
@@ -1842,5 +1842,6 @@ void  GeomliteTest::SurfaceCommands(Draw_Interpretor& theCommands)
                   __FILE__,
                  surface_radius,g);
   theCommands.Add("compBsplSur","BsplSurf1 BSplSurf2",__FILE__,compBsplSur,g);
-
+  
+  
 }
diff --git a/tests/bugs/moddata/bug23475 b/tests/bugs/moddata/bug23475
new file mode 100755 (executable)
index 0000000..30150d5
--- /dev/null
@@ -0,0 +1,16 @@
+puts "============"
+puts "CR23475"
+puts "==========="
+puts ""
+###############################################################################
+# Wrong result of Geom_BSpline_Surface::IsVClosed()
+###############################################################################
+
+restore [locate_data_file bug23475.brep] s1
+set info [dump s1]
+
+if { [regexp "BSplineSurface vclosed" $info] != 1} {
+    puts "Error : surface is not closed by V"
+}
+
+