0031303: Different calculation of offset direction in Adaptor2d_OffsetCurve and Geom2...
authorifv <ifv@opencascade.com>
Tue, 25 Feb 2020 08:27:28 +0000 (11:27 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 11 Mar 2020 13:37:50 +0000 (16:37 +0300)
Calculations in Adaptor2d_OffsetCurve are unified with similar calculations in Geom2d_OffsetCurve using   methods extracted from Geom2dEvaluator_OffsetCurve to Geom2dEvaluator.cxx

BRepFill_OffsetWire.cxx, Geom2dGcc_Circ2d2TanRadGeo.cxx, Geom2dGcc_Circ2dTanOnRadGeo.cxx, MAT2d_Circuit.cxx are modified to satisfy changing offset direction.

12 files changed:
dox/dev_guides/upgrade/upgrade.md
src/Adaptor2d/Adaptor2d_OffsetCurve.cxx
src/Adaptor2d/Adaptor2d_OffsetCurve.hxx
src/BRepFill/BRepFill_OffsetWire.cxx
src/Geom2dEvaluator/FILES
src/Geom2dEvaluator/Geom2dEvaluator.cxx [new file with mode: 0644]
src/Geom2dEvaluator/Geom2dEvaluator.hxx [new file with mode: 0644]
src/Geom2dEvaluator/Geom2dEvaluator_OffsetCurve.cxx
src/Geom2dEvaluator/Geom2dEvaluator_OffsetCurve.hxx
src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx
src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx
src/MAT2d/MAT2d_Circuit.cxx

index 5ea184c..c8e21c1 100644 (file)
@@ -1902,3 +1902,9 @@ void BOPTools_AlgoTools::TreatCompound (const TopoDS_Shape& theS,
                                         TopTools_ListOfShape& theLS,
                                         TopTools_MapOfShape* theMap = NULL);
 ~~~~
+
+@subsection upgrade_750_Adaptor2d_OffsetCurve  Offset direction change
+
+Offset direction, which used in class Adaptor2d_OffsetCurve for evaluating values and derivatives of offset curve is unified for offset direction used in class Geom2d_OffsetCurve: now offset direction points to outer ("right") side of base curve instead of the previously used inner ("left") side. Old usage of class in any application should be changed something like that:
+
+Adaptor2d_OffsetCurve aOC(BaseCurve, Offset) --> Adaptor2d_OffsetCurve aOC(BaseCurve, -Offset)
index 3f45876..66be2af 100644 (file)
@@ -17,6 +17,7 @@
 #include <Adaptor2d_OffsetCurve.hxx>
 #include <Geom2d_BezierCurve.hxx>
 #include <Geom2d_BSplineCurve.hxx>
+#include <Geom2dEvaluator.hxx>
 #include <GeomAbs_SurfaceType.hxx>
 #include <gp.hxx>
 #include <gp_Ax22d.hxx>
@@ -33,7 +34,6 @@
 #include <Standard_DomainError.hxx>
 #include <Standard_NoSuchObject.hxx>
 #include <Standard_NotImplemented.hxx>
-#include <Standard_OutOfRange.hxx>
 #include <Standard_TypeMismatch.hxx>
 
 //=======================================================================
@@ -112,7 +112,6 @@ void Adaptor2d_OffsetCurve::Load( const Standard_Real Offset)
   myOffset = Offset;
   myFirst = myCurve->FirstParameter();
   myLast = myCurve->LastParameter();
-  
 }
 
 //=======================================================================
@@ -299,18 +298,11 @@ Standard_Real Adaptor2d_OffsetCurve::Period() const
 gp_Pnt2d Adaptor2d_OffsetCurve::Value(const Standard_Real U) const
 {
   if ( myOffset != 0.) {
-    gp_Pnt2d P;
-    gp_Vec2d V;
-    Standard_Real Norme;
-    myCurve->D1(U, P, V);
-    Norme = V.Magnitude();
-    V.SetCoord(-V.Y(),V.X());
-    if (Norme >= gp::Resolution()) {
-      return gp_Pnt2d(P.XY()+myOffset*V.XY()/Norme);
-    }
-    else {
-      throw gp_VectorWithNullMagnitude("Adaptor2d_OffsetCurve::Value");
-    }
+    gp_Pnt2d aP;
+    gp_Vec2d aV;
+    myCurve->D1(U, aP, aV);
+    Geom2dEvaluator::CalculateD0(aP, aV, myOffset);
+    return aP;
   }
   else {
     return myCurve->Value(U);
@@ -333,28 +325,15 @@ void Adaptor2d_OffsetCurve::D0(const Standard_Real U, gp_Pnt2d& P) const
 //=======================================================================
 
 void Adaptor2d_OffsetCurve::D1
-  (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V) const
-{
-  gp_Vec2d V1,V2,V3;
-  gp_Pnt2d PP;
-  Standard_Real Norme;
-  if ( myOffset != 0. ) {
-    myCurve->D2(U,PP,V1,V2);
-    Norme = V1.Magnitude();
-    V3.SetCoord( -V1.Y(),V1.X());
-    V2.SetCoord( -V2.Y(),V2.X());
-    if ( Norme >= gp::Resolution()) {
-      P = gp_Pnt2d( PP.XY()+myOffset*V3.XY()/Norme);
-      V = gp_Vec2d( V1.XY()+
-                  (myOffset/Norme)*(V2.XY()-V3.XY()*
-                                   (V2.XY()*V3.XY())/(Norme*Norme)));
-    }
-    else {
-      throw gp_VectorWithNullMagnitude("Adaptor2d_OffsetCurve::D1");
-    }
+(const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V) const
+{
+  if (myOffset != 0.) {
+    gp_Vec2d aV2;
+    myCurve->D2(U, P, V, aV2);
+    Geom2dEvaluator::CalculateD1( P, V, aV2, myOffset);
   }
   else {
-    myCurve->D1(U,P,V);
+    myCurve->D1(U, P, V);
   }
 }
 
@@ -364,38 +343,15 @@ void Adaptor2d_OffsetCurve::D1
 //=======================================================================
 
 void Adaptor2d_OffsetCurve::D2
-  (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
+(const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
 {
-  if ( myOffset != 0.) {
-    gp_Vec2d T1,T2,T3;
-    gp_Pnt2d PP;
-    Standard_Real Norme;
-    myCurve->D3(U,PP,T1,T2,T3);
-
-    Norme = T1.Magnitude();
-    if ( Norme >= gp::Resolution()) {
-      gp_Vec2d N1,N2,N3;             // Ni = Z ^ Ti
-      N1.SetCoord( -T1.Y(), T1.X());
-      N2.SetCoord( -T2.Y(), T2.X());
-      N3.SetCoord( -T3.Y(), T3.X());
-      Standard_Real d12,d13,d22,Nor3,Nor11;
-      d12   = T1*T2;
-      d22   = T2*T2;
-      d13   = T1*T3;
-      Nor3  = Norme*Norme*Norme;
-      Nor11 = Nor3*Nor3*Nor3*Norme*Norme;
-      V2    = gp_Vec2d( -1 * ( (d22+d13)/Nor3 + 3*d12*d12/Nor11) * N1.XY());
-      V2    = gp_Vec2d( V2.XY() - (2*d12/Nor3)*N2.XY() + N3.XY()/Norme);
-      V2    = gp_Vec2d( myOffset*V2.XY() + T2.XY());
-
-      D1( U,P,V1);
-    }
-    else {
-      throw gp_VectorWithNullMagnitude("Adaptor2d_OffsetCurve::D2");
-    }
+  if (myOffset != 0.) {
+    gp_Vec2d aV3;
+    myCurve->D3(U, P, V1, V2, aV3);
+    Geom2dEvaluator::CalculateD2(P, V1, V2, aV3, Standard_False, myOffset);
   }
   else {
-    myCurve->D2(U,P,V1,V2);
+    myCurve->D2(U, P, V1, V2);
   }
 }
 
@@ -404,14 +360,18 @@ void Adaptor2d_OffsetCurve::D2
 //purpose  : 
 //=======================================================================
 
-//void Adaptor2d_OffsetCurve::D3
-//  (const Standard_Real T, 
-//   gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const
 void Adaptor2d_OffsetCurve::D3
-  (const Standard_Real , 
-   gp_Pnt2d& , gp_Vec2d& , gp_Vec2d& , gp_Vec2d& ) const
+  (const Standard_Real U
+   gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const
 {
-  throw Standard_NotImplemented("Adaptor2d_OffsetCurve::D3");
+  if (myOffset != 0.) {
+    gp_Vec2d aV4 = myCurve->DN(U, 4);
+    myCurve->D3(U, P, V1, V2, V3);
+    Geom2dEvaluator::CalculateD3(P, V1, V2, V3, aV4, Standard_False, myOffset);
+  }
+  else {
+    myCurve->D3(U, P, V1, V2, V3);
+  }
 }
 
 //=======================================================================
@@ -420,7 +380,6 @@ void Adaptor2d_OffsetCurve::D3
 //=======================================================================
 
 gp_Vec2d Adaptor2d_OffsetCurve::DN
-//  (const Standard_Real T, const Standard_Integer N) const
   (const Standard_Real , const Standard_Integer ) const
 {
   throw Standard_NotImplemented("Adaptor2d_OffsetCurve::DN");
index fc379a0..7b3cc2f 100644 (file)
@@ -193,7 +193,6 @@ private:
   Standard_Real myFirst;
   Standard_Real myLast;
 
-
 };
 
 
index 1e313fe..7e48817 100644 (file)
@@ -275,9 +275,9 @@ static Standard_Boolean KPartCircle
     Handle(Geom2d_Curve) OC;
     if (AHC->GetType() == GeomAbs_Line)
     {
-      if (E.Orientation() == TopAbs_REVERSED)
+      if (E.Orientation() == TopAbs_FORWARD)
         anOffset *= -1;
-      Adaptor2d_OffsetCurve Off(AHC,anOffset);
+      Adaptor2d_OffsetCurve Off(AHC, anOffset);
       OC = new Geom2d_Line(Off.Line());
     }
     else if (AHC->GetType() == GeomAbs_Circle)
@@ -298,7 +298,7 @@ static Standard_Boolean KPartCircle
       if (E.Orientation() == TopAbs_FORWARD)
         anOffset *= -1;
       Handle(Geom2d_TrimmedCurve) G2dT = new Geom2d_TrimmedCurve(aPCurve, f, l);
-      OC = new Geom2d_OffsetCurve( G2dT, anOffset);
+      OC = new Geom2d_OffsetCurve(G2dT, anOffset);
     }
     Handle(Geom_Surface) aSurf = BRep_Tool::Surface(mySpine);
     Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurf);
@@ -2032,7 +2032,7 @@ void MakeOffset (const TopoDS_Edge&        E,
   Standard_Real f,l;
   Standard_Real anOffset = Offset;
 
-  if (E.Orientation() == TopAbs_REVERSED) anOffset *= -1;
+  if (E.Orientation() == TopAbs_FORWARD) anOffset *= -1;
 
   Handle(Geom2d_Curve) G2d = BRep_Tool::CurveOnSurface(E,F,f,l);
   Handle(Geom2d_Curve) G2dOC;
@@ -2060,14 +2060,14 @@ void MakeOffset (const TopoDS_Edge&        E,
     gp_Dir2d Xd = axes.XDirection();
     gp_Dir2d Yd = axes.YDirection();
     Standard_Real Crossed = Xd.X()*Yd.Y()-Xd.Y()*Yd.X();
-    Standard_Real Signe = ( Crossed > 0.) ? 1. : -1.;
+    Standard_Real Signe = ( Crossed > 0.) ? -1. : 1.;
 
     if (anOffset*Signe < AC.Circle().Radius() - Precision::Confusion()) {
 
       Handle(Geom2dAdaptor_HCurve) AHC = 
         new Geom2dAdaptor_HCurve(G2d);
-      Adaptor2d_OffsetCurve   Off(AHC,-anOffset);
-      Handle(Geom2d_Circle) CC = new Geom2d_Circle(Off.Circle());      
+      Adaptor2d_OffsetCurve   Off(AHC, anOffset);
+      Handle(Geom2d_Circle) CC = new Geom2d_Circle(Off.Circle());
 
       Standard_Real Delta = 2*M_PI - l + f;
       if (theJoinType == GeomAbs_Arc)
@@ -2101,7 +2101,7 @@ void MakeOffset (const TopoDS_Edge&        E,
   else if (AC.GetType() == GeomAbs_Line) {
     Handle(Geom2dAdaptor_HCurve) AHC = 
       new Geom2dAdaptor_HCurve(G2d);
-    Adaptor2d_OffsetCurve Off(AHC,anOffset);
+    Adaptor2d_OffsetCurve Off(AHC, anOffset);
     Handle(Geom2d_Line)       CC = new Geom2d_Line(Off.Line());
     Standard_Real Delta = (l - f);
     if (ToExtendFirstPar)
@@ -2122,7 +2122,6 @@ void MakeOffset (const TopoDS_Edge&        E,
   }
   else {
 
-    anOffset = -anOffset;
     Handle(Geom2d_TrimmedCurve) G2dT = new Geom2d_TrimmedCurve(G2d,f,l);
     G2dOC = new Geom2d_OffsetCurve( G2dT, anOffset);
 
index 3eb8ed1..c1a4577 100644 (file)
@@ -1,3 +1,5 @@
 Geom2dEvaluator_Curve.hxx
 Geom2dEvaluator_OffsetCurve.cxx
 Geom2dEvaluator_OffsetCurve.hxx
+Geom2dEvaluator.hxx
+Geom2dEvaluator.cxx
\ No newline at end of file
diff --git a/src/Geom2dEvaluator/Geom2dEvaluator.cxx b/src/Geom2dEvaluator/Geom2dEvaluator.cxx
new file mode 100644 (file)
index 0000000..1f4f5f9
--- /dev/null
@@ -0,0 +1,239 @@
+// Created on: 2015-09-21
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Geom2dEvaluator.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec2d.hxx>
+#include <gp_XY.hxx>
+#include <Standard_NullValue.hxx>
+
+//=======================================================================
+//function : CalculateD0
+//purpose  : 
+//=======================================================================
+void Geom2dEvaluator::CalculateD0( gp_Pnt2d& theValue,
+                                   const gp_Vec2d& theD1, const Standard_Real theOffset)
+{
+  if (theD1.SquareMagnitude() <= gp::Resolution())
+    throw Standard_NullValue("Geom2dEvaluator: Undefined normal vector "
+                             "because tangent vector has zero-magnitude!");
+
+  gp_Dir2d aNormal(theD1.Y(), -theD1.X());
+  theValue.ChangeCoord().Add(aNormal.XY() * theOffset);
+}
+
+//=======================================================================
+//function : CalculateD1
+//purpose  : 
+//=======================================================================
+void Geom2dEvaluator::CalculateD1(gp_Pnt2d& theValue,
+                                  gp_Vec2d& theD1,
+                                  const gp_Vec2d& theD2, const Standard_Real theOffset)
+{
+  // P(u) = p(u) + Offset * Ndir / R
+  // with R = || p' ^ Z|| and Ndir = P' ^ Z
+
+  // P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R -  Ndir * (DR/R))
+
+  gp_XY Ndir(theD1.Y(), -theD1.X());
+  gp_XY DNdir(theD2.Y(), -theD2.X());
+  Standard_Real R2 = Ndir.SquareModulus();
+  Standard_Real R = Sqrt(R2);
+  Standard_Real R3 = R * R2;
+  Standard_Real Dr = Ndir.Dot(DNdir);
+  if (R3 <= gp::Resolution())
+  {
+    if (R2 <= gp::Resolution())
+      throw Standard_NullValue("Geom2dEvaluator_OffsetCurve: Null derivative");
+    //We try another computation but the stability is not very good.
+    DNdir.Multiply(R);
+    DNdir.Subtract(Ndir.Multiplied(Dr / R));
+    DNdir.Multiply(theOffset / R2);
+  }
+  else
+  {
+    // Same computation as IICURV in EUCLID-IS because the stability is better
+    DNdir.Multiply(theOffset / R);
+    DNdir.Subtract(Ndir.Multiplied(theOffset * Dr / R3));
+  }
+
+  Ndir.Multiply(theOffset / R);
+  // P(u)
+  theValue.ChangeCoord().Add(Ndir);
+  // P'(u)
+  theD1.Add(gp_Vec2d(DNdir));
+}
+
+//=======================================================================
+//function : CalculateD2
+//purpose  : 
+//=======================================================================
+void Geom2dEvaluator::CalculateD2( gp_Pnt2d& theValue,
+                                                    gp_Vec2d& theD1,
+                                                    gp_Vec2d& theD2,
+                                              const gp_Vec2d& theD3,
+                                              const Standard_Boolean theIsDirChange, const Standard_Real theOffset) 
+{
+  // P(u) = p(u) + Offset * Ndir / R
+  // with R = || p' ^ Z|| and Ndir = P' ^ Z
+
+  // P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R -  Ndir * (DR/R))
+
+  // P"(u) = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
+  //         Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
+
+  gp_XY Ndir(theD1.Y(), -theD1.X());
+  gp_XY DNdir(theD2.Y(), -theD2.X());
+  gp_XY D2Ndir(theD3.Y(), -theD3.X());
+  Standard_Real R2 = Ndir.SquareModulus();
+  Standard_Real R = Sqrt(R2);
+  Standard_Real R3 = R2 * R;
+  Standard_Real R4 = R2 * R2;
+  Standard_Real R5 = R3 * R2;
+  Standard_Real Dr = Ndir.Dot(DNdir);
+  Standard_Real D2r = Ndir.Dot(D2Ndir) + DNdir.Dot(DNdir);
+  if (R5 <= gp::Resolution())
+  {
+    if (R4 <= gp::Resolution())
+      throw Standard_NullValue("Geom2dEvaluator: Null derivative");
+    //We try another computation but the stability is not very good dixit ISG.
+    // V2 = P" (U) :
+    D2Ndir.Subtract(DNdir.Multiplied(2.0 * Dr / R2));
+    D2Ndir.Add(Ndir.Multiplied(((3.0 * Dr * Dr) / R4) - (D2r / R2)));
+    D2Ndir.Multiply(theOffset / R);
+
+    // V1 = P' (U) :
+    DNdir.Multiply(R);
+    DNdir.Subtract(Ndir.Multiplied(Dr / R));
+    DNdir.Multiply(theOffset / R2);
+  }
+  else
+  {
+    // Same computation as IICURV in EUCLID-IS because the stability is better.
+    // V2 = P" (U) :
+    D2Ndir.Multiply(theOffset / R);
+    D2Ndir.Subtract(DNdir.Multiplied(2.0 * theOffset * Dr / R3));
+    D2Ndir.Add(Ndir.Multiplied(theOffset * (((3.0 * Dr * Dr) / R5) - (D2r / R3))));
+
+    // V1 = P' (U) 
+    DNdir.Multiply(theOffset / R);
+    DNdir.Subtract(Ndir.Multiplied(theOffset * Dr / R3));
+  }
+
+  Ndir.Multiply(theOffset / R);
+  // P(u)
+  theValue.ChangeCoord().Add(Ndir);
+  // P'(u) :
+  theD1.Add(gp_Vec2d(DNdir));
+  // P"(u) :
+  if (theIsDirChange)
+    theD2.Reverse();
+  theD2.Add(gp_Vec2d(D2Ndir));
+}
+
+//=======================================================================
+//function : CalculateD3
+//purpose  : 
+//=======================================================================
+void Geom2dEvaluator::CalculateD3(      gp_Pnt2d& theValue,
+                                                    gp_Vec2d& theD1,
+                                                    gp_Vec2d& theD2,
+                                                    gp_Vec2d& theD3,
+                                              const gp_Vec2d& theD4,
+                                              const Standard_Boolean theIsDirChange, const Standard_Real theOffset) 
+{
+  // P(u) = p(u) + Offset * Ndir / R
+  // with R = || p' ^ Z|| and Ndir = P' ^ Z
+
+  // P'(u)  = p'(u) + (Offset / R**2) * (DNdir/DU * R -  Ndir * (DR/R))
+
+  // P"(u)  = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
+  //          Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
+
+  // P"'(u) = p"'(u) + (Offset / R) * (D3Ndir - (3.0 * Dr/R**2 ) * D2Ndir -
+  //          (3.0 * D2r / R2) * DNdir) + (3.0 * Dr * Dr / R4) * DNdir -
+  //          (D3r/R2) * Ndir + (6.0 * Dr * Dr / R4) * Ndir +
+  //          (6.0 * Dr * D2r / R4) * Ndir - (15.0 * Dr* Dr* Dr /R6) * Ndir
+
+  gp_XY Ndir(theD1.Y(), -theD1.X());
+  gp_XY DNdir(theD2.Y(), -theD2.X());
+  gp_XY D2Ndir(theD3.Y(), -theD3.X());
+  gp_XY D3Ndir(theD4.Y(), -theD4.X());
+  Standard_Real R2 = Ndir.SquareModulus();
+  Standard_Real R = Sqrt(R2);
+  Standard_Real R3 = R2 * R;
+  Standard_Real R4 = R2 * R2;
+  Standard_Real R5 = R3 * R2;
+  Standard_Real R6 = R3 * R3;
+  Standard_Real R7 = R5 * R2;
+  Standard_Real Dr = Ndir.Dot(DNdir);
+  Standard_Real D2r = Ndir.Dot(D2Ndir) + DNdir.Dot(DNdir);
+  Standard_Real D3r = Ndir.Dot(D3Ndir) + 3.0 * DNdir.Dot(D2Ndir);
+
+  if (R7 <= gp::Resolution())
+  {
+    if (R6 <= gp::Resolution())
+      throw Standard_NullValue("Geom2dEvaluator: Null derivative");
+    //We try another computation but the stability is not very good dixit ISG.
+    // V3 = P"' (U) :
+    D3Ndir.Subtract(D2Ndir.Multiplied(3.0 * theOffset * Dr / R2));
+    D3Ndir.Subtract(
+      (DNdir.Multiplied((3.0 * theOffset) * ((D2r / R2) + (Dr*Dr) / R4))));
+    D3Ndir.Add(Ndir.Multiplied(
+      (theOffset * (6.0*Dr*Dr / R4 + 6.0*Dr*D2r / R4 - 15.0*Dr*Dr*Dr / R6 - D3r))));
+    D3Ndir.Multiply(theOffset / R);
+    // V2 = P" (U) :
+    R4 = R2 * R2;
+    D2Ndir.Subtract(DNdir.Multiplied(2.0 * Dr / R2));
+    D2Ndir.Subtract(Ndir.Multiplied(((3.0 * Dr * Dr) / R4) - (D2r / R2)));
+    D2Ndir.Multiply(theOffset / R);
+    // V1 = P' (U) :
+    DNdir.Multiply(R);
+    DNdir.Subtract(Ndir.Multiplied(Dr / R));
+    DNdir.Multiply(theOffset / R2);
+  }
+  else
+  {
+    // Same computation as IICURV in EUCLID-IS because the stability is better.
+    // V3 = P"' (U) :
+    D3Ndir.Multiply(theOffset / R);
+    D3Ndir.Subtract(D2Ndir.Multiplied(3.0 * theOffset * Dr / R3));
+    D3Ndir.Subtract(DNdir.Multiplied(
+      ((3.0 * theOffset) * ((D2r / R3) + (Dr*Dr) / R5))));
+    D3Ndir.Add(Ndir.Multiplied(
+      (theOffset * (6.0*Dr*Dr / R5 + 6.0*Dr*D2r / R5 - 15.0*Dr*Dr*Dr / R7 - D3r))));
+    // V2 = P" (U) :
+    D2Ndir.Multiply(theOffset / R);
+    D2Ndir.Subtract(DNdir.Multiplied(2.0 * theOffset * Dr / R3));
+    D2Ndir.Subtract(Ndir.Multiplied(
+      theOffset * (((3.0 * Dr * Dr) / R5) - (D2r / R3))));
+    // V1 = P' (U) :
+    DNdir.Multiply(theOffset / R);
+    DNdir.Subtract(Ndir.Multiplied(theOffset * Dr / R3));
+  }
+
+  Ndir.Multiply(theOffset / R);
+  // P(u)
+  theValue.ChangeCoord().Add(Ndir);
+  // P'(u) :
+  theD1.Add(gp_Vec2d(DNdir));
+  // P"(u)
+  theD2.Add(gp_Vec2d(D2Ndir));
+  // P"'(u)
+  if (theIsDirChange)
+    theD3.Reverse();
+  theD3.Add(gp_Vec2d(D2Ndir));
+}
+
+
diff --git a/src/Geom2dEvaluator/Geom2dEvaluator.hxx b/src/Geom2dEvaluator/Geom2dEvaluator.hxx
new file mode 100644 (file)
index 0000000..2aa1d6b
--- /dev/null
@@ -0,0 +1,87 @@
+// Created on: 1992-08-28
+// Created by: Remi LEQUETTE
+// Copyright (c) 1992-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Geom2dEvaluator_HeaderFile
+#define _Geom2dEvaluator_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Real.hxx>
+#include <Standard_Integer.hxx>
+
+class gp_Pnt2d;
+class gp_Vec2d;
+
+//! The Geom2dEvaluator package provides  utilities for .
+//! calculating value and derivatives of offset curve
+//! using corresponding values of base curve
+
+class Geom2dEvaluator
+{
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+  
+  //! Recalculate D1 values of base curve into D0 value of offset curve
+  Standard_EXPORT static void CalculateD0(gp_Pnt2d& theValue,
+                                          const gp_Vec2d& theD1, const Standard_Real theOffset);
+  
+  //! Recalculate D2 values of base curve into D1 values of offset curve
+  Standard_EXPORT static  void CalculateD1(gp_Pnt2d& theValue,
+                                           gp_Vec2d& theD1,
+                                           const gp_Vec2d& theD2, const Standard_Real theOffset);
+
+  
+  //! Recalculate D3 values of base curve into D2 values of offset curve
+  Standard_EXPORT static   void CalculateD2(gp_Pnt2d& theValue,
+                                            gp_Vec2d& theD1,
+                                            gp_Vec2d& theD2,
+                                            const gp_Vec2d& theD3, const Standard_Boolean theIsDirChange, 
+                                            const Standard_Real theOffset);
+
+  
+  //! Recalculate D3 values of base curve into D3 values of offset curve
+  Standard_EXPORT static void CalculateD3(gp_Pnt2d& theValue,
+                                          gp_Vec2d& theD1,
+                                          gp_Vec2d& theD2,
+                                          gp_Vec2d& theD3,
+                                          const gp_Vec2d& theD4, const Standard_Boolean theIsDirChange,
+                                          const Standard_Real theOffset); 
+
+  
+  //! Recalculate derivatives in the singular point
+  //! Returns true if the direction of derivatives is changed
+  Standard_EXPORT static Standard_Boolean AdjustDerivative(const Standard_Integer theMaxDerivative,
+                                                           const Standard_Real theU,
+                                                           gp_Vec2d& theD1,
+                                                           gp_Vec2d& theD2,
+                                                           gp_Vec2d& theD3,
+                                                           gp_Vec2d& theD4);
+  
+  
+protected:
+
+
+
+
+
+private:
+
+};
+
+
+#endif // _Geom2dEvaluator_HeaderFile
index a899808..56864c1 100644 (file)
@@ -13,7 +13,7 @@
 // commercial license or contractual agreement.
 
 #include <Geom2dEvaluator_OffsetCurve.hxx>
-
+#include <Geom2dEvaluator.hxx>
 #include <Geom2dAdaptor_HCurve.hxx>
 #include <Standard_NullValue.hxx>
 
@@ -43,7 +43,7 @@ void Geom2dEvaluator_OffsetCurve::D0(const Standard_Real theU,
 {
   gp_Vec2d aD1;
   BaseD1(theU, theValue, aD1);
-  CalculateD0(theValue, aD1);
+  Geom2dEvaluator::CalculateD0(theValue, aD1, myOffset);
 }
 
 void Geom2dEvaluator_OffsetCurve::D1(const Standard_Real theU,
@@ -52,7 +52,7 @@ void Geom2dEvaluator_OffsetCurve::D1(const Standard_Real theU,
 {
   gp_Vec2d aD2;
   BaseD2(theU, theValue, theD1, aD2);
-  CalculateD1(theValue, theD1, aD2);
+  Geom2dEvaluator::CalculateD1(theValue, theD1, aD2, myOffset);
 }
 
 void Geom2dEvaluator_OffsetCurve::D2(const Standard_Real theU,
@@ -70,7 +70,7 @@ void Geom2dEvaluator_OffsetCurve::D2(const Standard_Real theU,
     isDirectionChange = AdjustDerivative(3, theU, theD1, theD2, aD3, aDummyD4);
   }
 
-  CalculateD2(theValue, theD1, theD2, aD3, isDirectionChange);
+  Geom2dEvaluator::CalculateD2(theValue, theD1, theD2, aD3, isDirectionChange, myOffset);
 }
 
 void Geom2dEvaluator_OffsetCurve::D3(const Standard_Real theU,
@@ -86,7 +86,7 @@ void Geom2dEvaluator_OffsetCurve::D3(const Standard_Real theU,
   if (theD1.SquareMagnitude() <= gp::Resolution())
     isDirectionChange = AdjustDerivative(4, theU, theD1, theD2, theD3, aD4);
 
-  CalculateD3(theValue, theD1, theD2, theD3, aD4, isDirectionChange);
+  Geom2dEvaluator::CalculateD3(theValue, theD1, theD2, theD3, aD4, isDirectionChange, myOffset);
 }
 
 gp_Vec2d Geom2dEvaluator_OffsetCurve::DN(const Standard_Real theU,
@@ -184,207 +184,6 @@ gp_Vec2d Geom2dEvaluator_OffsetCurve::BaseDN(const Standard_Real theU,
 }
 
 
-void Geom2dEvaluator_OffsetCurve::CalculateD0(      gp_Pnt2d& theValue,
-                                              const gp_Vec2d& theD1) const
-{
-  if (theD1.SquareMagnitude() <= gp::Resolution())
-    throw Standard_NullValue("Geom2dEvaluator_OffsetCurve: Undefined normal vector "
-                             "because tangent vector has zero-magnitude!");
-
-  gp_Dir2d aNormal(theD1.Y(), -theD1.X());
-  theValue.ChangeCoord().Add(aNormal.XY() * myOffset);
-}
-
-void Geom2dEvaluator_OffsetCurve::CalculateD1(      gp_Pnt2d& theValue,
-                                                    gp_Vec2d& theD1,
-                                              const gp_Vec2d& theD2) const
-{
-  // P(u) = p(u) + Offset * Ndir / R
-  // with R = || p' ^ Z|| and Ndir = P' ^ Z
-
-  // P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R -  Ndir * (DR/R))
-
-  gp_XY Ndir(theD1.Y(), -theD1.X());
-  gp_XY DNdir(theD2.Y(), -theD2.X());
-  Standard_Real R2 = Ndir.SquareModulus();
-  Standard_Real R = Sqrt(R2);
-  Standard_Real R3 = R * R2;
-  Standard_Real Dr = Ndir.Dot(DNdir);
-  if (R3 <= gp::Resolution())
-  {
-    if (R2 <= gp::Resolution())
-      throw Standard_NullValue("Geom2dEvaluator_OffsetCurve: Null derivative");
-    //We try another computation but the stability is not very good.
-    DNdir.Multiply(R);
-    DNdir.Subtract(Ndir.Multiplied(Dr / R));
-    DNdir.Multiply(myOffset / R2);
-  }
-  else
-  {
-    // Same computation as IICURV in EUCLID-IS because the stability is better
-    DNdir.Multiply(myOffset / R);
-    DNdir.Subtract(Ndir.Multiplied(myOffset * Dr / R3));
-  }
-
-  Ndir.Multiply(myOffset / R);
-  // P(u)
-  theValue.ChangeCoord().Add(Ndir);
-  // P'(u)
-  theD1.Add(gp_Vec2d(DNdir));
-}
-
-void Geom2dEvaluator_OffsetCurve::CalculateD2(      gp_Pnt2d& theValue,
-                                                    gp_Vec2d& theD1,
-                                                    gp_Vec2d& theD2,
-                                              const gp_Vec2d& theD3,
-                                              const Standard_Boolean theIsDirChange) const
-{
-  // P(u) = p(u) + Offset * Ndir / R
-  // with R = || p' ^ Z|| and Ndir = P' ^ Z
-
-  // P'(u) = p'(u) + (Offset / R**2) * (DNdir/DU * R -  Ndir * (DR/R))
-
-  // P"(u) = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
-  //         Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
-
-  gp_XY Ndir(theD1.Y(), -theD1.X());
-  gp_XY DNdir(theD2.Y(), -theD2.X());
-  gp_XY D2Ndir(theD3.Y(), -theD3.X());
-  Standard_Real R2 = Ndir.SquareModulus();
-  Standard_Real R = Sqrt(R2);
-  Standard_Real R3 = R2 * R;
-  Standard_Real R4 = R2 * R2;
-  Standard_Real R5 = R3 * R2;
-  Standard_Real Dr = Ndir.Dot(DNdir);
-  Standard_Real D2r = Ndir.Dot(D2Ndir) + DNdir.Dot(DNdir);
-  if (R5 <= gp::Resolution())
-  {
-    if (R4 <= gp::Resolution())
-      throw Standard_NullValue("Geom2dEvaluator_OffsetCurve: Null derivative");
-    //We try another computation but the stability is not very good dixit ISG.
-    // V2 = P" (U) :
-    D2Ndir.Subtract(DNdir.Multiplied(2.0 * Dr / R2));
-    D2Ndir.Add(Ndir.Multiplied(((3.0 * Dr * Dr) / R4) - (D2r / R2)));
-    D2Ndir.Multiply(myOffset / R);
-
-    // V1 = P' (U) :
-    DNdir.Multiply(R);
-    DNdir.Subtract(Ndir.Multiplied(Dr / R));
-    DNdir.Multiply(myOffset / R2);
-  }
-  else
-  {
-    // Same computation as IICURV in EUCLID-IS because the stability is better.
-    // V2 = P" (U) :
-    D2Ndir.Multiply(myOffset / R);
-    D2Ndir.Subtract(DNdir.Multiplied(2.0 * myOffset * Dr / R3));
-    D2Ndir.Add(Ndir.Multiplied(myOffset * (((3.0 * Dr * Dr) / R5) - (D2r / R3))));
-
-    // V1 = P' (U) 
-    DNdir.Multiply(myOffset / R);
-    DNdir.Subtract(Ndir.Multiplied(myOffset * Dr / R3));
-  }
-
-  Ndir.Multiply(myOffset / R);
-  // P(u)
-  theValue.ChangeCoord().Add(Ndir);
-  // P'(u) :
-  theD1.Add(gp_Vec2d(DNdir));
-  // P"(u) :
-  if (theIsDirChange)
-    theD2.Reverse();
-  theD2.Add(gp_Vec2d(D2Ndir));
-}
-
-void Geom2dEvaluator_OffsetCurve::CalculateD3(      gp_Pnt2d& theValue,
-                                                    gp_Vec2d& theD1,
-                                                    gp_Vec2d& theD2,
-                                                    gp_Vec2d& theD3,
-                                              const gp_Vec2d& theD4,
-                                              const Standard_Boolean theIsDirChange) const
-{
-  // P(u) = p(u) + Offset * Ndir / R
-  // with R = || p' ^ Z|| and Ndir = P' ^ Z
-
-  // P'(u)  = p'(u) + (Offset / R**2) * (DNdir/DU * R -  Ndir * (DR/R))
-
-  // P"(u)  = p"(u) + (Offset / R) * (D2Ndir/DU - DNdir * (2.0 * Dr/ R**2) +
-  //          Ndir * ( (3.0 * Dr**2 / R**4) - (D2r / R**2)))
-
-  // P"'(u) = p"'(u) + (Offset / R) * (D3Ndir - (3.0 * Dr/R**2 ) * D2Ndir -
-  //          (3.0 * D2r / R2) * DNdir) + (3.0 * Dr * Dr / R4) * DNdir -
-  //          (D3r/R2) * Ndir + (6.0 * Dr * Dr / R4) * Ndir +
-  //          (6.0 * Dr * D2r / R4) * Ndir - (15.0 * Dr* Dr* Dr /R6) * Ndir
-
-  gp_XY Ndir(theD1.Y(), -theD1.X());
-  gp_XY DNdir(theD2.Y(), -theD2.X());
-  gp_XY D2Ndir(theD3.Y(), -theD3.X());
-  gp_XY D3Ndir(theD4.Y(), -theD4.X());
-  Standard_Real R2 = Ndir.SquareModulus();
-  Standard_Real R = Sqrt(R2);
-  Standard_Real R3 = R2 * R;
-  Standard_Real R4 = R2 * R2;
-  Standard_Real R5 = R3 * R2;
-  Standard_Real R6 = R3 * R3;
-  Standard_Real R7 = R5 * R2;
-  Standard_Real Dr = Ndir.Dot(DNdir);
-  Standard_Real D2r = Ndir.Dot(D2Ndir) + DNdir.Dot(DNdir);
-  Standard_Real D3r = Ndir.Dot(D3Ndir) + 3.0 * DNdir.Dot(D2Ndir);
-
-  if (R7 <= gp::Resolution())
-  {
-    if (R6 <= gp::Resolution())
-      throw Standard_NullValue("Geom2dEvaluator_OffsetCurve: Null derivative");
-    //We try another computation but the stability is not very good dixit ISG.
-    // V3 = P"' (U) :
-    D3Ndir.Subtract(D2Ndir.Multiplied(3.0 * myOffset * Dr / R2));
-    D3Ndir.Subtract(
-      (DNdir.Multiplied((3.0 * myOffset) * ((D2r / R2) + (Dr*Dr) / R4))));
-    D3Ndir.Add(Ndir.Multiplied(
-      (myOffset * (6.0*Dr*Dr / R4 + 6.0*Dr*D2r / R4 - 15.0*Dr*Dr*Dr / R6 - D3r))));
-    D3Ndir.Multiply(myOffset / R);
-    // V2 = P" (U) :
-    R4 = R2 * R2;
-    D2Ndir.Subtract(DNdir.Multiplied(2.0 * Dr / R2));
-    D2Ndir.Subtract(Ndir.Multiplied(((3.0 * Dr * Dr) / R4) - (D2r / R2)));
-    D2Ndir.Multiply(myOffset / R);
-    // V1 = P' (U) :
-    DNdir.Multiply(R);
-    DNdir.Subtract(Ndir.Multiplied(Dr / R));
-    DNdir.Multiply(myOffset / R2);
-  }
-  else
-  {
-    // Same computation as IICURV in EUCLID-IS because the stability is better.
-    // V3 = P"' (U) :
-    D3Ndir.Multiply(myOffset / R);
-    D3Ndir.Subtract(D2Ndir.Multiplied(3.0 * myOffset * Dr / R3));
-    D3Ndir.Subtract(DNdir.Multiplied(
-      ((3.0 * myOffset) * ((D2r / R3) + (Dr*Dr) / R5))));
-    D3Ndir.Add(Ndir.Multiplied(
-      (myOffset * (6.0*Dr*Dr / R5 + 6.0*Dr*D2r / R5 - 15.0*Dr*Dr*Dr / R7 - D3r))));
-    // V2 = P" (U) :
-    D2Ndir.Multiply(myOffset / R);
-    D2Ndir.Subtract(DNdir.Multiplied(2.0 * myOffset * Dr / R3));
-    D2Ndir.Subtract(Ndir.Multiplied(
-      myOffset * (((3.0 * Dr * Dr) / R5) - (D2r / R3))));
-    // V1 = P' (U) :
-    DNdir.Multiply(myOffset / R);
-    DNdir.Subtract(Ndir.Multiplied(myOffset * Dr / R3));
-  }
-
-  Ndir.Multiply(myOffset / R);
-  // P(u)
-  theValue.ChangeCoord().Add(Ndir);
-  // P'(u) :
-  theD1.Add(gp_Vec2d(DNdir));
-  // P"(u)
-  theD2.Add(gp_Vec2d(D2Ndir));
-  // P"'(u)
-  if (theIsDirChange)
-    theD3.Reverse();
-  theD3.Add(gp_Vec2d(D2Ndir));
-}
 
 
 Standard_Boolean Geom2dEvaluator_OffsetCurve::AdjustDerivative(
index c24d351..64e400f 100644 (file)
@@ -57,27 +57,6 @@ public:
   DEFINE_STANDARD_RTTIEXT(Geom2dEvaluator_OffsetCurve,Geom2dEvaluator_Curve)
 
 private:
-  //! Recalculate D1 values of base curve into D0 value of offset curve
-  void CalculateD0(      gp_Pnt2d& theValue,
-                   const gp_Vec2d& theD1) const;
-  //! Recalculate D2 values of base curve into D1 values of offset curve
-  void CalculateD1(      gp_Pnt2d& theValue,
-                         gp_Vec2d& theD1,
-                   const gp_Vec2d& theD2) const;
-  //! Recalculate D3 values of base curve into D2 values of offset curve
-  void CalculateD2(      gp_Pnt2d& theValue,
-                         gp_Vec2d& theD1,
-                         gp_Vec2d& theD2,
-                   const gp_Vec2d& theD3,
-                   const Standard_Boolean theIsDirChange) const;
-  //! Recalculate D3 values of base curve into D3 values of offset curve
-  void CalculateD3(      gp_Pnt2d& theValue,
-                         gp_Vec2d& theD1,
-                         gp_Vec2d& theD2,
-                         gp_Vec2d& theD3,
-                   const gp_Vec2d& theD4,
-                   const Standard_Boolean theIsDirChange) const;
-
   //! Calculate value of base curve/adaptor
   void BaseD0(const Standard_Real theU, gp_Pnt2d& theValue) const;
   //! Calculate value and first derivatives of base curve/adaptor
index 2c3caa0..7796d07 100644 (file)
@@ -183,7 +183,8 @@ pararg2(1,aNbSolMAX)
       IntRes2d_Domain D1;
       for (Standard_Integer jcote2 = 1; jcote2 <= nbrcote2 && NbrSol < aNbSolMAX; jcote2++) {
         Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2);
-        Adaptor2d_OffsetCurve C2(HCu2,cote2(jcote2));
+        //Adaptor2d_OffsetCurve C2(HCu2,cote2(jcote2));
+        Adaptor2d_OffsetCurve C2(HCu2, -cote2(jcote2));
         firstparam = Max(C2.FirstParameter(),thefirst);
         lastparam  = Min(C2.LastParameter(),thelast);
         IntRes2d_Domain D2(C2.Value(firstparam), firstparam, Tol,
@@ -367,7 +368,8 @@ pararg2(1,aNbSolMAX)
       D1.SetEquivalentParameters(0.,2.*M_PI);
       for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) {
         Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2);
-        Adaptor2d_OffsetCurve C2(HCu2,cote2(jcote2));
+        //Adaptor2d_OffsetCurve C2(HCu2,cote2(jcote2));
+        Adaptor2d_OffsetCurve C2(HCu2, -cote2(jcote2));
         firstparam = Max(C2.FirstParameter(),thefirst);
         lastparam  = Min(C2.LastParameter(),thelast);
         IntRes2d_Domain D2(C2.Value(firstparam), firstparam, Tol,
@@ -499,7 +501,8 @@ pararg2(1,aNbSolMAX)
     Geom2dInt_TheIntConicCurveOfGInter Intp;
     for (Standard_Integer jcote1 = 1; jcote1 <= nbrcote1 && NbrSol < aNbSolMAX; jcote1++) {
       Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1);
-      Adaptor2d_OffsetCurve Cu2(HCu1,cote1(jcote1));
+      //Adaptor2d_OffsetCurve Cu2(HCu1,cote1(jcote1));
+      Adaptor2d_OffsetCurve Cu2(HCu1,-cote1(jcote1));
       firstparam = Max(Cu2.FirstParameter(),thefirst);
       lastparam  = Min(Cu2.LastParameter(),thelast);
       IntRes2d_Domain D2(Cu2.Value(firstparam), firstparam, Tol,
@@ -832,7 +835,8 @@ pararg2(1,aNbSolMAX)
     Geom2dInt_GInter Intp;
     for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
       Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1); 
-      Adaptor2d_OffsetCurve C1(HCu1,cote1(jcote1));
+      //Adaptor2d_OffsetCurve C1(HCu1,cote1(jcote1));
+      Adaptor2d_OffsetCurve C1(HCu1, -cote1(jcote1));
 #ifdef OCCT_DEBUG
       Standard_Real firstparam = Max(C1.FirstParameter(), thefirst);
       Standard_Real lastparam = Min(C1.LastParameter(), thelast);
@@ -841,7 +845,8 @@ pararg2(1,aNbSolMAX)
 #endif
       for (Standard_Integer jcote2 = 1; jcote2 <= nbrcote2 && NbrSol < aNbSolMAX; jcote2++) {
         Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2);
-        Adaptor2d_OffsetCurve C2(HCu2,cote2(jcote2));
+        //Adaptor2d_OffsetCurve C2(HCu2,cote2(jcote2));
+        Adaptor2d_OffsetCurve C2(HCu2, -cote2(jcote2));
 #ifdef OCCT_DEBUG
         firstparam = Max(C2.FirstParameter(), thefirst);
         lastparam  = Min(C2.LastParameter(),thelast);
index 892c06a..863a144 100644 (file)
@@ -125,7 +125,8 @@ parcen3(1,aNbSolMAX)
     Geom2dInt_TheIntConicCurveOfGInter Intp;
     for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
       Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1);
-      Adaptor2d_OffsetCurve C2(HCu1,Coef(jcote1));
+      //Adaptor2d_OffsetCurve C2(HCu1,Coef(jcote1));
+      Adaptor2d_OffsetCurve C2(HCu1, -Coef(jcote1));
       firstparam = Max(C2.FirstParameter(),thefirst);
       lastparam  = Min(C2.LastParameter(),thelast);
       IntRes2d_Domain D2(C2.Value(firstparam), firstparam, Tol,
@@ -238,7 +239,8 @@ parcen3(1,aNbSolMAX)
     Geom2dInt_TheIntConicCurveOfGInter Intp;
     for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
       Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1);
-      Adaptor2d_OffsetCurve C2(HCu1,cote1(jcote1));
+      //Adaptor2d_OffsetCurve C2(HCu1,cote1(jcote1));
+      Adaptor2d_OffsetCurve C2(HCu1, -cote1(jcote1));
       firstparam = Max(C2.FirstParameter(),thefirst);
       lastparam  = Min(C2.LastParameter(),thelast);
       IntRes2d_Domain D2(C2.Value(firstparam),firstparam,Tol,
@@ -593,7 +595,8 @@ parcen3(1,aNbSolMAX)
     Geom2dInt_GInter Intp;
     for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
       Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1);
-      Adaptor2d_OffsetCurve C1(HCu1,cote1(jcote1));
+      //Adaptor2d_OffsetCurve C1(HCu1,cote1(jcote1));
+      Adaptor2d_OffsetCurve C1(HCu1, -cote1(jcote1));
       firstparam = Max(C1.FirstParameter(),thefirst);
       lastparam  = Min(C1.LastParameter(),thelast);
       IntRes2d_Domain D1(C1.Value(firstparam), firstparam, Tol,
index cf0d037..8224a35 100644 (file)
@@ -268,12 +268,12 @@ Standard_Boolean MAT2d_Circuit::IsSharpCorner(const Handle(Geom2d_Geometry)& Geo
     D = Min(P1.Distance(P),P2.Distance(P));
     D /= 10;
     
-    if (Direction > 0.) D = -D;
-    
+    if (Direction < 0.) D = -D;
+
     Handle(Geom2dAdaptor_HCurve) HC1 = new Geom2dAdaptor_HCurve(C1);
     Handle(Geom2dAdaptor_HCurve) HC2 = new Geom2dAdaptor_HCurve(C2);
-    Adaptor2d_OffsetCurve OC1(HC1,D,MilC1,C1->LastParameter());
-    Adaptor2d_OffsetCurve OC2(HC2,D,C2->FirstParameter(),MilC2);
+    Adaptor2d_OffsetCurve OC1(HC1, D, MilC1, C1->LastParameter());
+    Adaptor2d_OffsetCurve OC2(HC2, D, C2->FirstParameter(), MilC2);
     Geom2dInt_GInter Intersect; 
     Intersect.Perform(OC1,OC2,Tol,Tol);