]> OCCT Git - occt-copy.git/commitdiff
0026185: BRepOffsetAPI_MakeOffset: regressions on some customer's cases
authorjgv <jgv@opencascade.com>
Thu, 28 May 2015 14:43:49 +0000 (17:43 +0300)
committerjgv <jgv@opencascade.com>
Thu, 28 May 2015 14:43:49 +0000 (17:43 +0300)
src/BRepFill/BRepFill_OffsetWire.cxx
src/BRepFill/BRepFill_TrimEdgeTool.cdl
src/BRepFill/BRepFill_TrimEdgeTool.cxx
src/Bisector/Bisector_Bisec.cdl
src/Bisector/Bisector_Bisec.cxx
src/Bisector/Bisector_BisecAna.cdl
src/Bisector/Bisector_BisecAna.cxx
src/MAT2d/MAT2d_Tool2d.cxx

index c8d81b284e9ae0ef41b2361eff68459bf565f6e2..98a48315e5e8f197f5cc0f32befa00bb0322f721 100755 (executable)
@@ -915,6 +915,9 @@ void BRepFill_OffsetWire::PerformWithBiLo
 //                                MapNodeVertex,VE);
     }
 
+    if (myJoinType == GeomAbs_Intersection)
+      StartOnEdge = EndOnEdge = 0;
+
     //---------------------------------------------
     // Construction of geometries.
     //---------------------------------------------
@@ -927,7 +930,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
     // Construction of vertices on edges parallel to the spine.
     //-----------------------------------------------------------
 
-    Trim.IntersectWith(E [0], E [1], Params);
+    Trim.IntersectWith(E [0], E [1], myJoinType, Params);
 
     for (Standard_Integer s = 1; s <= Params.Length(); s++) {
       TopoDS_Vertex VC;
index c7d1189d8f6d4c7d74244f6e4915b85152bc5087..7c265f864e6eb25495a5ab0316212d83a142e714 100755 (executable)
@@ -32,7 +32,8 @@ uses
     Curve         from Geom2d,
     Geometry      from Geom2d, 
     SequenceOfPnt from TColgp,
-    Curve         from Geom2dAdaptor
+    Curve         from Geom2dAdaptor,
+    JoinType      from GeomAbs
 
 is
     Create
@@ -45,6 +46,7 @@ is
     
     IntersectWith( me : in out;
                   Edge1 , Edge2 :        Edge          from TopoDS;
+                  theJoinType   :        JoinType      from GeomAbs;
                   Params        : in out SequenceOfPnt from TColgp)
     is static;
 
index 9a64bc6ee49478a5023080b6e5d16ba2cbe22cc5..2d6accb50e034efe8827e447ab74b785645e3bf6 100755 (executable)
@@ -306,7 +306,8 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
 
 void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
                                          const TopoDS_Edge& Edge2,
-                                               TColgp_SequenceOfPnt& Params)
+                                          const GeomAbs_JoinType theJoinType,
+                                          TColgp_SequenceOfPnt& Params)
 {
   Params.Clear();
 
@@ -484,6 +485,23 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
     Points2.Remove(Params.Length()+1, Points2.Length());
   }
 
+  NbPoints = Params.Length();
+
+  if (NbPoints > 0 && theJoinType == GeomAbs_Intersection)
+  {
+    //Remove all vertices with non-minimal parameter
+    Standard_Integer imin = 1;
+    for (i = 2; i <= NbPoints; i++)
+      if (Params(i).X() < Params(imin).X())
+        imin = i;
+    gp_Pnt Pnt1 = Params(imin);
+    gp_Pnt Pnt2 = Points2(imin);
+    Params.Clear();
+    Points2.Clear();
+    Params.Append(Pnt1);
+    Points2.Append(Pnt2);
+  }
+  
   NbPoints = Params.Length();
   for ( i = 1; i <= NbPoints; i++) {
     PSeq = Params(i);
index 2173d0ce80b328c0d7f7d77750aa3d78ff7bbd7d..2d3247b4cc5a54d3e14f08572ffaec3f91db051c 100755 (executable)
@@ -50,7 +50,8 @@ uses
     Point        from Geom2d  ,
     Pnt2d        from gp      ,
     Vec2d        from gp      ,
-    Integer      from Standard
+    Integer      from Standard,
+    JoinType     from GeomAbs
 
 is
     Create returns Bisec from Bisector;
@@ -62,6 +63,7 @@ is
             V1        : Vec2d   from gp                        ;
             V2        : Vec2d   from gp                        ;
             Sense     : Real    from Standard                  ;
+           ajointype : JoinType from GeomAbs                  ;
            Tolerance : Real    from Standard                  ;
            oncurve   : Boolean from Standard = Standard_True  );
           
index cd418ac6f9a107870fd44f75631c2978916d123b..ee469abcbd072f2a3a3346f6a49feb9487445829 100755 (executable)
@@ -81,6 +81,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
                             const gp_Vec2d&             afirstvector  ,
                             const gp_Vec2d&             asecondvector ,
                             const Standard_Real         adirection    ,
+                             const GeomAbs_JoinType      ajointype     ,
                             const Standard_Real         tolerance     ,
                             const Standard_Boolean      oncurve       )
 {
@@ -110,6 +111,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
                     afirstvector  ,
                     asecondvector ,
                     adirection    ,
+                     ajointype     ,
                     tolerance     ,
                     oncurve       );
      UFirst = BisAna->ParameterOfStartPoint();
index d4935e00e9f7afbe86989befdf854a6d55d4f3de..52de2dd2545c44b38839c6bf2fe14126b87dd13d 100755 (executable)
@@ -30,6 +30,7 @@ inherits
 uses
     Shape             from GeomAbs,
     CurveType         from GeomAbs,
+    JoinType          from GeomAbs,
     Curve             from Geom2d,
     Geometry          from Geom2d,    
     TrimmedCurve      from Geom2d,
@@ -52,6 +53,7 @@ is
             V1        : Vec2d   from gp                        ;
             V2        : Vec2d   from gp                        ;
             Sense     : Real    from Standard                  ;
+           jointype  : JoinType from GeomAbs                  ;
            Tolerance : Real    from Standard                  ;
            oncurve   : Boolean from Standard = Standard_True  );
           
@@ -128,7 +130,8 @@ is
              Sense :        Real    from Standard   ;
              U     :    out Real    from Standard   ;
             sense :    out Boolean from Standard   ;
-            ok    :    out Boolean from Standard   ) 
+            ok    :    out Boolean from Standard   ;
+            IsBisecOfTwoLines : Boolean from Standard = Standard_False)
         
         --- Purpose : Returns the distance between the point <P> and
         --            the bisecting <Bis>.
index 51735cf7c732b551e8d6b344cf586918465cb235..eac140a6086a1470a689657ebb1634d853af3b43 100755 (executable)
@@ -81,7 +81,8 @@ Standard_Real Bisector_BisecAna::Distance (
    const Standard_Real         adirection,
    Standard_Real&              aparameter,
    Standard_Boolean&           asense,
-   Standard_Boolean&           astatus)
+   Standard_Boolean&           astatus,
+   Standard_Boolean            IsBisecOfTwoLines)
 {
   astatus = Standard_True;
 
@@ -158,30 +159,33 @@ Standard_Real Bisector_BisecAna::Distance (
   else {
     asense = Standard_True;
 
-//  Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 Begin
-// Replacement of -1.E-8 for a tolerance 1.e-4
-    Standard_Real aTol = 1.e-4;
-
-    if ((afirstdir^secdirrev)*adirection < -0.1) {   // input
-      if((afirstdir^tangdir)*adirection < aTol &&
-        (secdirrev^tangdir)*adirection < aTol) asense = Standard_False;
-    }
-    else if((afirstdir^secdirrev)*adirection > 0.1) { // output
-      if((afirstdir^tangdir)*adirection < aTol ||
-        (secdirrev^tangdir)*adirection < aTol) asense = Standard_False;
-    }
-    else  {                                                // flat
-      if (afirstdir.Dot(secdirrev) > 0.) {                // tangent 
-       if ((afirstdir^tangdir)*adirection < 0.) asense = Standard_False;
+    if (!IsBisecOfTwoLines)
+    {
+      //  Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 Begin
+      // Replacement of -1.E-8 for a tolerance 1.e-4
+      Standard_Real aTol = 1.e-4;
+      
+      if ((afirstdir^secdirrev)*adirection < -0.1) {   // input
+        if((afirstdir^tangdir)*adirection < aTol &&
+           (secdirrev^tangdir)*adirection < aTol) asense = Standard_False;
       }
-      else{                                                // turn back
-//  Modified by Sergey KHROMOV - Thu Oct 31 14:16:53 2002
-//     if ((afirstdir.Dot(tangdir))*adirection > 0.) asense = Standard_False;
-       if (afirstdir.Dot(tangdir) < 0.) asense = Standard_False;
-//  Modified by Sergey KHROMOV - Thu Oct 31 14:16:54 2002
+      else if((afirstdir^secdirrev)*adirection > 0.1) { // output
+        if((afirstdir^tangdir)*adirection < aTol ||
+           (secdirrev^tangdir)*adirection < aTol) asense = Standard_False;
       }
+      else  {                                                // flat
+        if (afirstdir.Dot(secdirrev) > 0.) {                // tangent 
+          if ((afirstdir^tangdir)*adirection < 0.) asense = Standard_False;
+        }
+        else{                                                // turn back
+          //  Modified by Sergey KHROMOV - Thu Oct 31 14:16:53 2002
+          //   if ((afirstdir.Dot(tangdir))*adirection > 0.) asense = Standard_False;
+          if (afirstdir.Dot(tangdir) < 0.) asense = Standard_False;
+          //  Modified by Sergey KHROMOV - Thu Oct 31 14:16:54 2002
+        }
+      }
+      //  Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 End
     }
-//  Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 End
   }
   return distance;
 }
@@ -203,6 +207,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
                                const gp_Vec2d&             afirstvector  ,
                                const gp_Vec2d&             asecondvector ,
                                const Standard_Real         adirection    ,
+                                const GeomAbs_JoinType      ajointype     ,
                                const Standard_Real         tolerance     ,
                                const Standard_Boolean      oncurve       )
 {
@@ -632,14 +637,26 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
        }
        else if (type == GccInt_Par) {
          bisectorcurve = new Geom2d_Parabola(TheSol->Parabola());
+          Standard_Real FocalLength = ((Handle(Geom2d_Parabola)&)bisectorcurve)->Focal();
+          Standard_Real secondparameter = Precision::Infinite();
          if (!thesense)
+          {
+            if (ajointype == GeomAbs_Intersection &&
+                4.*FocalLength < firstparameter) //first parameter is too far from peak of parabola
+              secondparameter = 0.;
            thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
                                                  firstparameter,
-                                                 - Precision::Infinite());
+                                                 -secondparameter);
+          }
          else
+          {
+            if (ajointype == GeomAbs_Intersection &&
+                firstparameter < -4.*FocalLength) //first parameter is too far from peak of parabola
+              secondparameter = 0.;
            thebisector = new Geom2d_TrimmedCurve(bisectorcurve,
                                                  firstparameter,
-                                                 Precision::Infinite());
+                                                 secondparameter);
+          }
        }
       }
     }
@@ -721,7 +738,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
       else
        distanceptsol = Distance(apoint,solution,
                                 afirstvector,asecondvector,
-                                adirection,parameter,sense,ok);
+                                adirection,parameter,sense,ok, Standard_True);
 //  Modified by skv - Tue Feb 15 17:51:29 2005 Integration End
       if (ok || !oncurve) {
        thesense = sense;
index 8e149853ada6ec0b97be3f6a4a90bffa172a899e..097c72f97a960151d51b481697f15668c5ba45c7 100755 (executable)
@@ -349,7 +349,7 @@ void MAT2d_Tool2d::CreateBisector(const Handle(MAT_Bisector)& abisector)
                     GeomPnt (abisector->IssuePoint()),
                     GeomVec (abisector->FirstVector()),
                     GeomVec (abisector->SecondVector()),
-                    theDirection,tolerance,ontheline);
+                    theDirection,theJoinType,tolerance,ontheline);
   }
   else if(type1 == STANDARD_TYPE(Geom2d_CartesianPoint) && 
          type2 == STANDARD_TYPE(Geom2d_CartesianPoint)) {
@@ -658,6 +658,16 @@ Standard_Boolean MAT2d_Tool2d::IsSameDistance (
 
   Standard_Real EpsDist = MAT2d_TOLCONF*100. ;
   Distance = Dist(1);
+  if (theJoinType == GeomAbs_Intersection &&
+      Precision::IsInfinite(Distance))
+  {
+    for (Standard_Integer i = 2; i <= 4; i++)
+      if (!Precision::IsInfinite(Dist(i)))
+      {
+        Distance = Dist(i);
+        break;
+      }
+  }
   for (Standard_Integer i = 1; i <= 4; i++){
     if (theJoinType == GeomAbs_Intersection &&
         Precision::IsInfinite(Dist(i)))
@@ -1075,7 +1085,7 @@ void MAT2d_Tool2d::BisecFusion(const Standard_Integer I1,
     Handle(Bisector_BisecCC) BCC1 = Handle(Bisector_BisecCC)::DownCast(Bisector1->BasisCurve());
 
     Bis.Perform(BCC1->Curve(2), BCC1->Curve(1), P2, VBid, VBid, 
-               theDirection, Tolerance, Standard_False); 
+               theDirection, theJoinType, Tolerance, Standard_False); 
 
     Bisector1 = Handle(Geom2d_TrimmedCurve)::DownCast(Bis.Value());
     BCC1      = Handle(Bisector_BisecCC)   ::DownCast(Bisector1->BasisCurve());