]> OCCT Git - occt-copy.git/commitdiff
Fix for 3d offset algorithm
authorifv <ifv@opencascade.com>
Mon, 2 Feb 2015 13:00:19 +0000 (16:00 +0300)
committerifv <ifv@opencascade.com>
Mon, 2 Feb 2015 13:00:19 +0000 (16:00 +0300)
src/BRepOffset/BRepOffset_Analyse.cxx
src/BRepOffset/BRepOffset_MakeOffset.cxx
src/BiTgte/BiTgte_Blend.cxx

index ff16613a8ae24d179a7d978b3eb9605c02cd88e1..659d12786ab66520aeaad102e95febdea7edf9a7 100644 (file)
 
 #include <Precision.hxx>
 #include <gp.hxx>
-
+#include <BRepAdaptor_Surface.hxx>
+#include <Adaptor3d_Surface.hxx>
+//
+static void Correct2dPoint(const Adaptor3d_Surface& theS, gp_Pnt2d& theP2d);
 
 //=======================================================================
 //function : BRepOffset_Analyse
@@ -86,8 +89,7 @@ static void EdgeAnalyse(const TopoDS_Edge&         E,
   TopLoc_Location L;
   Standard_Real   f,l;
   
-  Handle (Geom_Surface) S1 = BRep_Tool::Surface(F1);
-  Handle (Geom_Surface) S2 = BRep_Tool::Surface(F2);
+  BRepAdaptor_Surface S1(F1), S2(F2);
   Handle (Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E,F1,f,l);
   Handle (Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E,F2,f,l);
 
@@ -99,7 +101,7 @@ static void EdgeAnalyse(const TopoDS_Edge&         E,
   if (BRep_Tool::HasContinuity(E,F1,F2)) {
     if (BRep_Tool::Continuity(E,F1,F2) > GeomAbs_C0) {
       BRepOffset_Interval I;
-       I.First(f); I.Last(l);
+           I.First(f); I.Last(l);
       I.Type(BRepOffset_Tangent);
       LI.Append(I);
       return;
@@ -123,13 +125,15 @@ static void EdgeAnalyse(const TopoDS_Edge&         E,
   gp_Pnt2d P  = C1->Value(ParOnC);
   gp_Pnt   P3;
   gp_Vec   D1U,D1V;
-  
-  S1->D1(P.X(),P.Y(),P3,D1U,D1V);
+
+  Correct2dPoint(S1, P);
+  S1.D1(P.X(),P.Y(),P3,D1U,D1V);
   gp_Vec DN1(D1U^D1V);
   if (F1.Orientation() == TopAbs_REVERSED) DN1.Reverse();
   
   P = C2->Value(ParOnC);
-  S2->D1(P.X(),P.Y(),P3,D1U,D1V);
+  Correct2dPoint(S2, P);
+  S2.D1(P.X(),P.Y(),P3,D1U,D1V);
   gp_Vec DN2(D1U^D1V);
   if (F2.Orientation() == TopAbs_REVERSED) DN2.Reverse();
 
@@ -529,3 +533,45 @@ void BRepOffset_Analyse::AddFaces (const TopoDS_Face&    Face,
     }
   }
 }
+
+//=======================================================================
+//function : Correct2dPoint
+//purpose  : 
+//=======================================================================
+void Correct2dPoint(const Adaptor3d_Surface& theS, gp_Pnt2d& theP2d)
+{
+  const Standard_Real coeff = 0.01;
+  Standard_Real eps;
+  Standard_Real u1, u2, v1, v2;
+  if(theS.GetType() >= GeomAbs_BezierSurface)
+  {
+    u1 = theS.FirstUParameter();
+    u2 = theS.LastUParameter();
+    v1 = theS.FirstVParameter();
+    v2 = theS.LastVParameter();
+    if(!(Precision::IsInfinite(u1) || Precision::IsInfinite(u2)))
+    {
+      eps = Max(coeff*(u2-u1), Precision::PConfusion());
+      if(Abs(theP2d.X()-u1) < eps)
+      {
+        theP2d.SetX(u1 + eps);
+      }
+      if(Abs(theP2d.X()-u2) < eps)
+      {
+        theP2d.SetX(u2 - eps);
+      }
+    }
+    if(!(Precision::IsInfinite(v1) || Precision::IsInfinite(v2)))
+    {
+      eps = Max(coeff*(v2-v1), Precision::PConfusion());
+      if(Abs(theP2d.Y()-v1) < eps)
+      {
+        theP2d.SetY(v1 + eps);
+      }
+      if(Abs(theP2d.Y()-v2) < eps)
+      {
+        theP2d.SetY(v2 - eps);
+      }
+    }
+  }
+}
\ No newline at end of file
index b659330b70a46da5b53723f105b88dde3fe61127..1919e8a12f19f5b9939674bb48021c8a85fc01f7 100644 (file)
   Standard_Boolean ChronBuild  = Standard_False;
   Standard_Integer NbAE        = 0;
   Standard_Integer NbAF        = 0;  
+  Standard_Integer NVP        = 0;  
+  Standard_Integer NVM        = 0;  
+  Standard_Integer NVN        = 0;  
   static OSD_Chronometer  Clock;
   char name[100];
 
@@ -1845,6 +1848,7 @@ void BRepOffset_MakeOffset::CorrectConicalFaces()
   Standard_Real TolApex = 1.e-5;
 
   Standard_Integer i;
+  Standard_Boolean isSphericalFaceAdded = Standard_False;
 
   TopTools_DataMapOfShapeListOfShape FacesOfCone;
   //TopTools_DataMapOfShapeShape DegEdges;
@@ -2152,13 +2156,17 @@ void BRepOffset_MakeOffset::CorrectConicalFaces()
     TopoDS_Shape theShell = Explo.Current();
     theShell.Free( Standard_True );
     BB.Add( theShell, NewSphericalFace );
+    isSphericalFaceAdded = Standard_True;
   }
 
-  Explo.Init( myOffsetShape, TopAbs_SHELL );
+  if(isSphericalFaceAdded)
+  {
+    Explo.Init( myOffsetShape, TopAbs_SHELL );
 
-  if (Explo.More()) {
-    TopoDS_Shape theShell = Explo.Current();
-    theShell.Closed( Standard_True );
+    if (Explo.More()) {
+      TopoDS_Shape theShell = Explo.Current();
+      theShell.Closed( Standard_True );
+    }
   }
 
 /*
index 96b7e38c0fd80a1b5c484b79beffabcf666991f9..0af5ddd11bce73d4164b641d63e1096ec9b5edd4 100644 (file)
@@ -2336,10 +2336,6 @@ void BiTgte_Blend::ComputeShape()
   
   BRep_Builder B;
 
-#ifdef DRAW
-  Standard_Integer NbNT = 1;
-#endif
-
   // Maj of the Map of created.
   // Update edges that do not change in the resulting shape 
   // i.e. invariant edges in the unwinding.