From: dln Date: Fri, 28 Mar 2014 07:28:22 +0000 (+0400) Subject: 0024778: Convertation of the generic classes to the non-generic. Part 9 X-Git-Tag: V6_8_0_beta~434 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=54e37688ef25fbe2a9199f7455527a1020709640;p=occt-copy.git 0024778: Convertation of the generic classes to the non-generic. Part 9 Generic classes: "GccIter_Circ2d2TanOn", "GccIter_Circ2d3Tan", "GccIter_Lin2d2Tan", "GccIter_Lin2dTanObl" from "GccIter" package were converted to the non-generic classes and moved to the "Geom2dGcc" package. Names of this classes were changed to: "Geom2dGcc_Circ2d2TanOnIter", "Geom2dGcc_Circ2d3TanIter", "Geom2dGcc_Lin2d2TanIter", "Geom2dGcc_Lin2dTanOblIter". And their internal classes: "GccIter_FunctionTanCuCuOnCu", "GccIter_FunctionTanCuCuCu", "GccIter_FunctionTanCirCu", "GccIter_FunctionTanCuCu", "GccIter_FunctionTanCuPnt", "GccIter_FunctionTanObl" also converted to the non-generic and moved to the "Geom2dGcc" package(their declarations were moved to "Geom2dGcc.cdl"). Enumerations" Type1, Type2 and Type3 were moved to "Geom2dGcc.cdl". Package "GccIter" was deleted. --- diff --git a/adm/UDLIST b/adm/UDLIST index 5c2527255d..fbe43e9e58 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -134,7 +134,6 @@ p FilletSurf p GccAna p GccEnt p GccInt -p GccIter p Geom2dAPI p Geom2dGcc p Geom2dHatch diff --git a/src/GccIter/GccIter.cdl b/src/GccIter/GccIter.cdl deleted file mode 100644 index ace7551e2c..0000000000 --- a/src/GccIter/GccIter.cdl +++ /dev/null @@ -1,74 +0,0 @@ --- Created on: 1991-04-04 --- Created by: Remi GILET --- Copyright (c) 1991-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. - -package GccIter - - ---Purpose : - -- This package provides an implementation of analytics - -- algorithms (using only non persistant entities) used - -- to create 2d lines or circles with geometric constraints. - -- - -- Exceptions : - -- IsParallel which inherits DomainError. This exception - -- is raised in the class Lin2dTanObl when we want to - -- find the intersection point between the solution and - -- the second argument with a null angle. - -uses GccEnt, - GccInt, - GccAna, - StdFail, - gp, - math - -is - -enumeration Type1 is CuCuCu,CiCuCu,CiCiCu,CiLiCu,LiLiCu,LiCuCu; - -enumeration Type2 is CuCuOnCu,CiCuOnCu,LiCuOnCu,CuPtOnCu, - CuCuOnLi,CiCuOnLi,LiCuOnLi,CuPtOnLi, - CuCuOnCi,CiCuOnCi,LiCuOnCi,CuPtOnCi; - -enumeration Type3 is CuCu,CiCu; - -generic class FunctionTanCuCu; - -generic class FunctionTanCirCu; - -generic class FunctionTanCuCuCu; - -generic class FunctionTanCuCuOnCu; - -generic class FunctionTanCuPnt; - -generic class FunctionTanObl; - -generic class Lin2dTanObl, FuncTObl; - -- Create a 2d line TANgent to a 2d curve and OBLic to a 2d line. - -generic class Lin2d2Tan, FuncTCuCu, FuncTCirCu, FuncTCuPt; - -- Create a 2d line TANgent to 2 2d entities. - -generic class Circ2d3Tan, FuncTCuCuCu; - -- Create a 2d circle TANgent to 3 2d entities. - -generic class Circ2d2TanOn, FuncTCuCuOnCu; - -- Create a 2d circle TANgent to a 2d entity and centered ON a 2d - -- entity (not a point). - -exception IsParallel inherits DomainError from Standard; - -end GccIter; diff --git a/src/GccIter/GccIter_Circ2d2TanOn.cdl b/src/GccIter/GccIter_Circ2d2TanOn.cdl deleted file mode 100644 index 1d4ef50607..0000000000 --- a/src/GccIter/GccIter_Circ2d2TanOn.cdl +++ /dev/null @@ -1,349 +0,0 @@ --- Created on: 1991-03-29 --- Created by: Remi GILET --- Copyright (c) 1991-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. - -generic class Circ2d2TanOn from GccIter ( - TheCurve as any; - TheCurveTool as any; - TheQualifiedCurve as any) -- as QualifiedCurve from GccEnt - -- (TheCurve) - - ---Purpose: This class implements the algorithms used to - -- create 2d circles TANgent to 2 entities and - -- having the center ON a curv. - -- The order of the tangency argument is always - -- QualifiedCirc, QualifiedLin, QualifiedCurv, Pnt2d. - -- the arguments are : - -- - The two tangency arguments. - -- - The center line. - -- - The parameter for each tangency argument which - -- is a curve. - -- - The tolerance. - --- inherits Entity from Standard - -uses Pnt2d from gp, - Lin2d from gp, - Circ2d from gp, - QualifiedCirc from GccEnt, - QualifiedLin from GccEnt, - Position from GccEnt - -raises NotDone from StdFail - -private class FuncTCuCuOnCu instantiates FunctionTanCuCuOnCu from GccIter ( - TheCurve,TheCurveTool); -is - --- On a 2d line .......................................................... - -Create(Qualified1 : QualifiedCirc ; - Qualified2 : TheQualifiedCurve ; - OnLine : Lin2d ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d circle and a curve and - -- having the center ON a 2d line. - -- Param2 is the initial guess on the curve QualifiedCurv. - -- Tolerance is used for the limit cases. - -Create(Qualified1 : QualifiedLin ; - Qualified2 : TheQualifiedCurve ; - OnLine : Lin2d ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d line and a curve and - -- having the center ON a 2d line. - -- Param2 is the initial guess on the curve QualifiedCurv. - -- Tolerance is used for the limit cases. - -Create(Qualified1 : TheQualifiedCurve ; - Qualified2 : TheQualifiedCurve ; - OnLine : Lin2d ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to two curves and - -- having the center ON a 2d line. - -- Param1 is the initial guess on the first QualifiedCurv. - -- Param2 is the initial guess on the first QualifiedCurv. - -- Tolerance is used for the limit cases. - -Create(Qualified1 : TheQualifiedCurve ; - Point2 : Pnt2d ; - OnLine : Lin2d ; - Param1 : Real ; - Param2 : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d point and a curve and - -- having the center ON a 2d line. - -- Param2 is the initial guess on the curve QualifiedCurv. - -- Tolerance is used for the limit cases. - - --- -- On a 2d Circle ..................................................... - -Create(Qualified1 : QualifiedCirc ; - Qualified2 : TheQualifiedCurve ; - OnCirc : Circ2d ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d circle and a curve and - -- having the center ON a 2d circle. - -- Param2 is the initial guess on the curve QualifiedCurv. - -- Tolerance is used for the limit cases. - -Create(Qualified1 : QualifiedLin ; - Qualified2 : TheQualifiedCurve ; - OnCirc : Circ2d ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d line and a curve and - -- having the center ON a 2d circle. - -- Param2 is the initial guess on the curve QualifiedCurv. - -- Tolerance is used for the limit cases. - -Create(Qualified1 : TheQualifiedCurve ; - Qualified2 : TheQualifiedCurve ; - OnCirc : Circ2d ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to two curves and - -- having the center ON a 2d circle. - -- Param1 is the initial guess on the first QualifiedCurv. - -- Param2 is the initial guess on the first QualifiedCurv. - -- Tolerance is used for the limit cases. - -Create(Qualified1 : TheQualifiedCurve ; - Point2 : Pnt2d ; - OnCirc : Circ2d ; - Param1 : Real ; - Param2 : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d point and a curve and - -- having the center ON a 2d circle. - -- Param2 is the initial guess on the curve QualifiedCurv. - -- Tolerance is used for the limit cases. - --- -- On a curve ..................................................... - -Create(Qualified1 : QualifiedCirc ; - Qualified2 : TheQualifiedCurve ; - OnCurv : TheCurve ; - Param1 : Real ; - Param2 : Real ; - ParamOn : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d circle and a curve and - -- having the center ON a 2d curve. - -- Param2 is the initial guess on the curve QualifiedCurv. - -- ParamOn is the initial guess on the center curve OnCurv. - -- Tolerance is used for the limit cases. - -Create(Qualified1 : QualifiedLin ; - Qualified2 : TheQualifiedCurve ; - OnCurve : TheCurve ; - Param1 : Real ; - Param2 : Real ; - ParamOn : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d line and a curve and - -- having the center ON a 2d curve. - -- Param2 is the initial guess on the curve QualifiedCurv. - -- ParamOn is the initial guess on the center curve OnCurv. - -- Tolerance is used for the limit cases. - -Create(Qualified1 : TheQualifiedCurve ; - Point2 : Pnt2d ; - OnCurve : TheCurve ; - Param1 : Real ; - ParamOn : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d Point and a curve and - -- having the center ON a 2d curve. - -- Param1 is the initial guess on the curve QualifiedCurv. - -- ParamOn is the initial guess on the center curve OnCurv. - -- Tolerance is used for the limit cases. - -Create(Qualified1 : TheQualifiedCurve ; - Qualified2 : TheQualifiedCurve ; - OnCurve : TheCurve ; - Param1 : Real ; - Param2 : Real ; - ParamOn : Real ; - Tolerance : Real ) returns Circ2d2TanOn from GccIter ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to two curves and - -- having the center ON a 2d curve. - -- Param1 is the initial guess on the first curve QualifiedCurv. - -- Param1 is the initial guess on the second curve QualifiedCurv. - -- ParamOn is the initial guess on the center curve OnCurv. - -- Tolerance is used for the limit cases. - --- -- .................................................................... - -IsDone(me) returns Boolean -is static; - ---Purpose: This method returns True if the construction - -- algorithm succeeded. - -ThisSolution(me) returns Circ2d - ---Purpose: Returns the solution. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -WhichQualifier(me ; - Qualif1 : out Position from GccEnt; - Qualif2 : out Position from GccEnt) -raises NotDone from StdFail -is static; - -- It returns the informations about the qualifiers of the tangency - -- arguments concerning the solution number Index. - -- It returns the real qualifiers (the qualifiers given to the - -- constructor method in case of enclosed, enclosing and outside - -- and the qualifiers computedin case of unqualified). - -Tangency1(me ; - ParSol,ParArg : out Real ; - PntSol : out Pnt2d) - ---Purpose: Returns information about the tangency point between - -- the result and the first argument. - -- ParSol is the intrinsic parameter of the point PntSol - -- on the solution curv. - -- ParArg is the intrinsic parameter of the point PntSol - -- on the argument curv. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -Tangency2(me ; - ParSol,ParArg : out Real ; - PntSol : out Pnt2d) - ---Purpose: Returns information about the tangency point between - -- the result and the second argument. - -- ParSol is the intrinsic parameter of the point PntSol - -- on the solution curv. - -- ParArg is the intrinsic parameter of the point PntSol - -- on the argument curv. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -CenterOn3 (me ; - ParArg : out Real ; - PntSol : out Pnt2d) - ---Purpose: Returns information about the center (on the curv) of the - -- result and the third argument. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -IsTheSame1(me) returns Boolean - -- Returns True if the solution is equal to the first argument. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -IsTheSame2(me) returns Boolean - -- Returns True if the solution is equal to the second argument. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -fields - - WellDone : Boolean; - ---Purpose: True if the algorithm succeeded. - - cirsol : Circ2d from gp; - -- The solutions. - - qualifier1 : Position from GccEnt; - -- The qualifiers of the first argument. - - qualifier2 : Position from GccEnt; - -- The qualifiers of the first argument. - - TheSame1 : Boolean; - ---Purpose: True if the solution and the first argument are the - -- same in the tolerance of Tolerance. - -- False in the other cases. - - TheSame2 : Boolean; - ---Purpose: True if the solution and the second argument are the - -- same in the tolerance of Tolerance. - -- False in the other cases. - - pnttg1sol : Pnt2d; - ---Purpose: The tangency point between the solution and the first - -- argument on the solution. - - pnttg2sol : Pnt2d; - ---Purpose: The tangency point between the solution and the second - -- argument on the solution. - - pntcen : Pnt2d; - ---Purpose: The center point of the solution on the third argument. - - par1sol : Real; - ---Purpose: The parameter of the tangency point between the - -- solution and the first argument on the solution. - - par2sol : Real; - ---Purpose: The parameter of the tangency point between the - -- solution and the second argument on the solution. - - pararg1 : Real; - ---Purpose: The parameter of the tangency point between the - -- solution and the first argument on the first argument. - - pararg2 : Real; - ---Purpose: The parameter of the tangency point between the - -- solution and the second argument on the second argument. - - parcen3 : Real; - ---Purpose: The parameter of the center point of the solution - -- on the second argument. - -end Circ2d2TanOn; diff --git a/src/GccIter/GccIter_Circ2d2TanOn.gxx b/src/GccIter/GccIter_Circ2d2TanOn.gxx deleted file mode 100644 index 44454dda37..0000000000 --- a/src/GccIter/GccIter_Circ2d2TanOn.gxx +++ /dev/null @@ -1,1297 +0,0 @@ -// Created on: 1991-12-13 -// Created by: Remi GILET -// Copyright (c) 1991-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. - -//========================================================================= -// Creation d un cercle tangent a deux elements : Droite. + -// Cercle. + -// Point. + -// Courbes. + -// centre sur un troisieme : Droite. + -// Cercle. + -// Courbes. + -//========================================================================= - -#include -#include -#include -#include -#include -#include -#include - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const GccEnt_QualifiedLin& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const gp_Lin2d& OnLine , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolang ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - Standard_Real Tol = Abs(Tolang); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Dir2d dirx(1.,0.); - gp_Lin2d L1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - math_Vector Umin(1,4); - math_Vector Umax(1,4); - math_Vector Ufirst(1,4); - math_Vector tol(1,4); - Umin(1) = RealFirst(); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = RealFirst(); - Umin(4) = 0.; - Umax(1) = RealLast(); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = RealLast(); - Umax(4) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = 1.e-15; - tol(2) = TheCurveTool::EpsX(Cu2,Tolang); - tol(3) = tol(1); - tol(4) = tol(1); - gp_Pnt2d point1 = ElCLib::Value(Param1,L1); - gp_Pnt2d point2 = TheCurveTool::Value(Cu2,Param2); - gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine); - Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(L1,Cu2,OnLine,Ufirst(4)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); -// gp_Vec2d Tan1,Tan2,Nor1,Nor2; - gp_Vec2d Tan1,Tan2; - ElCLib::D1(Ufirst(1),L1,point1,Tan1); - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); - gp_Vec2d Tan3(OnLine.Direction().XY()); - gp_Pnt2d point3(OnLine.Location().XY()+Ufirst(3)*Tan3.XY()); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan2 = Tan2.Magnitude(); - gp_Vec2d Vec1(point1,point3); - gp_Vec2d Vec2(point2,point3); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real angle2; - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - angle2 = Vec2.Angle(Tan2); - } - else { angle2 = 0.; } - Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(), - L1.Direction().X())); - if (Qualified1.IsUnqualified() || - (Qualified1.IsOutside() && pscal <= 0.) || - (Qualified1.IsEnclosed() && pscal >= 0.)) { - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&angle2<=0.)|| - (Qualified2.IsOutside() && angle2 >= 0) || - (Qualified2.IsEnclosed() && angle2 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pnttg1sol = point1; - pararg1 = Ufirst(1); - par1sol = ElCLib::Parameter(cirsol,pnttg1sol); - pnttg2sol = point2; - pararg2 = Ufirst(2); - par2sol = ElCLib::Parameter(cirsol,pnttg2sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const TheQualifiedCurve& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const gp_Lin2d& OnLine , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - gp_Dir2d dirx(1.,0.); - TheCurve Cu1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - math_Vector Umin(1,4); - math_Vector Umax(1,4); - math_Vector Ufirst(1,4); - math_Vector tol(1,4); - Umin(1) = TheCurveTool::FirstParameter(Cu1); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = RealFirst(); - Umin(4) = 0.; - Umax(1) = TheCurveTool::LastParameter(Cu1); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = RealLast(); - Umax(4) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = TheCurveTool::EpsX(Cu1,Abs(Tolerance)); - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = 1.e-15; - tol(4) = Tol/10.; - gp_Pnt2d point1 = TheCurveTool::Value(Cu1,Param1); - gp_Pnt2d point2 = TheCurveTool::Value(Cu2,Param2); - gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine); - Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(Cu1,Cu2,OnLine,Ufirst(4)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); - gp_Vec2d Tan1,Tan2; - TheCurveTool::D1(Cu1,Ufirst(1),point1,Tan1); - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); - gp_Vec2d Tan3(OnLine.Direction().XY()); - gp_Pnt2d point3(OnLine.Location().XY()+Ufirst(3)*Tan3.XY()); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - gp_Vec2d Vec1(point1,point3); - gp_Vec2d Vec2(point2,point3); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real angle1,angle2; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - angle1 = Vec1.Angle(Tan1); - } - else { angle1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - angle2 = Vec2.Angle(Tan2); - } - else { angle2 = 0.; } - if (Qualified1.IsUnqualified()|| - (Qualified1.IsEnclosing()&&angle1<=0.)|| - (Qualified1.IsOutside() && angle1 >= 0.) || - (Qualified1.IsEnclosed() && angle1 <= 0.)) { - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&angle2<=0.)|| - (Qualified2.IsOutside() && angle2 >= 0) || - (Qualified2.IsEnclosed() && angle2 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pnttg1sol = point1; - pararg1 = Ufirst(1); - par1sol = ElCLib::Parameter(cirsol,pnttg1sol); - pnttg2sol = point2; - pararg2 = Ufirst(2); - par2sol = ElCLib::Parameter(cirsol,pnttg2sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const TheQualifiedCurve& Qualified1 , - const gp_Pnt2d& Point2 , - const gp_Lin2d& OnLine , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Tolerance ) { - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - gp_Dir2d dirx(1.,0.); - TheCurve Cu1 = Qualified1.Qualified(); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = TheCurveTool::FirstParameter(Cu1); - Umin(2) = RealFirst(); - Umin(3) = 0.; - Umax(1) = TheCurveTool::LastParameter(Cu1); - Umax(2) = RealLast(); - Umax(3) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - tol(1) = TheCurveTool::EpsX(Cu1,Abs(Tolerance)); - tol(2) = 1.e-15; - tol(3) = Tol/10.; - gp_Pnt2d point1 = TheCurveTool::Value(Cu1,Param1); - gp_Pnt2d point3 = ElCLib::Value(Param2,OnLine); - Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(Cu1,Point2,OnLine,Ufirst(3)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); - gp_Pnt2d point1,point3; - gp_Vec2d Tan1,Tan3; - TheCurveTool::D1(Cu1,Ufirst(1),point1,Tan1); - ElCLib::D1(Ufirst(2),OnLine,point3,Tan3); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(Point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan1 = Tan1.Magnitude(); - gp_Vec2d Vec1(point1,point3); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real angle1; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - angle1 = Vec1.Angle(Tan1); - } - else { angle1 = 0.; } - if (Qualified1.IsUnqualified()|| - (Qualified1.IsEnclosing()&&angle1<=0.)|| - (Qualified1.IsOutside() && angle1 >= 0.) || - (Qualified1.IsEnclosed() && angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = GccEnt_noqualifier; - pnttg1sol = point1; - pararg1 = Ufirst(1); - par1sol = ElCLib::Parameter(cirsol,pnttg1sol); - pnttg2sol = Point2; - pararg2 = Ufirst(2); - par2sol = ElCLib::Parameter(cirsol,pnttg2sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const GccEnt_QualifiedCirc& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const gp_Lin2d& OnLine , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - gp_Dir2d dirx(1.,0.); - gp_Circ2d C1 = Qualified1.Qualified(); - Standard_Real R1 = C1.Radius(); - TheCurve Cu2 = Qualified2.Qualified(); - math_Vector Umin(1,4); - math_Vector Umax(1,4); - math_Vector Ufirst(1,4); - math_Vector tol(1,4); - Umin(1) = RealFirst(); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = RealFirst(); - Umin(4) = 0.; - Umax(1) = RealLast(); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = RealLast(); - Umax(4) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = 2.e-15*M_PI; - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = 1.e-15; - tol(4) = Tol/10.; - gp_Pnt2d point1 = ElCLib::Value(Param1,C1); - gp_Pnt2d point2 = TheCurveTool::Value(Cu2,Param2); - gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine); - Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(C1,Cu2,OnLine,Ufirst(4)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); -// gp_Vec2d Tan1,Tan2,Nor1,Nor2; - gp_Vec2d Tan1,Tan2,Nor2; - ElCLib::D2(Ufirst(1),C1,point1,Tan1,Nor2); - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); -#ifdef DEB - gp_Vec2d Tan3(OnLine.Direction().XY()); -#else - OnLine.Direction().XY(); -#endif - point3 = ElCLib::Value(Ufirst(1),OnLine); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan2 = Tan2.Magnitude(); - gp_Vec2d Vec1(point1,point3); - gp_Vec2d Vec2(point2,point3); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real angle2; - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - angle2 = Vec2.Angle(Tan2); - } - else { angle2 = 0.; } - Standard_Real dist = C1.Location().Distance(point3); - Standard_Real Rsol = cirsol.Radius(); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| - (Qualified1.IsOutside() && dist >= Rsol) || - (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&angle2<=0.)|| - (Qualified2.IsOutside() && angle2 >= 0) || - (Qualified2.IsEnclosed() && angle2 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pnttg1sol = point1; - pararg1 = Ufirst(1); - par1sol = ElCLib::Parameter(cirsol,pnttg1sol); - pnttg2sol = point2; - pararg2 = Ufirst(2); - par2sol = ElCLib::Parameter(cirsol,pnttg2sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const GccEnt_QualifiedCirc& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const gp_Circ2d& OnCirc , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - gp_Dir2d dirx(1.,0.); - gp_Circ2d C1 = Qualified1.Qualified(); - Standard_Real R1 = C1.Radius(); - TheCurve Cu2 = Qualified2.Qualified(); - math_Vector Umin(1,4); - math_Vector Umax(1,4); - math_Vector Ufirst(1,4); - math_Vector tol(1,4); - Umin(1) = RealFirst(); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = RealFirst(); - Umin(4) = 0.; - Umax(1) = RealLast(); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = RealLast(); - Umax(4) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = 2.e-15*M_PI; - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = 2.e-15*M_PI; - tol(4) = Tol/10.; - gp_Pnt2d point1 = ElCLib::Value(Param1,C1); - gp_Pnt2d point2 = TheCurveTool::Value(Cu2,Param2); - gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc); - Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(C1,Cu2,OnCirc,Ufirst(4)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); -// gp_Vec2d Tan1,Tan2,Nor1; - gp_Vec2d Tan1,Tan2; - ElCLib::D1(Ufirst(1),C1,point1,Tan1); - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); -#ifdef DEB - gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3))); -#endif - point3 = ElCLib::Value(Ufirst(3),OnCirc); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan2 = Tan2.Magnitude(); - gp_Vec2d Vec1(point1,point3); - gp_Vec2d Vec2(point2,point3); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real angle2; - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - angle2 = Vec2.Angle(Tan2); - } - else { angle2 = 0.; } - Standard_Real dist = C1.Location().Distance(point3); - Standard_Real Rsol = cirsol.Radius(); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| - (Qualified1.IsOutside() && dist >= Rsol) || - (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&angle2<=0.)|| - (Qualified2.IsOutside() && angle2 >= 0) || - (Qualified2.IsEnclosed() && angle2 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pnttg1sol = point1; - pararg1 = Ufirst(1); - par1sol = ElCLib::Parameter(cirsol,pnttg1sol); - pnttg2sol = point2; - pararg2 = Ufirst(2); - par2sol = ElCLib::Parameter(cirsol,pnttg2sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const GccEnt_QualifiedLin& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const gp_Circ2d& OnCirc , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - gp_Dir2d dirx(1.,0.); - gp_Lin2d L1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - math_Vector Umin(1,4); - math_Vector Umax(1,4); - math_Vector Ufirst(1,4); - math_Vector tol(1,4); - Umin(1) = RealFirst(); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = RealFirst(); - Umin(4) = 0.; - Umax(1) = RealLast(); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = RealLast(); - Umax(4) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = 1.e-15; - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = 2.e-15*M_PI; - tol(4) = Tol/10.; - gp_Pnt2d point1 = ElCLib::Value(Param1,L1); - gp_Pnt2d point2 = TheCurveTool::Value(Cu2,Param2); - gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc); - Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(L1,Cu2,OnCirc,Ufirst(4)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); - gp_Pnt2d point1,point2; - gp_Vec2d Tan1,Tan2; - ElCLib::D1(Ufirst(1),L1,point1,Tan1); - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); -#ifdef DEB - gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3))); -#endif - point3 = ElCLib::Value(Ufirst(3),OnCirc); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan2 = Tan2.Magnitude(); - gp_Vec2d Vec1(point1,point3); - gp_Vec2d Vec2(point2,point3); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real angle2; - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - angle2 = Vec2.Angle(Tan2); - } - else { angle2 = 0.; } - Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(), - L1.Direction().X())); - if (Qualified1.IsUnqualified() || - (Qualified1.IsOutside() && pscal <= 0.) || - (Qualified1.IsEnclosed() && pscal >= 0.)) { - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&angle2<=0.)|| - (Qualified2.IsOutside() && angle2 >= 0) || - (Qualified2.IsEnclosed() && angle2 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pnttg1sol = point1; - pararg1 = Ufirst(1); - par1sol = ElCLib::Parameter(cirsol,pnttg1sol); - pnttg2sol = point2; - pararg2 = Ufirst(2); - par2sol = ElCLib::Parameter(cirsol,pnttg2sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const TheQualifiedCurve& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const gp_Circ2d& OnCirc , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - gp_Dir2d dirx(1.,0.); - TheCurve Cu1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - math_Vector Umin(1,4); - math_Vector Umax(1,4); - math_Vector Ufirst(1,4); - math_Vector tol(1,4); - Umin(1) = TheCurveTool::FirstParameter(Cu1); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = RealFirst(); - Umin(4) = 0.; - Umax(1) = TheCurveTool::LastParameter(Cu1); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = RealLast(); - Umax(4) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = TheCurveTool::EpsX(Cu1,Abs(Tolerance)); - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = 2.e-15*M_PI; - tol(4) = Tol/10.; - gp_Pnt2d point1 = TheCurveTool::Value(Cu1,Param1); - gp_Pnt2d point2 = TheCurveTool::Value(Cu2,Param2); - Standard_Real R1 = OnCirc.Radius(); - gp_Pnt2d point3(OnCirc.Location().XY()+R1*gp_XY(Cos(Param3),Sin(Param3))); - Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(Cu1,Cu2,OnCirc,Ufirst(4)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); -// gp_Vec2d Tan1,Tan2,Nor1; - gp_Vec2d Tan1,Tan2; - TheCurveTool::D1(Cu1,Ufirst(1),point1,Tan1); - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); -#ifdef DEB - gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3))); -#endif - point3 = gp_Pnt2d(OnCirc.Location().XY()+ - R1*gp_XY(Cos(Ufirst(3)),Sin(Ufirst(3)))); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - gp_Vec2d Vec1(point1,point3); - gp_Vec2d Vec2(point2,point3); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real angle1,angle2; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - angle1 = Vec1.Angle(Tan1); - } - else { angle1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - angle2 = Vec2.Angle(Tan2); - } - else { angle2 = 0.; } - if (Qualified1.IsUnqualified()|| - (Qualified1.IsEnclosing()&&angle1<=0.)|| - (Qualified1.IsOutside() && angle1 >= 0.) || - (Qualified1.IsEnclosed() && angle1 <= 0.)) { - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&angle2<=0.)|| - (Qualified2.IsOutside() && angle2 >= 0) || - (Qualified2.IsEnclosed() && angle2 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pararg1 = Ufirst(1); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(2); - pnttg2sol = point2; - par2sol = pnttg2sol.Distance(pnttg1sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const TheQualifiedCurve& Qualified1 , - const gp_Pnt2d& Point2 , - const gp_Circ2d& OnCirc , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Tolerance ) { - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - gp_Dir2d dirx(1.,0.); - TheCurve Cu1 = Qualified1.Qualified(); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = TheCurveTool::FirstParameter(Cu1); - Umin(2) = RealFirst(); - Umin(3) = 0.; - Umax(1) = TheCurveTool::LastParameter(Cu1); - Umax(2) = RealLast(); - Umax(3) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - tol(1) = TheCurveTool::EpsX(Cu1,Abs(Tolerance)); - tol(2) = 2.e-15*M_PI; - tol(3) = Tol/10.; - gp_Pnt2d point1 = TheCurveTool::Value(Cu1,Param1); - gp_Pnt2d point3 = ElCLib::Value(Param2,OnCirc); - Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(Cu1,Point2,OnCirc,Ufirst(3)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); - gp_Pnt2d point1,point3; - gp_Vec2d Tan1,Tan3; - TheCurveTool::D1(Cu1,Ufirst(1),point1,Tan1); - ElCLib::D1(Ufirst(2),OnCirc,point3,Tan3); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(Point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan1 = Tan1.Magnitude(); - gp_Vec2d Vec1(point1,point3); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real angle1; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - angle1 = Vec1.Angle(Tan1); - } - else { angle1 = 0.; } - if (Qualified1.IsUnqualified()|| - (Qualified1.IsEnclosing()&&angle1<=0.)|| - (Qualified1.IsOutside() && angle1 >= 0.) || - (Qualified1.IsEnclosed() && angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = GccEnt_noqualifier; - pnttg1sol = point1; - pararg1 = Ufirst(1); - par1sol = ElCLib::Parameter(cirsol,pnttg1sol); - pnttg2sol = Point2; - pararg2 = 0.; - par2sol = ElCLib::Parameter(cirsol,pnttg2sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const TheQualifiedCurve& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const TheCurve& OnCurv , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Dir2d dirx(1.,0.); - TheCurve Cu1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - math_Vector Umin(1,4); - math_Vector Umax(1,4); - math_Vector Ufirst(1,4); - math_Vector tol(1,4); - Umin(1) = TheCurveTool::FirstParameter(Cu1); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = TheCurveTool::FirstParameter(OnCurv); - Umin(4) = 0.; - Umax(1) = TheCurveTool::LastParameter(Cu1); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = TheCurveTool::LastParameter(OnCurv); - Umax(4) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = TheCurveTool::EpsX(Cu1,Abs(Tolerance)); - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = TheCurveTool::EpsX(OnCurv,Abs(Tolerance)); - tol(4) = Tol/10.; - gp_Pnt2d point1 = TheCurveTool::Value(Cu1,Param1); - gp_Pnt2d point2 = TheCurveTool::Value(Cu2,Param2); - gp_Pnt2d point3 = TheCurveTool::Value(OnCurv,Param3); - Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(Cu1,Cu2,OnCurv,Ufirst(4)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); - gp_Vec2d Tan1,Tan2,Tan3; - TheCurveTool::D1(Cu1,Ufirst(1),point1,Tan1); - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); - TheCurveTool::D1(OnCurv,Ufirst(3),point3,Tan3); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - gp_Vec2d Vec1(point1,point3); - gp_Vec2d Vec2(point2,point3); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real angle1,angle2; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - angle1 = Vec1.Angle(Tan1); - } - else { angle1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - angle2 = Vec2.Angle(Tan2); - } - else { angle2 = 0.; } - if (Qualified1.IsUnqualified()|| - (Qualified1.IsEnclosing()&&angle1<=0.)|| - (Qualified1.IsOutside() && angle1 >= 0.) || - (Qualified1.IsEnclosed() && angle1 <= 0.)) { - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&angle2<=0.)|| - (Qualified2.IsOutside() && angle2 >= 0) || - (Qualified2.IsEnclosed() && angle2 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pararg1 = Ufirst(1); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(2); - pnttg2sol = point2; - par2sol = pnttg2sol.Distance(pnttg1sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const GccEnt_QualifiedCirc& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const TheCurve& OnCurv , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real ParamOn , - const Standard_Real Tolerance ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - gp_Circ2d C1 = Qualified1.Qualified(); - Standard_Real R1 = C1.Radius(); - TheCurve Cu2 = Qualified2.Qualified(); - math_Vector Umin(1,4); - math_Vector Umax(1,4); - math_Vector Ufirst(1,4); - math_Vector tol(1,4); - Umin(1) = RealFirst(); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = TheCurveTool::FirstParameter(OnCurv); - Umin(4) = 0.; - Umax(1) = RealLast(); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = TheCurveTool::LastParameter(OnCurv); - Umax(4) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = ParamOn; - tol(1) = 2.e-15*M_PI; - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = TheCurveTool::EpsX(OnCurv,Abs(Tolerance)); - tol(4) = Tol/10.;; - gp_Pnt2d point1 = ElCLib::Value(Param1,C1); - gp_Pnt2d point2 = TheCurveTool::Value(Cu2,Param2); - gp_Pnt2d point3 = TheCurveTool::Value(OnCurv,ParamOn); - Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(C1,Cu2,OnCurv,Ufirst(4)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); - gp_Vec2d Tan1,Tan2,Tan3; - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); - TheCurveTool::D1(OnCurv,Ufirst(3),point3,Tan3); - ElCLib::D1(Ufirst(1),C1,point1,Tan1); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - gp_Dir2d dirx(1.,0.); - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan2 = Tan2.Magnitude(); - gp_Vec2d Vec1(point1.XY(),point3.XY()); - gp_Vec2d Vec2(point2.XY(),point3.XY()); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real angle2; - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - angle2 = Vec2.Angle(Tan2); - } - else { angle2 = 0.; } - Standard_Real dist = C1.Location().Distance(point3); - Standard_Real Rsol = cirsol.Radius(); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| - (Qualified1.IsOutside() && dist >= Rsol) || - (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&angle2<=0.)|| - (Qualified2.IsOutside() && angle2 >= 0) || - (Qualified2.IsEnclosed() && angle2 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pnttg1sol = point1; - pararg1 = Ufirst(1); - par1sol = ElCLib::Parameter(cirsol,pnttg1sol); - pnttg2sol = point2; - pararg2 = Ufirst(2); - par2sol = ElCLib::Parameter(cirsol,pnttg2sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const GccEnt_QualifiedLin& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const TheCurve& OnCurv , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real ParamOn , - const Standard_Real Tolerance ) { - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - gp_Dir2d dirx(1.,0.); - gp_Lin2d L1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - math_Vector Umin(1,4); - math_Vector Umax(1,4); - math_Vector Ufirst(1,4); - math_Vector tol(1,4); - Umin(1) = RealFirst(); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = TheCurveTool::FirstParameter(OnCurv); - Umin(4) = 0.; - Umax(1) = RealLast(); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = TheCurveTool::LastParameter(OnCurv); - Umax(4) = RealLast(); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = ParamOn; - tol(1) = 1.e-15; - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = TheCurveTool::EpsX(OnCurv,Abs(Tolerance)); - tol(4) = Tol/10.; - gp_Pnt2d point1 = ElCLib::Value(Param1,L1); - gp_Pnt2d point2 = TheCurveTool::Value(Cu2,Param2); - gp_Pnt2d point3 = TheCurveTool::Value(OnCurv,ParamOn); - Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(L1,Cu2,OnCurv,Ufirst(4)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); - gp_Vec2d Tan1,Tan2,Tan3; - ElCLib::D1(Ufirst(1),L1,point1,Tan1); - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); - TheCurveTool::D1(OnCurv,Ufirst(3),point3,Tan3); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan2 = Tan2.Magnitude(); - gp_Vec2d Vec1(point1,point3); - gp_Vec2d Vec2(point2,point3); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real angle2; - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - angle2 = Vec2.Angle(Tan2); - } - else { angle2 = 0.; } - Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(), - L1.Direction().X())); - if (Qualified1.IsUnqualified() || - (Qualified1.IsOutside() && pscal <= 0.) || - (Qualified1.IsEnclosed() && pscal >= 0.)) { - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&angle2<=0.)|| - (Qualified2.IsOutside() && angle2 >= 0) || - (Qualified2.IsEnclosed() && angle2 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pnttg1sol = point1; - pararg1 = Ufirst(1); - par1sol = ElCLib::Parameter(cirsol,pnttg1sol); - pnttg2sol = point2; - pararg2 = Ufirst(2); - par2sol = ElCLib::Parameter(cirsol,pnttg2sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Circ2d2TanOn:: - GccIter_Circ2d2TanOn (const TheQualifiedCurve& Qualified1 , - const gp_Pnt2d& Point2 , - const TheCurve& OnCurv , - const Standard_Real Param1 , - const Standard_Real ParamOn , - const Standard_Real Tolerance ) -{ - TheSame1 = Standard_False; - TheSame2 = Standard_False; - par1sol = 0.; - par2sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - parcen3 = 0.; - - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - gp_Dir2d dirx(1.,0.); - TheCurve Cu1 = Qualified1.Qualified(); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = TheCurveTool::FirstParameter(Cu1); - Umin(2) = RealFirst(); - Umin(3) = TheCurveTool::FirstParameter(OnCurv); - Umax(1) = TheCurveTool::LastParameter(Cu1); - Umax(2) = RealLast(); - Umax(3) = TheCurveTool::LastParameter(OnCurv); - Ufirst(1) = Param1; - Ufirst(2) = ParamOn; - tol(1) = TheCurveTool::EpsX(Cu1,Abs(Tolerance)); - tol(2) = TheCurveTool::EpsX(OnCurv,Abs(Tolerance)); - tol(3) = Tol/10.; - gp_Pnt2d point1 = TheCurveTool::Value(Cu1,Param1); - gp_Pnt2d point3 = TheCurveTool::Value(OnCurv,ParamOn); - Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.; - GccIter_FuncTCuCuOnCu Func(Cu1,Point2,OnCurv,Ufirst(3)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - Func.Value(Ufirst,Umin); - if (Root.IsDone()) { - Root.Root(Ufirst); -// gp_Vec2d Tan1,Tan2,Tan3; - gp_Vec2d Tan1,Tan3; - TheCurveTool::D1(Cu1,Ufirst(1),point1,Tan1); - TheCurveTool::D1(OnCurv,Ufirst(3),point3,Tan3); - Standard_Real dist1 = point3.Distance(point1); - Standard_Real dist2 = point3.Distance(Point2); - if ( Abs(dist1-dist2)/2. <= Tol) { - cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); - Standard_Real normetan1 = Tan1.Magnitude(); - gp_Vec2d Vec1(point1,point3); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real angle1; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - angle1 = Vec1.Angle(Tan1); - } - else { angle1 = 0.; } - if (Qualified1.IsUnqualified()|| - (Qualified1.IsEnclosing()&&angle1<=0.)|| - (Qualified1.IsOutside() && angle1 >= 0.) || - (Qualified1.IsEnclosed() && angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = GccEnt_noqualifier; - pnttg1sol = point1; - pararg1 = Ufirst(1); - par1sol = ElCLib::Parameter(cirsol,pnttg1sol); - pnttg2sol = Point2; - pararg2 = 0.; - par2sol = ElCLib::Parameter(cirsol,pnttg2sol); - pntcen = point3; - parcen3 = Ufirst(3); - WellDone = Standard_True; - } - } - } -} - -Standard_Boolean GccIter_Circ2d2TanOn:: - IsDone () const{ return WellDone; } - -gp_Circ2d GccIter_Circ2d2TanOn:: - ThisSolution () const{ return cirsol; } - -void GccIter_Circ2d2TanOn:: - WhichQualifier (GccEnt_Position& Qualif1 , - GccEnt_Position& Qualif2 ) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - Qualif1 = qualifier1; - Qualif2 = qualifier2; - } -} - -void GccIter_Circ2d2TanOn:: - Tangency1 (Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& PntSol ) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - if (TheSame1 == 0) { - ParSol = 0; - ParArg = 0; - PntSol = pnttg1sol; - } - else { StdFail_NotDone::Raise(); } - } -} - -void GccIter_Circ2d2TanOn:: - Tangency2 (Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& PntSol ) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - ParSol = 0; - ParArg = 0; - PntSol = pnttg2sol; - } -} - -void GccIter_Circ2d2TanOn:: - CenterOn3 (Standard_Real& ParArg , - gp_Pnt2d& PntSol ) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - ParArg = 0; - PntSol = pntcen; - } -} - -Standard_Boolean GccIter_Circ2d2TanOn:: - IsTheSame1 () const -{ - if (!WellDone) StdFail_NotDone::Raise(); - - if (TheSame1 == 0) - return Standard_False; - return Standard_True; -} - - -Standard_Boolean GccIter_Circ2d2TanOn:: - IsTheSame2 () const -{ - if (!WellDone) StdFail_NotDone::Raise(); - return Standard_False; -} diff --git a/src/GccIter/GccIter_Circ2d3Tan.cdl b/src/GccIter/GccIter_Circ2d3Tan.cdl deleted file mode 100644 index 79b5c237c1..0000000000 --- a/src/GccIter/GccIter_Circ2d3Tan.cdl +++ /dev/null @@ -1,318 +0,0 @@ --- Created on: 1991-03-29 --- Created by: Remi GILET --- Copyright (c) 1991-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. - -generic class Circ2d3Tan from GccIter ( - TheCurve as any; - TheCurveTool as any; -- as CurveTool from GccInt (TheCurve) - TheQualifiedCurve as any) -- as QualifiedCurve from GccEnt - -- (TheCurve) - - ---Purpose: This class implements the algorithms used to - -- create 2d circles tangent to 3 points/lines/circles/ - -- curves with one curve or more. - -- The arguments of all construction methods are : - -- - The three qualifiied elements for the - -- tangency constrains (QualifiedCirc, QualifiedLine, - -- Qualifiedcurv, Points). - -- - A parameter for each QualifiedCurv. - --- inherits Entity from Standard - -uses Pnt2d from gp, - Lin2d from gp, - Circ2d from gp, - QualifiedCirc from GccEnt, - QualifiedLin from GccEnt, - Position from GccEnt - -raises NotDone from StdFail - -private class FuncTCuCuCu instantiates FunctionTanCuCuCu from GccIter ( - TheCurve,TheCurveTool); -is - -Create(Qualified1 : QualifiedCirc from GccEnt ; - Qualified2 : QualifiedCirc from GccEnt ; - Qualified3 : TheQualifiedCurve ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) -returns Circ2d3Tan from GccIter; - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to 2 circles and a curve. - -Create(Qualified1 : QualifiedCirc from GccEnt ; - Qualified2 : TheQualifiedCurve ; - Qualified3 : TheQualifiedCurve ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) -returns Circ2d3Tan from GccIter; - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to a circle and 2 curves. - -Create(Qualified1 : QualifiedCirc from GccEnt ; - Qualified2 : QualifiedLin from GccEnt ; - Qualified3 : TheQualifiedCurve ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) -returns Circ2d3Tan from GccIter; - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to a circle and a line and - -- a curve. - -Create(Qualified1 : QualifiedCirc from GccEnt ; - Qualified2 : TheQualifiedCurve ; - Point3 : Pnt2d ; - Param1 : Real ; - Param2 : Real ; - Tolerance : Real ) -returns Circ2d3Tan from GccIter; - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to a circle and a point and - -- a curve. - -Create(Qualified1 : QualifiedLin from GccEnt ; - Qualified2 : QualifiedLin from GccEnt ; - Qualified3 : TheQualifiedCurve ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) -returns Circ2d3Tan from GccIter; - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to 2 lines and a curve. - -Create(Qualified1 : QualifiedLin from GccEnt ; - Qualified2 : TheQualifiedCurve ; - Qualified3 : TheQualifiedCurve ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) -returns Circ2d3Tan from GccIter; - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to a line and 2 curves. - -Create(Qualified1 : QualifiedLin from GccEnt ; - Qualified2 : TheQualifiedCurve ; - Point3 : Pnt2d ; - Param1 : Real ; - Param2 : Real ; - Tolerance : Real ) -returns Circ2d3Tan from GccIter; - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to a line and a curve - -- and a point. - -Create(Qualified1 : TheQualifiedCurve ; - Point1 : Pnt2d ; - Point2 : Pnt2d ; - Param1 : Real ; - Tolerance : Real ) -returns Circ2d3Tan from GccIter; - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to a curve and 2 points. - -Create(Qualified1 : TheQualifiedCurve ; - Qualified2 : TheQualifiedCurve ; - Point2 : Pnt2d ; - Param1 : Real ; - Param2 : Real ; - Tolerance : Real ) -returns Circ2d3Tan from GccIter; - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to 2 curves and a point. - -Create(Qualified1 : TheQualifiedCurve ; - Qualified2 : TheQualifiedCurve ; - Qualified3 : TheQualifiedCurve ; - Param1 : Real ; - Param2 : Real ; - Param3 : Real ; - Tolerance : Real ) -returns Circ2d3Tan from GccIter; - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to 3 curves. - --- -- .................................................................... - -IsDone(me) returns Boolean -is static; - ---Purpose: This method returns True if the construction - -- algorithm succeeded. - -ThisSolution(me) returns Circ2d - ---Purpose: Returns the solution. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -WhichQualifier(me ; - Qualif1 : out Position from GccEnt; - Qualif2 : out Position from GccEnt; - Qualif3 : out Position from GccEnt) -raises NotDone from StdFail -is static; - -- It returns the informations about the qualifiers of the tangency - -- arguments concerning the solution number Index. - -- It returns the real qualifiers (the qualifiers given to the - -- constructor method in case of enclosed, enclosing and outside - -- and the qualifiers computedin case of unqualified). - -Tangency1(me ; - ParSol,ParArg : out Real ; - PntSol : out Pnt2d) - ---Purpose: Returns informations about the tangency point between - -- the result and the first argument. - -- ParSol is the intrinsic parameter of the point PntSol - -- on the solution curv. - -- ParArg is the intrinsic parameter of the point PntSol - -- on the argument curv. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -Tangency2(me ; - ParSol,ParArg : out Real ; - PntSol : out Pnt2d) - ---Purpose: Returns informations about the tangency point between - -- the result and the second argument. - -- ParSol is the intrinsic parameter of the point PntSol - -- on the solution curv. - -- ParArg is the intrinsic parameter of the point PntSol - -- on the argument curv. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -Tangency3(me ; - ParSol,ParArg : out Real ; - PntSol : out Pnt2d) - ---Purpose: Returns informations about the tangency point between - -- the result and the third argument. - -- ParSol is the intrinsic parameter of the point PntSol - -- on the solution curv. - -- ParArg is the intrinsic parameter of the point PntSol - -- on the argument curv. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -IsTheSame1(me) returns Boolean - -- Returns True if the solution is equal to the first argument. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -IsTheSame2(me) returns Boolean - -- Returns True if the solution is equal to the second argument. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -IsTheSame3(me) returns Boolean - -- Returns True if the solution is equal to the third argument. -raises NotDone from StdFail -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -fields - - WellDone : Boolean; - ---Purpose: True if the algorithm succeeded. - - cirsol : Circ2d; - ---Purpose: The solutions. - - qualifier1 : Position from GccEnt; - -- The qualifiers of the first argument. - - qualifier2 : Position from GccEnt; - -- The qualifiers of the first argument. - - qualifier3 : Position from GccEnt; - -- The qualifiers of the first argument. - - TheSame1 : Boolean; - ---Purpose: True if the solution and the first argument are identical. - -- Two circles are identical if the difference between the - -- radius of one and the sum of the radius of the other and - -- the distance between the centers is less than Tolerance. - -- False in the other cases. - - TheSame2 : Boolean; - ---Purpose: True if the solution and the second argument are identical. - -- Two circles are identical if the difference between the - -- radius of one and the sum of the radius of the other and - -- the distance between the centers is less than Tolerance. - -- False in the other cases. - - TheSame3 : Boolean; - ---Purpose: True if the solution and the third argument are identical. - -- Two circles are identical if the difference between the - -- radius of one and the sum of the radius of the other and - -- the distance between the centers is less than Tolerance. - -- False in the other cases. - - pnttg1sol : Pnt2d; - ---Purpose: The tangency point between the solution and the first - -- argument on the solution. - - pnttg2sol : Pnt2d; - ---Purpose: The tangency point between the solution and the second - -- argument on the solution. - - pnttg3sol : Pnt2d; - ---Purpose: The tangency point between the solution and the third - -- argument on the solution. - - par1sol : Real; - ---Purpose: The parameter of the tangency point between the solution - -- and the first argument on the solution. - - par2sol : Real; - ---Purpose: The parameter of the tangency point between the solution - -- and the second argument on the solution. - - par3sol : Real; - ---Purpose: The parameter of the tangency point between the solution - -- and the third argument on the solution. - - pararg1 : Real; - ---Purpose: The parameter of the tangency point between the solution - -- and the first argument on the first argument. - - pararg2 : Real; - ---Purpose: The parameter of the tangency point between the solution - -- and the second argument on the second argument. - - pararg3 : Real; - ---Purpose: The parameter of the tangency point between the solution - -- and the third argument on the second argument. - -end Circ2d3Tan; diff --git a/src/GccIter/GccIter_Circ2d3Tan.gxx b/src/GccIter/GccIter_Circ2d3Tan.gxx deleted file mode 100644 index 8fe0675c73..0000000000 --- a/src/GccIter/GccIter_Circ2d3Tan.gxx +++ /dev/null @@ -1,1351 +0,0 @@ -// Created on: 1991-12-13 -// Created by: Remi GILET -// Copyright (c) 1991-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. - -//========================================================================= -// Creation d un cercle tangent a deux elements : Droite. + -// Cercle. + -// Point. + -// Courbes. + -// centre sur un troisieme : Droite. + -// Cercle. + -// Courbes. + -//========================================================================= - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -GccIter_Circ2d3Tan:: - GccIter_Circ2d3Tan (const TheQualifiedCurve& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const TheQualifiedCurve& Qualified3 , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - TheSame3 = Standard_False; - par1sol = 0.; - par2sol = 0.; - par3sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - pararg3 = 0.; - - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified()) || - !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || - Qualified3.IsOutside() || Qualified3.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - TheCurve Cu1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - TheCurve Cu3 = Qualified3.Qualified(); - GccIter_FuncTCuCuCu Func(Cu1,Cu2,Cu3); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = TheCurveTool::FirstParameter(Cu1); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = TheCurveTool::FirstParameter(Cu3); - Umax(1) = TheCurveTool::LastParameter(Cu1); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = TheCurveTool::LastParameter(Cu3); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = TheCurveTool::EpsX(Cu1,Abs(Tolerance)); - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = TheCurveTool::EpsX(Cu3,Abs(Tolerance)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Root.Root(Ufirst); - Func.Value(Ufirst,Umin); - gp_Pnt2d point1,point2,point3; - gp_Vec2d Tan1,Tan2,Tan3; - TheCurveTool::D1(Cu1,Ufirst(1),point1,Tan1); - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); - TheCurveTool::D1(Cu3,Ufirst(3),point3,Tan3); - GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); - if (circ.IsDone()) { - cirsol = circ.ThisSolution(1); - gp_Pnt2d centre = cirsol.Location(); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - Standard_Real normetan3 = Tan3.Magnitude(); - gp_Vec2d Vec1(point1,centre); - gp_Vec2d Vec2(point2,centre); - gp_Vec2d Vec3(point3,centre); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real normevec3 = Vec3.Magnitude(); - Standard_Real dot1,dot2,dot3; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); - } - else { dot1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); - } - else { dot2 = 0.; } - if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { - dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); - } - else { dot3 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { - Standard_Real Angle1 = Vec1.Angle(Tan1); - if (Qualified1.IsUnqualified()|| - (Qualified1.IsEnclosing()&&Angle1<=0.)|| - (Qualified1.IsOutside() && Angle1 >= 0.) || - (Qualified1.IsEnclosed() && Angle1 <= 0.)) { - Angle1 = Vec2.Angle(Tan2); - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&Angle1<=0.)|| - (Qualified2.IsOutside() && Angle1 >= 0) || - (Qualified2.IsEnclosed() && Angle1 <= 0.)) { - Angle1 = Vec3.Angle(Tan3); - if (Qualified3.IsUnqualified() || - (Qualified3.IsEnclosing()&&Angle1<=0.)|| - (Qualified3.IsOutside() && Angle1 >= 0) || - (Qualified3.IsEnclosed() && Angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - qualifier3 = Qualified3.Qualifier(); - pararg1 = Ufirst(1); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(2); - pnttg2sol = point2; - par2sol = pnttg2sol.Distance(pnttg1sol); - pnttg3sol = point3; - pararg3 = Ufirst(3); - par3sol = pnttg3sol.Distance(pnttg1sol); - WellDone = Standard_True; - } - } - } - } - } - } - } - -GccIter_Circ2d3Tan:: - GccIter_Circ2d3Tan (const GccEnt_QualifiedCirc& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const TheQualifiedCurve& Qualified3 , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - TheSame3 = Standard_False; - par1sol = 0.; - par2sol = 0.; - par3sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - pararg3 = 0.; - - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified()) || - !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || - Qualified3.IsOutside() || Qualified3.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Circ2d C1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - TheCurve Cu3 = Qualified3.Qualified(); - GccIter_FuncTCuCuCu Func(C1,Cu2,Cu3); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = 0.; - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = TheCurveTool::FirstParameter(Cu3); - Umax(1) = 2*M_PI; - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = TheCurveTool::LastParameter(Cu3); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = 2.e-15*M_PI; - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = TheCurveTool::EpsX(Cu3,Abs(Tolerance)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Root.Root(Ufirst); - Func.Value(Ufirst,Umin); - gp_Pnt2d centre1(C1.Location()); - Standard_Real R1 = C1.Radius(); - gp_Pnt2d point1(centre1.XY()+R1*gp_XY(Cos(Ufirst(1)),Sin(Ufirst(1)))); - gp_Vec2d Tan1(gp_XY(-Sin(Ufirst(1)),Cos(Ufirst(1)))); - gp_Pnt2d point2,point3; -// gp_Vec2d Tan2,Tan3,Nor2,Nor3; - gp_Vec2d Tan2,Tan3; - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); - TheCurveTool::D1(Cu3,Ufirst(3),point3,Tan3); - GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); - if (circ.IsDone()) { - cirsol = circ.ThisSolution(1); - gp_Pnt2d centre(cirsol.Location()); - Standard_Real dist = centre1.Distance(centre); - Standard_Real Rsol = cirsol.Radius(); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - Standard_Real normetan3 = Tan3.Magnitude(); - gp_Vec2d Vec1(point1,centre); - gp_Vec2d Vec2(point2,centre); - gp_Vec2d Vec3(point3,centre); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real normevec3 = Vec3.Magnitude(); - Standard_Real dot1,dot2,dot3; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); - } - else { dot1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); - } - else { dot2 = 0.; } - if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { - dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); - } - else { dot3 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| - (Qualified1.IsOutside() && dist >= Rsol) || - (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { - Standard_Real Angle1 = Vec2.Angle(Tan2); - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&Angle1<=0.)|| - (Qualified2.IsOutside() && Angle1 >= 0) || - (Qualified2.IsEnclosed() && Angle1 <= 0.)) { - Angle1 = Vec3.Angle(Tan3); - if (Qualified3.IsUnqualified() || - (Qualified3.IsEnclosing()&&Angle1<=0.)|| - (Qualified3.IsOutside() && Angle1 >= 0) || - (Qualified3.IsEnclosed() && Angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - qualifier3 = Qualified3.Qualifier(); - pararg1 = Ufirst(1); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(2); - pnttg2sol = point2; - par2sol = 0.; - pararg3 = Ufirst(3); - pnttg3sol = point3; - par3sol = 0.; - WellDone = Standard_True; - } - } - } - } - } - } - } - -GccIter_Circ2d3Tan:: - GccIter_Circ2d3Tan (const GccEnt_QualifiedCirc& Qualified1 , - const GccEnt_QualifiedCirc& Qualified2 , - const TheQualifiedCurve& Qualified3 , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - TheSame3 = Standard_False; - par1sol = 0.; - par2sol = 0.; - par3sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - pararg3 = 0.; - - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified()) || - !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || - Qualified3.IsOutside() || Qualified3.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Circ2d C1 = Qualified1.Qualified(); - gp_Circ2d C2 = Qualified2.Qualified(); - TheCurve Cu3 = Qualified3.Qualified(); - GccIter_FuncTCuCuCu Func(C1,C2,Cu3); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = 0.; - Umin(2) = 0.; - Umin(3) = TheCurveTool::FirstParameter(Cu3); - Umax(1) = 2*M_PI; - Umax(2) = 2*M_PI; - Umax(3) = TheCurveTool::LastParameter(Cu3); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = 2.e-15*M_PI; - tol(2) = 2.e-15*M_PI; - tol(3) = TheCurveTool::EpsX(Cu3,Abs(Tolerance)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Root.Root(Ufirst); - Func.Value(Ufirst,Umin); - gp_Pnt2d centre1(C1.Location()); - Standard_Real R1 = C1.Radius(); - gp_Pnt2d point1(centre1.XY()+R1*gp_XY(Cos(Ufirst(1)),Sin(Ufirst(1)))); - gp_Vec2d Tan1(gp_XY(-Sin(Ufirst(1)),Cos(Ufirst(1)))); - gp_Pnt2d centre2(C2.Location()); - Standard_Real R2 = C2.Radius(); - gp_Pnt2d point2(centre2.XY()+R2*gp_XY(Cos(Ufirst(2)),Sin(Ufirst(2)))); - gp_Vec2d Tan2(gp_XY(-Sin(Ufirst(2)),Cos(Ufirst(2)))); - gp_Pnt2d point3; - gp_Vec2d Tan3; - TheCurveTool::D1(Cu3,Ufirst(3),point3,Tan3); - GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); - if (circ.IsDone()) { - cirsol = circ.ThisSolution(1); - gp_Pnt2d centre(cirsol.Location()); - Standard_Real dist = centre1.Distance(centre); - Standard_Real Rsol = cirsol.Radius(); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - Standard_Real normetan3 = Tan3.Magnitude(); - gp_Vec2d Vec1(point1,centre); - gp_Vec2d Vec2(point2,centre); - gp_Vec2d Vec3(point3,centre); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real normevec3 = Vec3.Magnitude(); - Standard_Real dot1,dot2,dot3; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); - } - else { dot1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); - } - else { dot2 = 0.; } - if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { - dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); - } - else { dot3 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| - (Qualified1.IsOutside() && dist >= Rsol) || - (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { - dist = centre2.Distance(centre); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && Rsol >= R2 && dist <= Rsol)|| - (Qualified1.IsOutside() && dist >= Rsol) || - (Qualified1.IsEnclosed() && Rsol <= R2 && dist <= Rsol)) { - gp_Vec2d Vec(point3,centre); - Standard_Real Angle1 = Vec.Angle(Tan3); - if (Qualified3.IsUnqualified() || - (Qualified3.IsEnclosing()&&Angle1<=0.)|| - (Qualified3.IsOutside() && Angle1 >= 0) || - (Qualified3.IsEnclosed() && Angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - qualifier3 = Qualified3.Qualifier(); - pararg1 = Ufirst(1); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(2); - pnttg2sol = point2; - par2sol = 0.; - pararg3 = Ufirst(3); - pnttg3sol = point3; - par3sol = 0.; - WellDone = Standard_True; - } - } - } - } - } - } - } - -GccIter_Circ2d3Tan:: - GccIter_Circ2d3Tan (const GccEnt_QualifiedLin& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const TheQualifiedCurve& Qualified3 , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - TheSame3 = Standard_False; - par1sol = 0.; - par2sol = 0.; - par3sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - pararg3 = 0.; - - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified()) || - !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || - Qualified3.IsOutside() || Qualified3.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Lin2d L1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - TheCurve Cu3 = Qualified3.Qualified(); - GccIter_FuncTCuCuCu Func(L1,Cu2,Cu3); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = RealFirst(); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umin(3) = TheCurveTool::FirstParameter(Cu3); - Umax(1) = RealLast(); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Umax(3) = TheCurveTool::LastParameter(Cu3); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = 1.e-15; - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - tol(3) = TheCurveTool::EpsX(Cu3,Abs(Tolerance)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Root.Root(Ufirst); - Func.Value(Ufirst,Umin); - gp_Pnt2d centre1(L1.Location()); - gp_Pnt2d point1(centre1.XY()+Ufirst(1)*L1.Direction().XY()); - gp_Pnt2d point2,point3; - gp_Vec2d Tan2,Tan3; - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); - TheCurveTool::D1(Cu3,Ufirst(3),point3,Tan3); - GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); - if (circ.IsDone()) { - cirsol = circ.ThisSolution(1); - gp_Pnt2d centre(cirsol.Location()); - - // creation vaariables intermediaires pour WNT - gp_XY dummy1 = centre.XY()-L1.Location().XY(); - gp_XY dummy2 (-L1.Direction().Y(),L1.Direction().X()); - Standard_Real pscal=dummy1.Dot(dummy2); - - gp_Vec2d Tan1(L1.Direction().XY()); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - Standard_Real normetan3 = Tan3.Magnitude(); - gp_Vec2d Vec1(point1,centre); - gp_Vec2d Vec2(point2,centre); - gp_Vec2d Vec3(point3,centre); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real normevec3 = Vec3.Magnitude(); - Standard_Real dot1,dot2,dot3; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); - } - else { dot1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); - } - else { dot2 = 0.; } - if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { - dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); - } - else { dot3 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { - if (Qualified1.IsUnqualified() || - (Qualified1.IsOutside() && pscal <= 0.) || - (Qualified1.IsEnclosed() && pscal >= 0.)) { - gp_Vec2d Vec(point2,centre); - Standard_Real Angle1 = Vec.Angle(Tan2); - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&Angle1<=0.)|| - (Qualified2.IsOutside() && Angle1 >= 0) || - (Qualified2.IsEnclosed() && Angle1 <= 0.)) { - Vec = gp_Vec2d(point3,centre); - Angle1 = Vec.Angle(Tan3); - if (Qualified3.IsUnqualified() || - (Qualified3.IsEnclosing()&&Angle1<=0.)|| - (Qualified3.IsOutside() && Angle1 >= 0) || - (Qualified3.IsEnclosed() && Angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - qualifier3 = Qualified3.Qualifier(); - pararg1 = Ufirst(1); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(2); - pnttg2sol = point2; - par2sol = 0.; - pararg3 = Ufirst(3); - pnttg3sol = point3; - par3sol = 0.; - WellDone = Standard_True; - } - } - } - } - } - } - } - -GccIter_Circ2d3Tan:: - GccIter_Circ2d3Tan (const GccEnt_QualifiedLin& Qualified1 , - const GccEnt_QualifiedLin& Qualified2 , - const TheQualifiedCurve& Qualified3 , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ){ - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - TheSame3 = Standard_False; - par1sol = 0.; - par2sol = 0.; - par3sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - pararg3 = 0.; - - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || - Qualified2.IsOutside() || Qualified2.IsUnqualified()) || - !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || - Qualified3.IsOutside() || Qualified3.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Lin2d L1 = Qualified1.Qualified(); - gp_Lin2d L2 = Qualified2.Qualified(); - TheCurve Cu3 = Qualified3.Qualified(); - GccIter_FuncTCuCuCu Func(L1,L2,Cu3); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = RealFirst(); - Umin(2) = RealFirst(); - Umin(3) = TheCurveTool::FirstParameter(Cu3); - Umax(1) = RealLast(); - Umax(2) = RealLast(); - Umax(3) = TheCurveTool::LastParameter(Cu3); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = 1.e-15; - tol(2) = 1.e-15; - tol(3) = TheCurveTool::EpsX(Cu3,Abs(Tolerance)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Root.Root(Ufirst); - Func.Value(Ufirst,Umin); - gp_Pnt2d centre1(L1.Location()); - gp_Pnt2d point1(centre1.XY()+Ufirst(1)*L1.Direction().XY()); - gp_Pnt2d centre2(L2.Location()); - gp_Pnt2d point2(centre2.XY()+Ufirst(2)*L2.Direction().XY()); - gp_Pnt2d point3; - gp_Vec2d Tan3; - TheCurveTool::D1(Cu3,Ufirst(3),point3,Tan3); - GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); - if (circ.IsDone()) { - cirsol = circ.ThisSolution(1); - gp_Pnt2d centre(cirsol.Location()); - Standard_Real pscal=centre.XY().Dot(gp_XY(-L1.Direction().Y(), - L1.Direction().X())); - if (Qualified1.IsUnqualified() || - (Qualified1.IsOutside() && pscal <= 0.) || - (Qualified1.IsEnclosed() && pscal >= 0.)) { - Standard_Real pscal=centre.XY().Dot(gp_XY(-L1.Direction().Y(), - L1.Direction().X())); - gp_Vec2d Tan1(L1.Direction().XY()); - gp_Vec2d Tan2(L2.Direction().XY()); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - Standard_Real normetan3 = Tan3.Magnitude(); - gp_Vec2d Vec1(point1,centre); - gp_Vec2d Vec2(point2,centre); - gp_Vec2d Vec3(point3,centre); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real normevec3 = Vec3.Magnitude(); - Standard_Real dot1,dot2,dot3; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); - } - else { dot1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); - } - else { dot2 = 0.; } - if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { - dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); - } - else { dot3 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { - if (Qualified2.IsUnqualified() || - (Qualified2.IsOutside() && pscal <= 0.) || - (Qualified2.IsEnclosed() && pscal >= 0.)) { - Standard_Real Angle1 = Vec3.Angle(Tan3); - if (Qualified3.IsUnqualified() || - (Qualified3.IsEnclosing()&&Angle1<=0.)|| - (Qualified3.IsOutside() && Angle1 >= 0) || - (Qualified3.IsEnclosed() && Angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - qualifier3 = Qualified3.Qualifier(); - pararg1 = Ufirst(1); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(2); - pnttg2sol = point2; - par2sol = 0.; - pararg3 = Ufirst(3); - pnttg3sol = point3; - par3sol = 0.; - WellDone = Standard_True; - } - } - } - } - } - } - } - -GccIter_Circ2d3Tan:: - GccIter_Circ2d3Tan (const TheQualifiedCurve& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const gp_Pnt2d& Point3 , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Tolerance ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - TheSame3 = Standard_False; - par1sol = 0.; - par2sol = 0.; - par3sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - pararg3 = 0.; - - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Circ2d C1(gp_Ax2d(Point3,gp_Dir2d(1.,0.)),0.); - TheCurve Cu1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - GccIter_FuncTCuCuCu Func(C1,Cu1,Cu2); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = 0.; - Umin(2) = TheCurveTool::FirstParameter(Cu1); - Umin(3) = TheCurveTool::FirstParameter(Cu2); - Umax(1) = 2*M_PI; - Umax(2) = TheCurveTool::LastParameter(Cu1); - Umax(3) = TheCurveTool::LastParameter(Cu2); - Ufirst(1) = M_PI; - Ufirst(2) = Param1; - Ufirst(3) = Param2; - tol(1) = 2.e-15*M_PI; - tol(2) = TheCurveTool::EpsX(Cu1,Abs(Tolerance)); - tol(3) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Root.Root(Ufirst); - Func.Value(Ufirst,Umin); - gp_Pnt2d point1,point2; -// gp_Vec2d Tan1,Tan2,Nor1,Nor2; - gp_Vec2d Tan1,Tan2; - TheCurveTool::D1(Cu1,Ufirst(2),point1,Tan1); - TheCurveTool::D1(Cu2,Ufirst(3),point2,Tan2); - GccAna_Circ2d3Tan circ(Point3,point1,point2,Tol); - if (circ.IsDone()) { - cirsol = circ.ThisSolution(1); - gp_Pnt2d centre(cirsol.Location()); - gp_Vec2d Tan3(-Sin(Ufirst(1)),Cos(Ufirst(1))); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - Standard_Real normetan3 = Tan3.Magnitude(); - gp_Vec2d Vec1(point1,centre); - gp_Vec2d Vec2(point2,centre); - gp_Vec2d Vec3(Point3,centre); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real normevec3 = Vec3.Magnitude(); - Standard_Real dot1,dot2,dot3; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); - } - else { dot1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); - } - else { dot2 = 0.; } - if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { - dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); - } - else { dot3 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { - Standard_Real Angle1 = Vec1.Angle(Tan1); - if (Qualified1.IsUnqualified()|| - (Qualified1.IsEnclosing()&&Angle1<=0.)|| - (Qualified1.IsOutside() && Angle1 >= 0) || - (Qualified1.IsEnclosed() && Angle1 <= 0.)) { - Angle1 = Vec2.Angle(Tan2); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing()&&Angle1<=0.)|| - (Qualified1.IsOutside() && Angle1 >= 0) || - (Qualified1.IsEnclosed() && Angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - qualifier3 = GccEnt_noqualifier; - pararg1 = Ufirst(2); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(3); - pnttg2sol = point2; - par2sol = 0.; - pararg3 = 0.; - pnttg3sol = Point3; - par3sol = 0.; - WellDone = Standard_True; - } - } - } - } - } - } - -GccIter_Circ2d3Tan:: - GccIter_Circ2d3Tan (const TheQualifiedCurve& Qualified1 , - const gp_Pnt2d& Point2 , - const gp_Pnt2d& Point3 , - const Standard_Real Param1 , - const Standard_Real Tolerance ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - TheSame3 = Standard_False; - par1sol = 0.; - par2sol = 0.; - par3sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - pararg3 = 0.; - - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Dir2d dirx(1.,0.); - gp_Circ2d C1(gp_Ax2d(Point2,dirx),0.); - gp_Circ2d C2(gp_Ax2d(Point3,dirx),0.); - TheCurve Cu1 = Qualified1.Qualified(); - GccIter_FuncTCuCuCu Func(C1,C2,Cu1); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = 0.; - Umin(2) = 0.; - Umin(3) = TheCurveTool::FirstParameter(Cu1); - Umax(1) = 2*M_PI; - Umax(2) = 2*M_PI; - Umax(3) = TheCurveTool::LastParameter(Cu1); - Ufirst(1) = M_PI; - Ufirst(2) = M_PI; - Ufirst(3) = Param1; - tol(1) = 2.e-15*M_PI; - tol(2) = 2.e-15*M_PI; - tol(3) = TheCurveTool::EpsX(Cu1,Abs(Tolerance)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Root.Root(Ufirst); - Func.Value(Ufirst,Umin); - gp_Pnt2d point3; -// gp_Vec2d Tan3,Nor3; - gp_Vec2d Tan3; - TheCurveTool::D1(Cu1,Ufirst(3),point3,Tan3); - GccAna_Circ2d3Tan circ(Point2,Point3,point3,Tol); - if (circ.IsDone()) { - cirsol = circ.ThisSolution(1); - gp_Pnt2d centre(cirsol.Location()); - gp_Vec2d Tan2(-Sin(Ufirst(2)),Cos(Ufirst(2))); - gp_Vec2d Tan1(-Sin(Ufirst(1)),Cos(Ufirst(1))); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - Standard_Real normetan3 = Tan3.Magnitude(); - gp_Vec2d Vec1(Point2,centre); - gp_Vec2d Vec2(Point3,centre); - gp_Vec2d Vec3(point3,centre); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real normevec3 = Vec3.Magnitude(); - Standard_Real dot1,dot2,dot3; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); - } - else { dot1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); - } - else { dot2 = 0.; } - if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { - dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); - } - else { dot3 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { - Standard_Real Angle1 = Vec1.Angle(Tan1); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing()&&Angle1<=0.)|| - (Qualified1.IsOutside() && Angle1 >= 0) || - (Qualified1.IsEnclosed() && Angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = GccEnt_noqualifier; - qualifier3 = GccEnt_noqualifier; - pararg1 = Ufirst(3); - par1sol = 0.; - pnttg1sol = point3; - pararg2 = 0.; - pnttg2sol = Point2; - par2sol = 0.; - pararg3 = 0.; - pnttg3sol = Point3; - par3sol = 0.; - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Circ2d3Tan:: - GccIter_Circ2d3Tan (const GccEnt_QualifiedLin& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const gp_Pnt2d& Point3 , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Tolerance ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - TheSame3 = Standard_False; - par1sol = 0.; - par2sol = 0.; - par3sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - pararg3 = 0.; - - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Dir2d dirx(1.,0.); - gp_Lin2d L1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - gp_Circ2d C3(gp_Ax2d(Point3,dirx),0.); - GccIter_FuncTCuCuCu Func(C3,L1,Cu2); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(2) = RealFirst(); - Umin(3) = TheCurveTool::FirstParameter(Cu2); - Umin(1) = 0.; - Umax(2) = RealLast(); - Umax(3) = TheCurveTool::LastParameter(Cu2); - Umax(1) = 2*M_PI; - Ufirst(2) = Param1; - Ufirst(3) = Param2; - Ufirst(1) = M_PI; - tol(1) = 2.e-15; - tol(2) = 1.e-15; - tol(3) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Root.Root(Ufirst); - Func.Value(Ufirst,Umin); - gp_Pnt2d centre1(L1.Location()); - gp_Pnt2d point1(centre1.XY()+Ufirst(2)*L1.Direction().XY()); - gp_Pnt2d point2; - gp_Vec2d Tan2; - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); - GccAna_Circ2d3Tan circ(point1,point2,Point3,Tol); - if (circ.IsDone()) { - cirsol = circ.ThisSolution(1); - gp_Pnt2d centre(cirsol.Location()); - Standard_Real pscal=centre.XY().Dot(gp_XY(-L1.Direction().Y(), - L1.Direction().X())); - gp_Vec2d Tan1(L1.Direction().XY()); - gp_Vec2d Tan3(-Sin(Ufirst(1)),Cos(Ufirst(1))); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - Standard_Real normetan3 = Tan3.Magnitude(); - gp_Vec2d Vec1(point1,centre); - gp_Vec2d Vec2(point2,centre); - gp_Vec2d Vec3(Point3,centre); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real normevec3 = Vec3.Magnitude(); - Standard_Real dot1,dot2,dot3; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); - } - else { dot1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); - } - else { dot2 = 0.; } - if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { - dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); - } - else { dot3 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { - if (Qualified1.IsUnqualified() || - (Qualified1.IsOutside() && pscal <= 0.) || - (Qualified1.IsEnclosed() && pscal >= 0.)) { - Standard_Real Angle1 = Vec2.Angle(Tan2); - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&Angle1<=0.)|| - (Qualified2.IsOutside() && Angle1 >= 0) || - (Qualified2.IsEnclosed() && Angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - qualifier3 = GccEnt_noqualifier; - pararg1 = Ufirst(2); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(3); - pnttg2sol = point2; - par2sol = 0.; - pararg3 = 0.; - pnttg3sol = Point3; - par3sol = 0.; - WellDone = Standard_True; - } - } - } - } - } - } - -GccIter_Circ2d3Tan:: - GccIter_Circ2d3Tan (const GccEnt_QualifiedCirc& Qualified1 , - const GccEnt_QualifiedLin& Qualified2 , - const TheQualifiedCurve& Qualified3 , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Param3 , - const Standard_Real Tolerance ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - TheSame3 = Standard_False; - par1sol = 0.; - par2sol = 0.; - par3sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - pararg3 = 0.; - - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || - Qualified2.IsOutside() || Qualified2.IsUnqualified()) || - !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || - Qualified3.IsOutside() || Qualified3.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Circ2d C1 = Qualified1.Qualified(); - gp_Lin2d L2 = Qualified2.Qualified(); - TheCurve Cu3 = Qualified3.Qualified(); - GccIter_FuncTCuCuCu Func(C1,L2,Cu3); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = 0.; - Umin(2) = RealFirst(); - Umin(3) = TheCurveTool::FirstParameter(Cu3); - Umax(1) = 2*M_PI; - Umax(2) = RealLast(); - Umax(3) = TheCurveTool::LastParameter(Cu3); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - Ufirst(3) = Param3; - tol(1) = 2.e-15*M_PI; - tol(2) = 1.e-15; - tol(3) = TheCurveTool::EpsX(Cu3,Abs(Tolerance)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Func.Value(Ufirst,Umin); - Root.Root(Ufirst); - gp_Pnt2d centre1(C1.Location()); - Standard_Real R1 = C1.Radius(); - gp_Pnt2d point1(centre1.XY()+R1*gp_XY(Cos(Ufirst(1)),Sin(Ufirst(1)))); - gp_Pnt2d centre2(L2.Location()); - gp_Pnt2d point2(centre2.XY()+Ufirst(2)*L2.Direction().XY()); - gp_Pnt2d point3; - gp_Vec2d Tan3; - TheCurveTool::D1(Cu3,Ufirst(3),point3,Tan3); - GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); - if (circ.IsDone()) { - cirsol = circ.ThisSolution(1); - gp_Pnt2d centre(cirsol.Location()); - gp_Vec2d Tan1(-Sin(Ufirst(1)),Cos(Ufirst(1))); - gp_Vec2d Tan2(L2.Direction().XY()); - Standard_Real normetan1 = Tan1.Magnitude(); - Standard_Real normetan2 = Tan2.Magnitude(); - Standard_Real normetan3 = Tan3.Magnitude(); - gp_Vec2d Vec1(point1,centre); - gp_Vec2d Vec2(point2,centre); - gp_Vec2d Vec3(point3,centre); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real normevec3 = Vec3.Magnitude(); - Standard_Real dot1,dot2,dot3; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); - } - else { dot1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); - } - else { dot2 = 0.; } - if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { - dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); - } - else { dot3 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { - Standard_Real dist = centre1.Distance(centre); - Standard_Real Rsol = cirsol.Radius(); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| - (Qualified1.IsOutside() && dist >= Rsol) || - (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { - Standard_Real pscal=centre.XY().Dot(gp_XY(-L2.Direction().Y(), - L2.Direction().X())); - if (Qualified2.IsUnqualified() || - (Qualified2.IsOutside() && pscal <= 0.) || - (Qualified2.IsEnclosed() && pscal >= 0.)) { - Standard_Real Angle1 = Vec3.Angle(Tan3); - if (Qualified3.IsUnqualified() || - (Qualified3.IsEnclosing()&&Angle1<=0.)|| - (Qualified3.IsOutside() && Angle1 >= 0) || - (Qualified3.IsEnclosed() && Angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - qualifier3 = Qualified3.Qualifier(); - pararg1 = Ufirst(1); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(2); - pnttg2sol = point2; - par2sol = 0.; - pararg3 = Ufirst(3); - pnttg3sol = point3; - par3sol = 0.; - WellDone = Standard_True; - } - } - } - } - } - } - } - -GccIter_Circ2d3Tan:: - GccIter_Circ2d3Tan (const GccEnt_QualifiedCirc& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const gp_Pnt2d& Point3 , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Tolerance ) { - - TheSame1 = Standard_False; - TheSame2 = Standard_False; - TheSame3 = Standard_False; - par1sol = 0.; - par2sol = 0.; - par3sol = 0.; - pararg1 = 0.; - pararg2 = 0.; - pararg3 = 0.; - - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Circ2d C1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - gp_Dir2d dirx(1.,0.); - gp_Circ2d C3(gp_Ax2d(Point3,dirx),0.); - GccIter_FuncTCuCuCu Func(C1,C3,Cu2); - math_Vector Umin(1,3); - math_Vector Umax(1,3); - math_Vector Ufirst(1,3); - math_Vector tol(1,3); - Umin(1) = 0.; - Umin(3) = TheCurveTool::FirstParameter(Cu2); - Umin(2) = 0.; - Umax(1) = 2*M_PI; - Umax(3) = TheCurveTool::LastParameter(Cu2); - Umax(2) = 2*M_PI; - Ufirst(1) = Param1; - Ufirst(2) = M_PI; - Ufirst(3) = Param2; - tol(1) = 2.e-15*M_PI; - tol(2) = 2.e-15*M_PI; - tol(3) = TheCurveTool::EpsX(Cu2,Abs(Tolerance)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Root.Root(Ufirst); - Func.Value(Ufirst,Umin); - gp_Pnt2d centre1(C1.Location()); - Standard_Real R1 = C1.Radius(); - gp_Pnt2d point1(centre1.XY()+R1*gp_XY(Cos(Ufirst(1)),Sin(Ufirst(1)))); - gp_Pnt2d point2; -// gp_Vec2d Tan2,Nor2; - gp_Vec2d Tan2; - TheCurveTool::D1(Cu2,Ufirst(2),point2,Tan2); - GccAna_Circ2d3Tan circ(point1,point2,Point3,Tol); - if (circ.IsDone()) { - cirsol = circ.ThisSolution(1); - gp_Pnt2d centre(cirsol.Location()); - gp_Vec2d Tan1(-Sin(Ufirst(1)),Cos(Ufirst(1))); - gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3))); - Standard_Real normetan2 = Tan2.Magnitude(); - gp_Vec2d Vec1(point1,centre); - gp_Vec2d Vec2(point2,centre); - gp_Vec2d Vec3(Point3,centre); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real normevec2 = Vec2.Magnitude(); - Standard_Real normevec3 = Vec3.Magnitude(); - Standard_Real dot1,dot2,dot3; - if (normevec1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1); - } - else { dot1 = 0.; } - if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { - dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); - } - else { dot2 = 0.; } - if (normevec3 >= gp::Resolution()) { - dot3 = Vec3.Dot(Tan3)/(normevec3); - } - else { dot3 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { - Standard_Real dist = centre1.Distance(centre); - Standard_Real Rsol = cirsol.Radius(); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| - (Qualified1.IsOutside() && dist >= Rsol) || - (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { - Standard_Real Angle1 = Vec2.Angle(Tan2); - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing()&&Angle1<=0.)|| - (Qualified2.IsOutside() && Angle1 >= 0) || - (Qualified2.IsEnclosed() && Angle1 <= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - qualifier3 = GccEnt_noqualifier; - pararg1 = Ufirst(1); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(2); - pnttg2sol = point2; - par2sol = 0.; - pararg3 = 0.; - pnttg3sol = Point3; - par3sol = 0.; - WellDone = Standard_True; - } - } - } - } - } - } - -Standard_Boolean GccIter_Circ2d3Tan:: - IsDone () const{ return WellDone; } - -gp_Circ2d GccIter_Circ2d3Tan:: - ThisSolution () const{ return cirsol; } - -void GccIter_Circ2d3Tan:: - WhichQualifier (GccEnt_Position& Qualif1 , - GccEnt_Position& Qualif2 , - GccEnt_Position& Qualif3 ) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - Qualif1 = qualifier1; - Qualif2 = qualifier2; - Qualif3 = qualifier3; - } -} - -void GccIter_Circ2d3Tan:: - Tangency1 (Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& PntSol ) const{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - if (TheSame1 == 0) { - ParSol = par1sol; - ParArg = pararg1; - PntSol = pnttg1sol; - } - else { StdFail_NotDone::Raise(); } - } - } - -void GccIter_Circ2d3Tan:: - Tangency2 (Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& PntSol ) const{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - ParSol = par2sol; - ParArg = pararg2; - PntSol = pnttg2sol; - } - } - -void GccIter_Circ2d3Tan:: - Tangency3 (Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& PntSol ) const{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - ParSol = par3sol; - ParArg = pararg3; - PntSol = pnttg3sol; - } - } - -Standard_Boolean GccIter_Circ2d3Tan:: - IsTheSame1 () const -{ - if (!WellDone) StdFail_NotDone::Raise(); - - if (TheSame1 == 0) - return Standard_False; - - return Standard_True; -} - - -Standard_Boolean GccIter_Circ2d3Tan:: - IsTheSame2 () const -{ - if (!WellDone) StdFail_NotDone::Raise(); - - if (TheSame3 == 0) - return Standard_False; - - return Standard_True; - -} - -Standard_Boolean GccIter_Circ2d3Tan:: - IsTheSame3 () const -{ - if (!WellDone) StdFail_NotDone::Raise(); - - return Standard_True; -} diff --git a/src/GccIter/GccIter_FunctionTanCirCu.cdl b/src/GccIter/GccIter_FunctionTanCirCu.cdl deleted file mode 100644 index 297a1bd9b9..0000000000 --- a/src/GccIter/GccIter_FunctionTanCirCu.cdl +++ /dev/null @@ -1,64 +0,0 @@ --- Created on: 1992-02-20 --- Created by: Remy GILET --- 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. - -generic class FunctionTanCirCu from GccIter ( - TheCurve as any; - TheCurveTool as any) -- as CurvePGTool from GccInt(TheCurve) - -inherits FunctionWithDerivative from math - - ---Purpose: This abstract class describes a Function of 1 Variable - -- used to find a line tangent to a curve and a circle. - -uses Circ2d from gp - -is - -Create (Circ : Circ2d from gp ; - Curv : TheCurve ) returns FunctionTanCirCu from GccIter; - -Value (me : in out ; - X : Real ; - F : out Real ) returns Boolean; - ---Purpose: Computes the value of the function F for the variable X. - -- It returns True if the computation is successfully done, - -- False otherwise. - -Derivative (me : in out ; - X : Real ; - Deriv : out Real ) returns Boolean; - ---Purpose: Computes the derivative of the function F for the variable X. - -- It returns True if the computation is successfully done, - -- False otherwise. - -Values (me : in out ; - X : Real ; - F : out Real ; - Deriv : out Real ) returns Boolean; - ---Purpose: Computes the value and the derivative of the function F - -- for the variable X. - -- It returns True if the computation is successfully done, - -- False otherwise. - -fields - -TheCirc : Circ2d from gp; -Curve : TheCurve; --- Modified by Sergey KHROMOV - Thu Apr 5 09:50:18 2001 Begin -myWeight : Real; --- Modified by Sergey KHROMOV - Thu Apr 5 09:50:19 2001 End - -end FunctionTanCirCu; diff --git a/src/GccIter/GccIter_FunctionTanCirCu.gxx b/src/GccIter/GccIter_FunctionTanCirCu.gxx deleted file mode 100644 index fd44747b26..0000000000 --- a/src/GccIter/GccIter_FunctionTanCirCu.gxx +++ /dev/null @@ -1,134 +0,0 @@ -// Created on: 1992-01-20 -// Created by: Remi GILET -// 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. - -#include -#include -#include -#include - -//========================================================================= -// soit P1 le point sur la courbe TheCurve d abscisse u. + -// soit C le centre du cercle TheCirc. + -// Nous recherchons un point P2 appartenant au cercle tel que : + -// ---> --> + -// * P1P2 . CP2 = 0 + -// + -// * --> 2 2 + -// ||CP2|| = R + -// Nous cherchons donc les zeros de la fonction suivante: + -// --> --> 2 + -// --> 2 ( CP1 . T ) 2 + -// ||CP1|| - ----------- - R = F(u) + -// --> 2 + -// ||T|| + -// + -// La derivee de cette fonction est : + -// + -// 2*(CP1.T)(CP1.N) 2*(CP1.T)*(CP1.T)*T.N + -// f(u) = - ---------------- + --------------------- + -// T.T (T.T)*(T.T) + -//========================================================================= -// + -// skv: Small addition: The function and the derivative are normalized + -// by an average square distance between the circle + -// and the curve. + -//========================================================================= - -GccIter_FunctionTanCirCu:: - GccIter_FunctionTanCirCu(const gp_Circ2d& Circ , - const TheCurve& Curv ) { - Curve = Curv; - TheCirc = Circ; - -// Modified by Sergey KHROMOV - Thu Apr 5 09:51:21 2001 Begin - Standard_Integer aNbSamp = TheCurveTool::NbSamples(Curve); - Standard_Real aFirst = TheCurveTool::FirstParameter(Curve); - Standard_Real aLast = TheCurveTool::LastParameter(Curve); - Standard_Real aStep = (aLast - aFirst)/aNbSamp; - Standard_Real anX = aFirst + aStep/2.; - Standard_Integer aNbP = 0; - gp_XY aLoc(0., 0.); - - while (anX <= aLast) { - aLoc += (TheCurveTool::Value(Curve, anX)).XY(); - anX += aStep; - aNbP++; - } - myWeight = Max((aLoc - TheCirc.Location().XY()).SquareModulus(), TheCirc.Radius()); -// Modified by Sergey KHROMOV - Thu Apr 5 09:51:25 2001 End - } - - -Standard_Boolean GccIter_FunctionTanCirCu:: - Value (const Standard_Real X , - Standard_Real& Fval ) { - gp_Pnt2d Point; - gp_Vec2d Vect1; - TheCurveTool::D1(Curve,X,Point,Vect1); - Standard_Real NormeD1 = Vect1.Magnitude(); - gp_Vec2d TheDirection(TheCirc.Location(),Point); - Standard_Real squaredir = TheDirection.Dot(TheDirection); - Standard_Real R = TheCirc.Radius(); - Fval = squaredir-R*R- - (TheDirection.Dot(Vect1))*(TheDirection.Dot(Vect1))/(NormeD1*NormeD1); -// Modified by Sergey KHROMOV - Thu Apr 5 17:38:05 2001 Begin - Fval /= myWeight; -// Modified by Sergey KHROMOV - Thu Apr 5 17:38:06 2001 End - return Standard_True; -} - -Standard_Boolean GccIter_FunctionTanCirCu:: - Derivative (const Standard_Real X , - Standard_Real& Deriv ) { - gp_Pnt2d Point; - gp_Vec2d Vect1,Vect2; - TheCurveTool::D2(Curve,X,Point,Vect1,Vect2); - Standard_Real NormeD1 = Vect1.SquareMagnitude(); - gp_Vec2d TheDirection(TheCirc.Location(),Point); - Standard_Real cp1dott = TheDirection.Dot(Vect1); - Deriv = -2.*(cp1dott/NormeD1)* - ((TheDirection.Dot(Vect2))-cp1dott*Vect1.Dot(Vect2)/NormeD1); -// Modified by Sergey KHROMOV - Thu Apr 5 17:38:15 2001 Begin - Deriv /= myWeight; -// Modified by Sergey KHROMOV - Thu Apr 5 17:38:15 2001 End - return Standard_True; -} - -Standard_Boolean GccIter_FunctionTanCirCu:: - Values (const Standard_Real X , - Standard_Real& Fval , - Standard_Real& Deriv ) { - gp_Pnt2d Point; - gp_Vec2d Vect1,Vect2; - TheCurveTool::D2(Curve,X,Point,Vect1,Vect2); - Standard_Real NormeD1 = Vect1.SquareMagnitude(); - gp_Vec2d TheDirection(TheCirc.Location(),Point); - Standard_Real squaredir = TheDirection.SquareMagnitude(); - Standard_Real cp1dott = TheDirection.Dot(Vect1); - Standard_Real R = TheCirc.Radius(); - - Fval = squaredir-R*R-cp1dott*cp1dott/NormeD1; -// Modified by Sergey KHROMOV - Thu Apr 5 17:38:28 2001 Begin - Fval /= myWeight; -// Modified by Sergey KHROMOV - Thu Apr 5 17:38:28 2001 End - - Deriv = -2.*(cp1dott/NormeD1)* - ((TheDirection.Dot(Vect2))-cp1dott*Vect1.Dot(Vect2)/NormeD1); -// Modified by Sergey KHROMOV - Thu Apr 5 17:37:36 2001 Begin - Deriv /= myWeight; -// Modified by Sergey KHROMOV - Thu Apr 5 17:37:37 2001 End - return Standard_True; -} diff --git a/src/GccIter/GccIter_FunctionTanCuCu.cdl b/src/GccIter/GccIter_FunctionTanCuCu.cdl deleted file mode 100644 index bb48f4623b..0000000000 --- a/src/GccIter/GccIter_FunctionTanCuCu.cdl +++ /dev/null @@ -1,90 +0,0 @@ --- Created on: 1992-02-20 --- Created by: Remy GILET --- 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. - -generic class FunctionTanCuCu from GccIter ( - TheCurve as any; - TheCurveTool as any) -- as CurvePGTool from GccInt (TheCurve) - -inherits FunctionSetWithDerivatives from math - - ---Purpose: This abstract class describes a Function of 1 Variable - -- used to find a line tangent to two curves. - -uses Vector from math, - Matrix from math, - Circ2d from gp, - Pnt2d from gp, - Vec2d from gp, - Type3 from GccIter - - -raises ConstructionError - -is - -Create (Curv1 : TheCurve ; - Curv2 : TheCurve ) returns FunctionTanCuCu from GccIter; - -Create (Circ1 : Circ2d from gp ; - Curv2 : TheCurve ) returns FunctionTanCuCu from GccIter; - -InitDerivative(me : in out ; - X : Vector from math ; - Point1,Point2 : out Pnt2d from gp ; - Tan1,Tan2,D21,D22 : out Vec2d from gp ) -raises ConstructionError -is static; - -NbVariables(me) returns Integer; - ---Purpose: returns the number of variables of the function. - -NbEquations(me) returns Integer; - ---Purpose: returns the number of equations of the function. - -Value (me : in out ; - X : Vector from math; - F : out Vector from math) returns Boolean; - ---Purpose: Computes the value of the function F for the variable X. - -- It returns True if the computation is successfully done, - -- False otherwise. - -Derivatives (me : in out ; - X : Vector from math; - Deriv : out Matrix from math) returns Boolean; - ---Purpose: Computes the derivative of the function F for the variable X. - -- It returns True if the computation is successfully done, - -- False otherwise. - -Values (me : in out ; - X : Vector from math; - F : out Vector from math; - Deriv : out Matrix from math) returns Boolean; - ---Purpose: Computes the value and the derivative of the function F - -- for the variable X. - -- It returns True if the computation is successfully done, - -- False otherwise. - -fields - -TheCurve1 : TheCurve ; -TheCurve2 : TheCurve ; -TheCirc1 : Circ2d from gp ; -TheType : Type3 from GccIter ; - -end FunctionTanCuCu; - - - diff --git a/src/GccIter/GccIter_FunctionTanCuCu.gxx b/src/GccIter/GccIter_FunctionTanCuCu.gxx deleted file mode 100644 index 1ef062ea7d..0000000000 --- a/src/GccIter/GccIter_FunctionTanCuCu.gxx +++ /dev/null @@ -1,213 +0,0 @@ -// Created on: 1992-01-20 -// Created by: Remi GILET -// 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. - -#include -#include -#include - -void GccIter_FunctionTanCuCu:: - InitDerivative(const math_Vector& X , - gp_Pnt2d& Point1, - gp_Pnt2d& Point2, - gp_Vec2d& Tan1 , - gp_Vec2d& Tan2 , - gp_Vec2d& D21 , - gp_Vec2d& D22 ) { - switch (TheType) { - case GccIter_CuCu: - { - TheCurveTool::D2(TheCurve1,X(1),Point1,Tan1,D21); - TheCurveTool::D2(TheCurve2,X(2),Point2,Tan2,D22); - } - break; - case GccIter_CiCu: - { - ElCLib::D2(X(1),TheCirc1,Point1,Tan1,D21); - TheCurveTool::D2(TheCurve2,X(2),Point2,Tan2,D22); - } - break; - default: - { - } - } -} - -GccIter_FunctionTanCuCu:: - GccIter_FunctionTanCuCu(const TheCurve& C1 , - const TheCurve& C2 ) { - TheCurve1 = C1; - TheCurve2 = C2; - TheType = GccIter_CuCu; -} - -GccIter_FunctionTanCuCu:: - GccIter_FunctionTanCuCu(const gp_Circ2d& C1 , - const TheCurve& C2 ) { - TheCirc1 = C1; - TheCurve2 = C2; - TheType = GccIter_CiCu; -} - - -//========================================================================= -// soit P1 le point sur la courbe TheCurve1 d abscisse u1. + -// soit P2 le point sur la courbe TheCurve2 d abscisse u2. + -// soit T1 la tangente a la courbe TheCurve1 en P1. + -// soit T2 la tangente a la courbe TheCurve2 en P2. + -// Nous voulons P1 et P2 tels que : + -// ---> --> + -// * P1P2 /\ T1 = 0 + -// + -// --> --> + -// * T1 /\ T2 = 0 + -// + -// Nous cherchons donc les zeros des fonctions suivantes: + -// ---> --> + -// * P1P2 /\ T1 + -// --------------- = F1(u) + -// ---> --> + -// ||P1P2||*||T1|| + -// + -// --> --> + -// * T1 /\ T2 + -// --------------- = F2(u) + -// --> --> + -// ||T2||*||T1|| + -// + -// Les derivees de ces fonctions sont : + -// 2 2 + -// dF1 P1P2/\N1 (P1P2/\T1)*[T1*(-T1).P1P2+P1P2*(T1.N1)] + -// ----- = --------------- - ----------------------------------------- + -// du1 3 3 + -// ||P1P2||*||T1|| ||P1P2|| * ||T1|| + -// + -// 2 + -// dF1 T2/\T1 (P1P2/\T1)*[T1*(T2.P1P2) + -// ----- = --------------- - ----------------------------------------- + -// du2 3 3 + -// ||P1P2||*||T1|| ||P1P2|| * ||T1|| + -// + -// 2 + -// dF2 N1/\T2 T1/\T2*(N1.T1)T2 + -// ----- = ---------------- - ----------------------------- + -// du1 3 3 + -// ||T1||*||T2|| ||T1|| * ||T2|| + -// + -// 2 + -// dF2 T1/\N2 T1/\T2*(N2.T2)T1 + -// ----- = ---------------- - ----------------------------- + -// du2 3 3 + -// ||T1||*||T2|| ||T1|| * ||T2|| + -// + -//========================================================================= - -Standard_Integer GccIter_FunctionTanCuCu:: - NbVariables() const { return 2; } - -Standard_Integer GccIter_FunctionTanCuCu:: - NbEquations() const { return 2; } - -Standard_Boolean GccIter_FunctionTanCuCu:: - Value (const math_Vector& X , - math_Vector& Fval ) { - gp_Pnt2d Point1; - gp_Pnt2d Point2; - gp_Vec2d Vect11; - gp_Vec2d Vect21; - gp_Vec2d Vect12; - gp_Vec2d Vect22; - InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22); - Standard_Real NormeD11 = Vect11.Magnitude(); - Standard_Real NormeD21 = Vect21.Magnitude(); - gp_Vec2d TheDirection(Point1,Point2); - Standard_Real squaredir = TheDirection.Dot(TheDirection); - Fval(1) = TheDirection.Crossed(Vect11)/(NormeD11*squaredir); - Fval(2) = Vect11.Crossed(Vect21)/(NormeD11*NormeD21); - return Standard_True; -} - -Standard_Boolean GccIter_FunctionTanCuCu:: - Derivatives (const math_Vector& X , - math_Matrix& Deriv ) { - gp_Pnt2d Point1; - gp_Pnt2d Point2; - gp_Vec2d Vect11; - gp_Vec2d Vect21; - gp_Vec2d Vect12; - gp_Vec2d Vect22; - InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22); - Standard_Real NormeD11 = Vect11.Magnitude(); - Standard_Real NormeD21 = Vect21.Magnitude(); -#ifdef DEB - gp_Vec2d V2V1(Vect11.XY(),Vect21.XY()); -#else - Vect11.XY(); - Vect21.XY(); -#endif - gp_Vec2d TheDirection(Point1,Point2); - Standard_Real squaredir = TheDirection.Dot(TheDirection); - Deriv(1,1) = TheDirection.Crossed(Vect12)/(NormeD11*squaredir)+ - (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect11.Dot(TheDirection))/ - (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); - Deriv(1,2) = Vect21.Crossed(Vect11)/(NormeD11*squaredir)- - (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect21.Dot(TheDirection))/ - (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); - Deriv(2,1)=(Vect12.Crossed(Vect21))/(NormeD11*NormeD21)- - (Vect11.Crossed(Vect21))*(Vect12.Dot(Vect11))*NormeD21*NormeD21/ - (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); - Deriv(2,2)=(Vect11.Crossed(Vect22))/(NormeD11*NormeD21)- - (Vect11.Crossed(Vect21))*(Vect22.Dot(Vect21))*NormeD11*NormeD11/ - (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); - return Standard_True; -} - -Standard_Boolean GccIter_FunctionTanCuCu:: - Values (const math_Vector& X , - math_Vector& Fval , - math_Matrix& Deriv ) { - gp_Pnt2d Point1; - gp_Pnt2d Point2; - gp_Vec2d Vect11; - gp_Vec2d Vect21; - gp_Vec2d Vect12; - gp_Vec2d Vect22; - InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22); - Standard_Real NormeD11 = Vect11.Magnitude(); - Standard_Real NormeD21 = Vect21.Magnitude(); -#ifdef DEB - gp_Vec2d V2V1(Vect11.XY(),Vect21.XY()); -#else - Vect11.XY(); - Vect21.XY(); -#endif - gp_Vec2d TheDirection(Point1,Point2); - Standard_Real squaredir = TheDirection.Dot(TheDirection); - Fval(1) = TheDirection.Crossed(Vect11)/(NormeD11*squaredir); - Fval(2) = Vect11.Crossed(Vect21)/(NormeD11*NormeD21); - Deriv(1,1) = TheDirection.Crossed(Vect12)/(NormeD11*squaredir)+ - (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect11.Dot(TheDirection))/ - (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); - Deriv(1,2) = Vect21.Crossed(Vect11)/(NormeD11*squaredir)- - (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect21.Dot(TheDirection))/ - (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); - Deriv(2,1)=(Vect12.Crossed(Vect21))/(NormeD11*NormeD21)- - (Vect11.Crossed(Vect21))*(Vect12.Dot(Vect11))*NormeD21*NormeD21/ - (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); - Deriv(2,2)=(Vect11.Crossed(Vect22))/(NormeD11*NormeD21)- - (Vect11.Crossed(Vect21))*(Vect22.Dot(Vect21))*NormeD11*NormeD11/ - (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); - return Standard_True; -} diff --git a/src/GccIter/GccIter_FunctionTanCuCuCu.cdl b/src/GccIter/GccIter_FunctionTanCuCuCu.cdl deleted file mode 100644 index 382a7a393f..0000000000 --- a/src/GccIter/GccIter_FunctionTanCuCuCu.cdl +++ /dev/null @@ -1,116 +0,0 @@ --- Created on: 1991-05-13 --- Created by: Laurent PAINNOT --- Copyright (c) 1991-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. - -generic class FunctionTanCuCuCu from GccIter( - TheCurve as any; - TheCurveTool as any) -- as CurvePGTool from GccInt (TheCurve) - -inherits FunctionSetWithDerivatives from math - - ---Purpose: This abstract class describes a set on N Functions of - -- M independant variables. - -uses Vector from math, - Matrix from math, - Circ2d from gp, - Lin2d from gp, - Pnt2d from gp, - Vec2d from gp, - Type1 from GccIter - -raises ConstructionError - -is - - Create (C1 : TheCurve ; - C2 : TheCurve ; - C3 : TheCurve ) returns FunctionTanCuCuCu from GccIter; - - Create (C1 : Circ2d from gp ; - C2 : TheCurve ; - C3 : TheCurve ) returns FunctionTanCuCuCu from GccIter; - - Create (C1 : Circ2d from gp ; - C2 : Circ2d from gp ; - C3 : TheCurve ) returns FunctionTanCuCuCu from GccIter; - - Create (C1 : Circ2d from gp ; - L2 : Lin2d from gp ; - C3 : TheCurve ) returns FunctionTanCuCuCu from GccIter; - - Create (L1 : Lin2d from gp ; - L2 : Lin2d from gp ; - C3 : TheCurve ) returns FunctionTanCuCuCu from GccIter; - - Create (L1 : Lin2d from gp ; - C2 : TheCurve ; - C3 : TheCurve ) returns FunctionTanCuCuCu from GccIter; - - Create (C1 : Circ2d from gp ; - C2 : TheCurve ; - P3 : Pnt2d from gp ) returns FunctionTanCuCuCu from GccIter; - - Create (L1 : Lin2d from gp ; - C2 : TheCurve ; - P3 : Pnt2d from gp ) returns FunctionTanCuCuCu from GccIter; - - Create (C1 : TheCurve ; - P2 : Pnt2d from gp ; - P3 : Pnt2d from gp ) returns FunctionTanCuCuCu from GccIter; - -InitDerivative(me : in out ; - X : Vector from math ; - Point1,Point2,Point3 : out Pnt2d from gp ; - Tan1,Tan2,Tan3,D21,D22,D23 : out Vec2d from gp ) -raises ConstructionError -is static; - - NbVariables(me) returns Integer; - ---Purpose: Returns the number of variables of the function. - - NbEquations(me) returns Integer; - ---Purpose: Returns the number of equations of the function. - - Value(me : in out ; - X : Vector from math; - F : out Vector from math) returns Boolean; - ---Purpose: Computes the values of the Functions for the variable . - - Derivatives(me : in out ; - X : Vector from math; - D : out Matrix from math) returns Boolean; - ---Purpose: Returns the values of the derivatives for the variable . - - Values(me : in out ; - X : Vector from math; - F : out Vector from math; - D : out Matrix from math) returns Boolean; - ---Purpose: Returns the values of the functions and the derivatives - -- for the variable . - -fields - -Curv1 : TheCurve ; -Curv2 : TheCurve ; -Curv3 : TheCurve ; -Circ1 : Circ2d from gp ; -Circ2 : Circ2d from gp ; -Lin1 : Lin2d from gp ; -Lin2 : Lin2d from gp ; -TheType : Type1 from GccIter; - -end FunctionTanCuCuCu; - diff --git a/src/GccIter/GccIter_FunctionTanCuCuCu.gxx b/src/GccIter/GccIter_FunctionTanCuCuCu.gxx deleted file mode 100644 index 230ebe71c0..0000000000 --- a/src/GccIter/GccIter_FunctionTanCuCuCu.gxx +++ /dev/null @@ -1,480 +0,0 @@ -// Created on: 1992-01-20 -// Created by: Remi GILET -// 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. - -#include -#include -#include - -void GccIter_FunctionTanCuCuCu:: - InitDerivative(const math_Vector& X, - gp_Pnt2d& Point1, - gp_Pnt2d& Point2, - gp_Pnt2d& Point3, - gp_Vec2d& Tan1, - gp_Vec2d& Tan2, - gp_Vec2d& Tan3, - gp_Vec2d& D21, - gp_Vec2d& D22, - gp_Vec2d& D23) { - switch (TheType) { - case GccIter_CiCuCu: - { - ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - TheCurveTool::D2(Curv3,X(3),Point3,Tan3,D23); - } - break; - case GccIter_CiCiCu: - { - ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); - ElCLib::D2(X(2),Circ2,Point2,Tan2,D22); - TheCurveTool::D2(Curv3,X(3),Point3,Tan3,D23); - } - break; - case GccIter_CiLiCu: - { - ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); - ElCLib::D1(X(2),Lin2,Point2,Tan2); - D22 = gp_Vec2d(0.,0.); - TheCurveTool::D2(Curv3,X(3),Point3,Tan3,D23); - } - break; - case GccIter_LiCuCu: - { - ElCLib::D1(X(1),Lin1,Point1,Tan1); - D21 = gp_Vec2d(0.,0.); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - TheCurveTool::D2(Curv3,X(3),Point3,Tan3,D23); - } - break; - case GccIter_LiLiCu: - { - ElCLib::D1(X(1),Lin1,Point1,Tan1); - D21 = gp_Vec2d(0.,0.); - ElCLib::D1(X(2),Lin2,Point2,Tan2); - D22 = gp_Vec2d(0.,0.); - TheCurveTool::D2(Curv3,X(3),Point3,Tan3,D23); - } - break; - case GccIter_CuCuCu: - { - TheCurveTool::D2(Curv1,X(1),Point1,Tan1,D21); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - TheCurveTool::D2(Curv3,X(3),Point3,Tan3,D23); - } - break; - default: - { - Standard_ConstructionError::Raise(); - } - } -} - -GccIter_FunctionTanCuCuCu:: - GccIter_FunctionTanCuCuCu(const TheCurve& C1 , - const TheCurve& C2 , - const TheCurve& C3 ) { - Curv1 = C1; - Curv2 = C2; - Curv3 = C3; - TheType = GccIter_CuCuCu; -} - -GccIter_FunctionTanCuCuCu:: - GccIter_FunctionTanCuCuCu(const gp_Circ2d& C1 , - const TheCurve& C2 , - const TheCurve& C3 ) { - Circ1 = C1; - Curv2 = C2; - Curv3 = C3; - TheType = GccIter_CiCuCu; -} - -GccIter_FunctionTanCuCuCu:: - GccIter_FunctionTanCuCuCu(const gp_Circ2d& C1 , - const gp_Circ2d& C2 , - const TheCurve& C3 ) { - Circ1 = C1; - Circ2 = C2; - Curv3 = C3; - TheType = GccIter_CiCiCu; -} - -GccIter_FunctionTanCuCuCu:: - GccIter_FunctionTanCuCuCu(const gp_Circ2d& C1 , - const gp_Lin2d& L2 , - const TheCurve& C3 ) { - Circ1 = C1; - Lin2 = L2; - Curv3 = C3; - TheType = GccIter_CiLiCu; -} - -GccIter_FunctionTanCuCuCu:: - GccIter_FunctionTanCuCuCu(const gp_Lin2d& L1 , - const gp_Lin2d& L2 , - const TheCurve& C3 ) { - Lin1 = L1; - Lin2 = L2; - Curv3 = C3; - TheType = GccIter_LiLiCu; -} - -GccIter_FunctionTanCuCuCu:: - GccIter_FunctionTanCuCuCu(const gp_Lin2d& L1 , - const TheCurve& C2 , - const TheCurve& C3 ) { - Lin1 = L1; - Curv2 = C2; - Curv3 = C3; - TheType = GccIter_LiCuCu; -} - -//========================================================================== - -Standard_Integer GccIter_FunctionTanCuCuCu:: - NbVariables () const { return 3; } - -Standard_Integer GccIter_FunctionTanCuCuCu:: - NbEquations () const { return 3; } - -Standard_Boolean GccIter_FunctionTanCuCuCu:: - Value (const math_Vector& X , - math_Vector& Fval ) { - gp_Pnt2d Point1; - gp_Pnt2d Point2; - gp_Pnt2d Point3; - gp_Vec2d Tan1; - gp_Vec2d Tan2; - gp_Vec2d Tan3; - gp_Vec2d D21; - gp_Vec2d D22; - gp_Vec2d D23; - InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); -//pipj (normes) et PiPj (non Normes). - gp_XY P1P2(gp_Vec2d(Point1,Point2).XY()); - gp_XY P2P3(gp_Vec2d(Point2,Point3).XY()); - gp_XY P3P1(gp_Vec2d(Point3,Point1).XY()); - Standard_Real NorP1P2 = P1P2.Modulus(); - Standard_Real NorP2P3 = P2P3.Modulus(); - Standard_Real NorP3P1 = P3P1.Modulus(); - gp_XY p1p2,p2p3,p3p1; - if (NorP1P2 >= gp::Resolution()) { p1p2 = P1P2/NorP1P2; } - else { p1p2 = gp_XY(0.,0.); } - if (NorP2P3 >= gp::Resolution()) { p2p3 = P2P3/NorP2P3; } - else { p2p3 = gp_XY(0.,0.); } - if (NorP3P1 >= gp::Resolution()) { p3p1 = P3P1/NorP3P1; } - else { p3p1 = gp_XY(0.,0.); } -//derivees premieres non normees Deriv1ui. - gp_XY Deriv1u1(Tan1.XY()); - gp_XY Deriv1u2(Tan2.XY()); - gp_XY Deriv1u3(Tan3.XY()); -//normales aux courbes. - Standard_Real nnor1 = Deriv1u1.Modulus(); - Standard_Real nnor2 = Deriv1u2.Modulus(); - Standard_Real nnor3 = Deriv1u3.Modulus(); - gp_XY Nor1(-Deriv1u1.Y(),Deriv1u1.X()); - gp_XY Nor2(-Deriv1u2.Y(),Deriv1u2.X()); - gp_XY Nor3(-Deriv1u3.Y(),Deriv1u3.X()); - gp_XY nor1,nor2,nor3; - if (nnor1 >= gp::Resolution()) { nor1 = Nor1/nnor1; } - else { nor1 = gp_XY(0.,0.); } - if (nnor2 >= gp::Resolution()) { nor2 = Nor2/nnor2; } - else { nor2 = gp_XY(0.,0.); } - if (nnor3 >= gp::Resolution()) { nor3 = Nor3/nnor3; } - else { nor3 = gp_XY(0.,0.); } -//determination des signes pour les produits scalaires. - Standard_Real signe1 = 1.; - Standard_Real signe2 = 1.; - Standard_Real signe3 = 1.; - gp_Pnt2d Pcenter(gp_XY(Point1.XY()+Point2.XY()+Point3.XY())/3.); - gp_XY fic1(Pcenter.XY()-Point1.XY()); - gp_XY fic2(Pcenter.XY()-Point2.XY()); - gp_XY fic3(Pcenter.XY()-Point3.XY()); - Standard_Real pscal11 = nor1.Dot(fic1); - Standard_Real pscal22 = nor2.Dot(fic2); - Standard_Real pscal33 = nor3.Dot(fic3); - if (pscal11 <= 0.) { signe1 = -1; } - if (pscal22 <= 0.) { signe2 = -1; } - if (pscal33 <= 0.) { signe3 = -1; } -// Fonctions Fui. -// ============== - Fval(1) = signe1*nor1.Dot(p1p2)+signe2*nor2.Dot(p1p2); - Fval(2) = signe2*nor2.Dot(p2p3)+signe3*nor3.Dot(p2p3); - Fval(3) = signe3*nor3.Dot(p3p1)+signe1*nor1.Dot(p3p1); - return Standard_True; -} - - - -Standard_Boolean GccIter_FunctionTanCuCuCu::Derivatives (const math_Vector&, - math_Matrix&) -{ -#if 0 - gp_Pnt2d Point1; - gp_Pnt2d Point2; - gp_Pnt2d Point3; - gp_Vec2d Tan1; - gp_Vec2d Tan2; - gp_Vec2d Tan3; - gp_Vec2d D21; - gp_Vec2d D22; - gp_Vec2d D23; - InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); -//derivees premieres non normees Deriv1ui. - gp_XY Deriv1u1(Tan1.XY()); - gp_XY Deriv1u2(Tan2.XY()); - gp_XY Deriv1u3(Tan3.XY()); -//pipj (normes) et PiPj (non Normes). - gp_XY P1P2(gp_Vec2d(Point1,Point2).XY()); - gp_XY P2P3(gp_Vec2d(Point2,Point3).XY()); - gp_XY P3P1(gp_Vec2d(Point3,Point1).XY()); - Standard_Real NorP1P2 = P1P2.Modulus(); - Standard_Real NorP2P3 = P2P3.Modulus(); - Standard_Real NorP3P1 = P3P1.Modulus(); - gp_XY p1p2,p2p3,p3p1; - if (NorP1P2 >= gp::Resolution()) { p1p2 = P1P2/NorP1P2; } - else { p1p2 = gp_XY(0.,0.); } - if (NorP2P3 >= gp::Resolution()) { p2p3 = P2P3/NorP2P3; } - else { p2p3 = gp_XY(0.,0.); } - if (NorP3P1 >= gp::Resolution()) { p3p1 = P3P1/NorP3P1; } - else { p3p1 = gp_XY(0.,0.); } -//normales au courbes normees Nori et non nromees nori et norme des nori. - Standard_Real nnor1 = Deriv1u1.Modulus(); - Standard_Real nnor2 = Deriv1u2.Modulus(); - Standard_Real nnor3 = Deriv1u3.Modulus(); - gp_XY Nor1(-Deriv1u1.Y(),Deriv1u1.X()); - gp_XY Nor2(-Deriv1u2.Y(),Deriv1u2.X()); - gp_XY Nor3(-Deriv1u3.Y(),Deriv1u3.X()); - gp_XY nor1,nor2,nor3; - if (nnor1 >= gp::Resolution()) { nor1 = Nor1/nnor1; } - else { nor1 = gp_XY(0.,0.); } - if (nnor2 >= gp::Resolution()) { nor2 = Nor2/nnor2; } - else { nor2 = gp_XY(0.,0.); } - if (nnor3 >= gp::Resolution()) { nor3 = Nor3/nnor3; } - else { nor3 = gp_XY(0.,0.); } -//derivees des normales. - gp_XY NorD21,NorD22,NorD23; - NorD21 = gp_XY(-D21.Y(),D21.X()); - NorD22 = gp_XY(-D22.Y(),D22.X()); - NorD23 = gp_XY(-D23.Y(),D23.X()); -//determination des signes pour les produits scalaires. - Standard_Real signe1 = 1.; - Standard_Real signe2 = 1.; - Standard_Real signe3 = 1.; - gp_XY P = Point1.XY(); - P += Point2.XY(); - P += Point3.XY(); - P /= 3.; - gp_Pnt2d Pcenter(P); - gp_XY fic1 = Pcenter.XY(); - fic1 -= Point1.XY(); - gp_XY fic2 = Pcenter.XY(); - fic2 -= Point2.XY(); - gp_XY fic3 = Pcenter.XY(); - fic3 -= Point3.XY(); - Standard_Real pscal11 = nor1.Dot(fic1); - Standard_Real pscal22 = nor2.Dot(fic2); - Standard_Real pscal33 = nor3.Dot(fic3); - if (pscal11 <= 0.) { signe1 = -1; } - if (pscal22 <= 0.) { signe2 = -1; } - if (pscal33 <= 0.) { signe3 = -1; } - -// Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3 -// ============================================= - Standard_Real partie1,partie2; - if (nnor1 <= gp::Resolution()) { partie1 = 0.; } - else { partie1 = (signe1*NorD21/nnor1-(Nor1.Dot(NorD21)/(nnor1*nnor1*nnor1)) - *Nor1).Dot(p1p2); } - if (NorP1P2 <= gp::Resolution()) { partie2 = 0.; } - else {partie2=((Deriv1u1.Dot(p1p2)/(NorP1P2*NorP1P2))*P1P2-Deriv1u1/NorP1P2) - .Dot(signe1*nor1+signe2*nor2); } - Deriv(1,1) = partie1 + partie2; - if (nnor2 <= gp::Resolution()) { partie1 = 0.; } - else { partie1=(signe2*NorD22/(nnor2)-(Nor2.Dot(NorD22)/(nnor2*nnor2*nnor2)) - *Nor2).Dot(p1p2); } - if (NorP1P2 <= gp::Resolution()) { partie2 = 0.; } - else{partie2=((-Deriv1u2.Dot(p1p2)/(NorP1P2*NorP1P2))*P1P2+Deriv1u2/NorP1P2) - .Dot(signe1*nor1+signe2*nor2); } - Deriv(1,2) = partie1 + partie2; - Deriv(1,3) = 0.; - Deriv(2,1) = 0.; - if (nnor2 <= gp::Resolution()) { partie1 = 0.; } - else { partie1=(signe2*NorD22/(nnor2)-(Nor2.Dot(NorD22)/(nnor2*nnor2*nnor2)) - *Nor2).Dot(p2p3); } - if (NorP2P3 <= gp::Resolution()) { partie2 = 0.; } - else { partie2=((Deriv1u2.Dot(p2p3)/(NorP2P3*NorP2P3))*P2P3-Deriv1u2/NorP2P3) - .Dot(signe2*nor2+signe3*nor3); } - Deriv(2,2) = partie1 +partie2; - if (nnor3 <= gp::Resolution()) { partie1 = 0.; } - else { partie1=(signe3*NorD23/(nnor3)-(Nor3.Dot(NorD23)/(nnor3*nnor3*nnor3)) - *Nor3).Dot(p2p3); } - if (NorP2P3 <= gp::Resolution()) { partie2 = 0.; } - else {partie2=((-Deriv1u3.Dot(p2p3)/(NorP2P3*NorP2P3))*P2P3+Deriv1u3/NorP2P3) - .Dot(signe2*nor2+signe3*nor3); } - Deriv(2,3) = partie1 + partie2; - if (nnor1 <= gp::Resolution()) { partie1 = 0.; } - else { partie1 =(signe1*NorD21/(nnor1)-(Nor1.Dot(NorD21)/(nnor1*nnor1*nnor1)) - *Nor1).Dot(p3p1); } - if (NorP3P1 <= gp::Resolution()) { partie2 = 0.; } - else {partie2=((-Deriv1u1.Dot(p3p1)/(NorP3P1*NorP3P1))*P3P1+Deriv1u1/NorP3P1) - .Dot(signe1*nor1+signe3*nor3); } - Deriv(3,1) = partie1 + partie2; - Deriv(3,2) = 0.; - if (nnor3 <= gp::Resolution()) { partie1 = 0.; } - else { partie1=(signe3*NorD23/(nnor3)-(Nor3.Dot(NorD23)/(nnor3*nnor3*nnor3)) - *Nor3).Dot(p3p1); } - if (NorP3P1 <= gp::Resolution()) { partie2 = 0.; } - else {partie2=((Deriv1u3.Dot(p3p1)/(NorP3P1*NorP3P1))*P3P1-Deriv1u3/NorP3P1) - .Dot(signe1*nor1+signe3*nor3); } - Deriv(3,3) = partie1+partie2; -#endif - return Standard_True; -} - - -Standard_Boolean GccIter_FunctionTanCuCuCu:: Values (const math_Vector&, - math_Vector&, - math_Matrix& ) -{ -#if 0 - gp_Pnt2d Point1; - gp_Pnt2d Point2; - gp_Pnt2d Point3; - gp_Vec2d Tan1; - gp_Vec2d Tan2; - gp_Vec2d Tan3; - gp_Vec2d D21; - gp_Vec2d D22; - gp_Vec2d D23; - InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); -//derivees premieres non normees Deriv1ui. - gp_XY Deriv1u1(Tan1.XY()); - gp_XY Deriv1u2(Tan2.XY()); - gp_XY Deriv1u3(Tan3.XY()); -//pipj (normes) et PiPj (non Normes). - gp_XY P1P2(gp_Vec2d(Point1,Point2).XY()); - gp_XY P2P3(gp_Vec2d(Point2,Point3).XY()); - gp_XY P3P1(gp_Vec2d(Point3,Point1).XY()); - Standard_Real NorP1P2 = P1P2.Modulus(); - Standard_Real NorP2P3 = P2P3.Modulus(); - Standard_Real NorP3P1 = P3P1.Modulus(); - gp_XY p1p2,p2p3,p3p1; - if (NorP1P2 >= gp::Resolution()) { p1p2 = P1P2/NorP1P2; } - else { p1p2 = gp_XY(0.,0.); } - if (NorP2P3 >= gp::Resolution()) { p2p3 = P2P3/NorP2P3; } - else { p2p3 = gp_XY(0.,0.); } - if (NorP3P1 >= gp::Resolution()) { p3p1 = P3P1/NorP3P1; } - else { p3p1 = gp_XY(0.,0.); } -//normales au courbes normees Nori et non nromees nori et norme des nori. - Standard_Real nnor1 = Deriv1u1.Modulus(); - Standard_Real nnor2 = Deriv1u2.Modulus(); - Standard_Real nnor3 = Deriv1u3.Modulus(); - gp_XY Nor1(-Deriv1u1.Y(),Deriv1u1.X()); - gp_XY Nor2(-Deriv1u2.Y(),Deriv1u2.X()); - gp_XY Nor3(-Deriv1u3.Y(),Deriv1u3.X()); - gp_XY nor1,nor2,nor3; - if (nnor1 >= gp::Resolution()) { nor1 = Nor1/nnor1; } - else { nor1 = gp_XY(0.,0.); } - if (nnor2 >= gp::Resolution()) { nor2 = Nor2/nnor2; } - else { nor2 = gp_XY(0.,0.); } - if (nnor3 >= gp::Resolution()) { nor3 = Nor3/nnor3; } - else { nor3 = gp_XY(0.,0.); } -//derivees des normales. - gp_XY NorD21,NorD22,NorD23; - NorD21 = gp_XY(-D21.Y(),D21.X()); - NorD22 = gp_XY(-D22.Y(),D22.X()); - NorD23 = gp_XY(-D23.Y(),D23.X()); -//determination des signes pour les produits scalaires. - Standard_Real signe1 = 1.; - Standard_Real signe2 = 1.; - Standard_Real signe3 = 1.; - gp_XY P = Point1.XY(); - P += Point2.XY(); - P += Point3.XY(); - P /= 3.; - gp_Pnt2d Pcenter(P); - gp_XY fic1 = Pcenter.XY(); - fic1 -= Point1.XY(); - gp_XY fic2 = Pcenter.XY(); - fic2 -= Point2.XY(); - gp_XY fic3 = Pcenter.XY(); - fic3 -= Point3.XY(); - Standard_Real pscal11 = nor1.Dot(fic1); - Standard_Real pscal22 = nor2.Dot(fic2); - Standard_Real pscal33 = nor3.Dot(fic3); - if (pscal11 <= 0.) { signe1 = -1; } - if (pscal22 <= 0.) { signe2 = -1; } - if (pscal33 <= 0.) { signe3 = -1; } - -// Fonctions Fui. -// ============== - Fval(1) = signe1*nor1.Dot(p1p2)+signe2*nor2.Dot(p1p2); - Fval(2) = signe2*nor2.Dot(p2p3)+signe3*nor3.Dot(p2p3); - Fval(3) = signe3*nor3.Dot(p3p1)+signe1*nor1.Dot(p3p1); -// Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3 -// ============================================= - Standard_Real partie1,partie2; - if (nnor1 <= gp::Resolution()) { partie1 = 0.; } - else { partie1 = signe1*(NorD21/nnor1-(Nor1.Dot(NorD21)/(nnor1*nnor1*nnor1)) - *Nor1).Dot(p1p2); } - if (NorP1P2 <= gp::Resolution()) { partie2 = 0.; } - else {partie2=((Deriv1u1.Dot(p1p2)/(NorP1P2*NorP1P2))*P1P2-Deriv1u1/NorP1P2) - .Dot(signe1*nor1+signe2*nor2); } - Deriv(1,1) = partie1 + partie2; - if (nnor2 <= gp::Resolution()) { partie1 = 0.; } - else { partie1=signe2*(NorD22/(nnor2)-(Nor2.Dot(NorD22)/(nnor2*nnor2*nnor2)) - *Nor2).Dot(p1p2); } - if (NorP1P2 <= gp::Resolution()) { partie2 = 0.; } - else{partie2=((-Deriv1u2.Dot(p1p2)/(NorP1P2*NorP1P2))*P1P2+Deriv1u2/NorP1P2) - .Dot(signe1*nor1+signe2*nor2); } - Deriv(1,2) = partie1 + partie2; - Deriv(1,3) = 0.; - Deriv(2,1) = 0.; - if (nnor2 <= gp::Resolution()) { partie1 = 0.; } - else { partie1=signe2*(NorD22/(nnor2)-(Nor2.Dot(NorD22)/(nnor2*nnor2*nnor2)) - *Nor2).Dot(p2p3); } - if (NorP2P3 <= gp::Resolution()) { partie2 = 0.; } - else { partie2=((Deriv1u2.Dot(p2p3)/(NorP2P3*NorP2P3))*P2P3-Deriv1u2/NorP2P3) - .Dot(signe2*nor2+signe3*nor3); } - Deriv(2,2) = partie1 +partie2; - if (nnor3 <= gp::Resolution()) { partie1 = 0.; } - else { partie1=signe3*(NorD23/(nnor3)-(Nor3.Dot(NorD23)/(nnor3*nnor3*nnor3)) - *Nor3).Dot(p2p3); } - if (NorP2P3 <= gp::Resolution()) { partie2 = 0.; } - else {partie2=((-Deriv1u3.Dot(p2p3)/(NorP2P3*NorP2P3))*P2P3+Deriv1u3/NorP2P3) - .Dot(signe2*nor2+signe3*nor3); } - Deriv(2,3) = partie1 + partie2; - if (nnor1 <= gp::Resolution()) { partie1 = 0.; } - else { partie1 =signe1*(NorD21/(nnor1)-(Nor1.Dot(NorD21)/(nnor1*nnor1*nnor1)) - *Nor1).Dot(p3p1); } - if (NorP3P1 <= gp::Resolution()) { partie2 = 0.; } - else {partie2=((-Deriv1u1.Dot(p3p1)/(NorP3P1*NorP3P1))*P3P1+Deriv1u1/NorP3P1) - .Dot(signe1*nor1+signe3*nor3); } - Deriv(3,1) = partie1 + partie2; - Deriv(3,2) = 0.; - if (nnor3 <= gp::Resolution()) { partie1 = 0.; } - else { partie1=signe3*(NorD23/(nnor3)-(Nor3.Dot(NorD23)/(nnor3*nnor3*nnor3)) - *Nor3).Dot(p3p1); } - if (NorP3P1 <= gp::Resolution()) { partie2 = 0.; } - else {partie2=((Deriv1u3.Dot(p3p1)/(NorP3P1*NorP3P1))*P3P1-Deriv1u3/NorP3P1) - .Dot(signe1*nor1+signe3*nor3); } - Deriv(3,3) = partie1+partie2; -#endif - return Standard_True; -} - - diff --git a/src/GccIter/GccIter_FunctionTanCuCuOnCu.cdl b/src/GccIter/GccIter_FunctionTanCuCuOnCu.cdl deleted file mode 100644 index 78506ce2dd..0000000000 --- a/src/GccIter/GccIter_FunctionTanCuCuOnCu.cdl +++ /dev/null @@ -1,158 +0,0 @@ --- Created on: 1991-05-13 --- Created by: Laurent PAINNOT --- Copyright (c) 1991-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. - -generic class FunctionTanCuCuOnCu from GccIter ( - TheCurve as any; - TheCurveTool as any) -- as CurvePGTool from GccInt (TheCurve) - -inherits FunctionSetWithDerivatives from math - - ---Purpose: This abstract class describes a set on N Functions of - -- M independant variables. - -uses Vector from math, - Matrix from math, - Circ2d from gp, - Lin2d from gp, - Pnt2d from gp, - Vec2d from gp, - Type2 from GccIter - -raises ConstructionError - -is - - Create (C1 : TheCurve ; - C2 : TheCurve ; - OnCi : Circ2d from gp ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - - Create (C1 : Circ2d from gp ; - C2 : TheCurve ; - OnCi : Circ2d from gp ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - - Create (L1 : Lin2d from gp ; - C2 : TheCurve ; - OnCi : Circ2d from gp ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - - Create (C1 : TheCurve ; - P2 : Pnt2d from gp ; - OnCi : Circ2d from gp ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - ------------------------------------------------------------------------- - - Create (C1 : TheCurve ; - C2 : TheCurve ; - OnLi : Lin2d from gp ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - - Create (C1 : Circ2d from gp ; - C2 : TheCurve ; - OnLi : Lin2d from gp ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - - Create (L1 : Lin2d from gp ; - C2 : TheCurve ; - OnLi : Lin2d from gp ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - - Create (C1 : TheCurve ; - P2 : Pnt2d from gp ; - OnLi : Lin2d from gp ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - ------------------------------------------------------------------------ - - Create (C1 : TheCurve ; - C2 : TheCurve ; - OnCu : TheCurve ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - - Create (C1 : Circ2d from gp ; - C2 : TheCurve ; - OnCu : TheCurve ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - - Create (L1 : Lin2d from gp ; - C2 : TheCurve ; - OnCu : TheCurve ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - - Create (C1 : TheCurve ; - P1 : Pnt2d from gp ; - OnCu : TheCurve ; - Rad : Real from Standard ) -returns FunctionTanCuCuOnCu from GccIter; - -InitDerivative(me : in out ; - X : Vector from math ; - Point1,Point2,Point3 : out Pnt2d from gp ; - Tan1,Tan2,Tan3,D21,D22,D23 : out Vec2d from gp ) -raises ConstructionError -is static; - - NbVariables(me) returns Integer; - ---Purpose: Returns the number of variables of the function. - - NbEquations(me) returns Integer; - ---Purpose: Returns the number of equations of the function. - - Value(me : in out ; - X : Vector from math; - F : out Vector from math) returns Boolean; - ---Purpose: Computes the values of the Functions for the variable . - - Derivatives(me : in out ; - X : Vector from math; - D : out Matrix from math) returns Boolean; - ---Purpose: Returns the values of the derivatives for the variable . - - Values(me : in out ; - X : Vector from math; - F : out Vector from math; - D : out Matrix from math) returns Boolean; - ---Purpose: Returns the values of the functions and the derivatives - -- for the variable . - -fields - -Curv1 : TheCurve ; -Curv2 : TheCurve ; -Circ1 : Circ2d from gp ; -Lin1 : Lin2d from gp ; -Pnt2 : Pnt2d from gp ; -Circon : Circ2d from gp ; -Linon : Lin2d from gp ; -Curvon : TheCurve ; -FirstRad : Real from Standard ; -TheType : Type2 from GccIter ; - -end FunctionTanCuCuOnCu; - diff --git a/src/GccIter/GccIter_FunctionTanCuCuOnCu.gxx b/src/GccIter/GccIter_FunctionTanCuCuOnCu.gxx deleted file mode 100644 index 5c05f57e6e..0000000000 --- a/src/GccIter/GccIter_FunctionTanCuCuOnCu.gxx +++ /dev/null @@ -1,409 +0,0 @@ -// Created on: 1992-01-20 -// Created by: Remi GILET -// 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. - -#include -#include - -void GccIter_FunctionTanCuCuOnCu:: - InitDerivative(const math_Vector& X, - gp_Pnt2d& Point1, - gp_Pnt2d& Point2, - gp_Pnt2d& Point3, - gp_Vec2d& Tan1, - gp_Vec2d& Tan2, - gp_Vec2d& Tan3, - gp_Vec2d& D21, - gp_Vec2d& D22, - gp_Vec2d& D23) { - switch (TheType) { - case GccIter_CuCuOnCu: - { - TheCurveTool::D2(Curv1,X(1),Point1,Tan1,D21); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - TheCurveTool::D2(Curvon,X(3),Point3,Tan3,D23); - } - break; - case GccIter_CiCuOnCu: - { - ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - TheCurveTool::D2(Curvon,X(3),Point3,Tan3,D23); - } - break; - case GccIter_LiCuOnCu: - { - ElCLib::D1(X(1),Lin1,Point1,Tan1); - D21 = gp_Vec2d(0.,0.); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - TheCurveTool::D2(Curvon,X(3),Point3,Tan3,D23); - } - break; - case GccIter_CuPtOnCu: - { - TheCurveTool::D2(Curv1,X(1),Point1,Tan1,D21); - TheCurveTool::D2(Curvon,X(3),Point3,Tan3,D23); - Point2 = Pnt2; - Tan2 = gp_Vec2d(0.,0.); - D22 = gp_Vec2d(0.,0.); - } - break; - case GccIter_CuCuOnCi: - { - TheCurveTool::D2(Curv1,X(1),Point1,Tan1,D21); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - ElCLib::D2(X(3),Circon,Point3,Tan3,D23); - } - break; - case GccIter_CiCuOnCi: - { - ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - ElCLib::D2(X(3),Circon,Point3,Tan3,D23); - } - break; - case GccIter_LiCuOnCi: - { - ElCLib::D1(X(1),Lin1,Point1,Tan1); - D21 = gp_Vec2d(0.,0.); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - ElCLib::D2(X(3),Circon,Point3,Tan3,D23); - } - break; - case GccIter_CuPtOnCi: - { - TheCurveTool::D2(Curv1,X(1),Point1,Tan1,D21); - Point2 = Pnt2; - Tan2 = gp_Vec2d(0.,0.); - D22 = gp_Vec2d(0.,0.); - ElCLib::D2(X(3),Circon,Point3,Tan3,D23); - } - break; - case GccIter_CuCuOnLi: - { - TheCurveTool::D2(Curv1,X(1),Point1,Tan1,D21); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - ElCLib::D1(X(3),Linon,Point3,Tan3); - D23 = gp_Vec2d(0.,0.); - } - break; - case GccIter_CiCuOnLi: - { - ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - ElCLib::D1(X(3),Linon,Point3,Tan3); - D23 = gp_Vec2d(0.,0.); - } - break; - case GccIter_LiCuOnLi: - { - ElCLib::D1(X(1),Lin1,Point1,Tan1); - TheCurveTool::D2(Curv2,X(2),Point2,Tan2,D22); - D21 = gp_Vec2d(0.,0.); - ElCLib::D1(X(3),Linon,Point3,Tan3); - D23 = gp_Vec2d(0.,0.); - } - break; - case GccIter_CuPtOnLi: - { - TheCurveTool::D2(Curv1,X(1),Point1,Tan1,D21); - Point2 = Pnt2; - Tan2 = gp_Vec2d(0.,0.); - D22 = gp_Vec2d(0.,0.); - ElCLib::D1(X(3),Linon,Point3,Tan3); - D23 = gp_Vec2d(0.,0.); - } - break; - default: - { - Standard_ConstructionError::Raise(); - } - } -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const TheCurve& C1 , - const TheCurve& C2 , - const TheCurve& C3 , - const Standard_Real Rad ) { - Curv1 = C1; - Curv2 = C2; - Curvon = C3; - FirstRad = Rad; - TheType = GccIter_CuCuOnCu; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const gp_Circ2d& C1 , - const TheCurve& C2 , - const TheCurve& C3 , - const Standard_Real Rad ) { - Circ1 = C1; - Curv2 = C2; - Curvon = C3; - FirstRad = Rad; - TheType = GccIter_CiCuOnCu; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const gp_Lin2d& L1 , - const TheCurve& C2 , - const TheCurve& C3 , - const Standard_Real Rad ) { - Lin1 = L1; - Curv2 = C2; - Curvon = C3; - FirstRad = Rad; - TheType = GccIter_LiCuOnCu; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const TheCurve& C1 , - const gp_Pnt2d& P2 , - const TheCurve& C3 , - const Standard_Real Rad ) { - Curv1 = C1; - Pnt2 = P2; - Curvon = C3; - FirstRad = Rad; - TheType = GccIter_CuPtOnCu; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const TheCurve& C1 , - const TheCurve& C2 , - const gp_Lin2d& OnLi , - const Standard_Real Rad ) { - Curv1 = C1; - Curv2 = C2; - Linon = OnLi; - FirstRad = Rad; - TheType = GccIter_CuCuOnLi; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const gp_Circ2d& C1 , - const TheCurve& C2 , - const gp_Lin2d& OnLi , - const Standard_Real Rad ) { - Circ1 = C1; - Curv2 = C2; - Linon = OnLi; - FirstRad = Rad; - TheType = GccIter_CiCuOnLi; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const gp_Lin2d& L1 , - const TheCurve& C2 , - const gp_Lin2d& OnLi , - const Standard_Real Rad ) { - Lin1 = L1; - Curv2 = C2; - Linon = OnLi; - FirstRad = Rad; - TheType = GccIter_LiCuOnLi; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const TheCurve& C1 , - const gp_Pnt2d& P2 , - const gp_Lin2d& OnLi , - const Standard_Real Rad ) { - Curv1 = C1; - Pnt2 = P2; - Linon = OnLi; - FirstRad = Rad; - TheType = GccIter_CuPtOnLi; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const TheCurve& C1 , - const TheCurve& C2 , - const gp_Circ2d& OnCi , - const Standard_Real Rad ) { - Curv1 = C1; - Curv2 = C2; - Circon = OnCi; - FirstRad = Rad; - TheType = GccIter_CuCuOnCi; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const gp_Circ2d& C1 , - const TheCurve& C2 , - const gp_Circ2d& OnCi , - const Standard_Real Rad ) { - Circ1 = C1; - Curv2 = C2; - Circon = OnCi; - FirstRad = Rad; - TheType = GccIter_CuCuOnCi; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const gp_Lin2d& L1 , - const TheCurve& C2 , - const gp_Circ2d& OnCi , - const Standard_Real Rad ) { - Lin1 = L1; - Curv2 = C2; - Circon = OnCi; - FirstRad = Rad; - TheType = GccIter_LiCuOnCi; -} - -GccIter_FunctionTanCuCuOnCu:: - GccIter_FunctionTanCuCuOnCu(const TheCurve& C1 , - const gp_Pnt2d& P2 , - const gp_Circ2d& OnCi , - const Standard_Real Rad ) { - Curv1 = C1; - Pnt2 = P2; - Circon = OnCi; - FirstRad = Rad; - TheType = GccIter_CuPtOnCi; -} - -Standard_Integer GccIter_FunctionTanCuCuOnCu:: - NbVariables () const { return 4; } - -Standard_Integer GccIter_FunctionTanCuCuOnCu:: - NbEquations () const { return 4; } - -Standard_Boolean GccIter_FunctionTanCuCuOnCu:: - Value (const math_Vector& X , - math_Vector& Fval ) { - gp_Pnt2d Point1,Point2,Point3; - gp_Vec2d Tan1,Tan2,Tan3,D21,D22,D23; - InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); -//pipj (normes) et PiPj (non Normes). - gp_Vec2d P1P2(Point1,Point2); - gp_Vec2d P2P3(Point2,Point3); - gp_Vec2d P3P1(Point3,Point1); - gp_Vec2d p1p2,p2p3,p3p1; -// if (FirstRad < 1.) {FirstRad = 1.; } - p1p2 = P1P2/FirstRad; - p2p3 = P2P3/FirstRad; - p3p1 = P3P1/FirstRad; -//norme des Tani. - Standard_Real nnor1 = Tan1.Magnitude(); - Standard_Real nnor2 = Tan2.Magnitude(); -// Fonctions Fui. -// ============== - Fval(1) = (P3P1.Dot(P3P1)-X(4)*X(4))/(FirstRad*FirstRad); - Fval(2) = (P2P3.Dot(P2P3)-X(4)*X(4))/(FirstRad*FirstRad); - Fval(3) = P3P1.Dot(Tan1)/(nnor1*FirstRad); - Fval(4) = P2P3.Dot(Tan2)/(nnor2*FirstRad); - return Standard_True; -} - -Standard_Boolean GccIter_FunctionTanCuCuOnCu:: - Derivatives (const math_Vector& X , - math_Matrix& Deriv ) { - gp_Pnt2d Point1,Point2,Point3; - gp_Vec2d Tan1,Tan2,Tan3; - gp_Vec2d D21,D22,D23; - InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); -//pipj (normes) et PiPj (non Normes). - gp_Vec2d P1P2(Point1,Point2); - gp_Vec2d P2P3(Point2,Point3); - gp_Vec2d P3P1(Point3,Point1); - gp_Vec2d p1p2,p2p3,p3p1; -// if (FirstRad < 1.) {FirstRad = 1.; } - p1p2 = P1P2/FirstRad; - p2p3 = P2P3/FirstRad; - p3p1 = P3P1/FirstRad; -//normales au courbes normees Nori et non nromees nori et norme des nori. - Standard_Real nnor1 = Tan1.Magnitude(); - Standard_Real nnor2 = Tan2.Magnitude(); -// Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3 -// ============================================= - Deriv(1,1) = 2.*Tan1.Dot(P3P1)/(FirstRad*FirstRad); - Deriv(1,2) = 0.; - Deriv(1,3) = -2.*Tan3.Dot(P3P1)/(FirstRad*FirstRad); - Deriv(1,4) = -2.*X(4)/(FirstRad*FirstRad); - - Deriv(2,1) = 0.; - Deriv(2,2) = -2.*Tan2.Dot(P2P3)/(FirstRad*FirstRad); - Deriv(2,3) = 2.*Tan3.Dot(P2P3)/(FirstRad*FirstRad); - Deriv(2,4) = -2.*X(4)/(FirstRad*FirstRad); - - Deriv(3,1) = (P3P1.Dot(D21)+Tan1.Dot(Tan1))/(FirstRad*nnor1)- - (P3P1.Dot(Tan1)*D21.Dot(Tan1))/(FirstRad*nnor1*nnor1*nnor1); - Deriv(3,2) = 0.; - Deriv(3,3) = -(Tan3.Dot(Tan1))/(FirstRad*nnor1); - Deriv(3,4) = 0.; - - Deriv(4,1) = 0.; - Deriv(4,2) = (P2P3.Dot(D22)-Tan2.Dot(Tan2))/(FirstRad*nnor2)- - P2P3.Dot(Tan2)*Tan2.Dot(D22)/(FirstRad*nnor2*nnor2*nnor2); - Deriv(4,3) = Tan3.Dot(Tan2)/(FirstRad*nnor1); - Deriv(4,4) = 0.; - return Standard_True; -} - -Standard_Boolean GccIter_FunctionTanCuCuOnCu:: - Values (const math_Vector& X , - math_Vector& Fval , - math_Matrix& Deriv ) { - gp_Pnt2d Point1,Point2,Point3; - gp_Vec2d Tan1,Tan2,Tan3; - gp_Vec2d D21,D22,D23; - InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); -//pipj (normes) et PiPj (non Normes). - gp_Vec2d P1P2(Point1,Point2); - gp_Vec2d P2P3(Point2,Point3); - gp_Vec2d P3P1(Point3,Point1); - gp_Vec2d p1p2,p2p3,p3p1; -// if (FirstRad < 1.) {FirstRad = 1.; } - p1p2 = P1P2/FirstRad; - p2p3 = P2P3/FirstRad; - p3p1 = P3P1/FirstRad; -//normales au courbes normees Nori et non nromees nori et norme des nori. - Standard_Real nnor1 = Tan1.Magnitude(); - Standard_Real nnor2 = Tan2.Magnitude(); -// Fonctions Fui. -// ============== - Fval(1) = (P3P1.Dot(P3P1)-X(4)*X(4))/(FirstRad*FirstRad); - Fval(2) = (P2P3.Dot(P2P3)-X(4)*X(4))/(FirstRad*FirstRad); - Fval(3) = P3P1.Dot(Tan1)/(nnor1*FirstRad); - Fval(4) = P2P3.Dot(Tan2)/(nnor2*FirstRad); -// Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3 -// ============================================= - Deriv(1,1) = 2.*Tan1.Dot(P3P1)/(FirstRad*FirstRad); - Deriv(1,2) = 0.; - Deriv(1,3) = -2.*Tan3.Dot(P3P1)/(FirstRad*FirstRad); - Deriv(1,4) = -2.*X(4)/(FirstRad*FirstRad); - - Deriv(2,1) = 0.; - Deriv(2,2) = -2.*Tan2.Dot(P2P3)/(FirstRad*FirstRad); - Deriv(2,3) = 2.*Tan3.Dot(P2P3)/(FirstRad*FirstRad); - Deriv(2,4) = -2.*X(4)/(FirstRad*FirstRad); - - Deriv(3,1) = (P3P1.Dot(D21)+Tan1.Dot(Tan1))/(FirstRad*nnor1)- - (P3P1.Dot(Tan1)*D21.Dot(Tan1))/(FirstRad*nnor1*nnor1*nnor1); - Deriv(3,2) = 0.; - Deriv(3,3) = -(Tan3.Dot(Tan1))/(FirstRad*nnor1); - Deriv(3,4) = 0.; - - Deriv(4,1) = 0.; - Deriv(4,2) = (P2P3.Dot(D22)-Tan2.Dot(Tan2))/(FirstRad*nnor2)- - P2P3.Dot(Tan2)*Tan2.Dot(D22)/(FirstRad*nnor2*nnor2*nnor2); - Deriv(4,3) = Tan3.Dot(Tan2)/(FirstRad*nnor1); - Deriv(4,4) = 0.; - return Standard_True; -} - diff --git a/src/GccIter/GccIter_FunctionTanCuPnt.cdl b/src/GccIter/GccIter_FunctionTanCuPnt.cdl deleted file mode 100644 index 0d7f30634e..0000000000 --- a/src/GccIter/GccIter_FunctionTanCuPnt.cdl +++ /dev/null @@ -1,62 +0,0 @@ --- Created on: 1992-02-20 --- Created by: Remy GILET --- 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. - -generic class FunctionTanCuPnt from GccIter ( - TheCurve as any ; - TheCurveTool as any ) - -inherits FunctionWithDerivative from math - - ---Purpose: This abstract class describes a Function of 1 Variable - -- used to find a line tangent to a curve and passing - -- through a point. - -uses Pnt2d from gp - -is - -Create (C : TheCurve ; - Point : Pnt2d from gp ) returns FunctionTanCuPnt from GccIter; - -Value (me : in out ; - X : Real ; - F : out Real ) returns Boolean; - ---Purpose: Computes the value of the function F for the variable X. - -- It returns True if the computation is successfully done, - -- False otherwise. - -Derivative (me : in out ; - X : Real ; - Deriv : out Real ) returns Boolean; - ---Purpose: Computes the derivative of the function F for the variable X. - -- It returns True if the computation is successfully done, - -- False otherwise. - -Values (me : in out ; - X : Real ; - F : out Real ; - Deriv : out Real ) returns Boolean; - ---Purpose: Computes the value and the derivative of the function F - -- for the variable X. - -- It returns True if the computation is successfully done, - -- False otherwise. - -fields - -TheCurv : TheCurve; -ThePoint : Pnt2d from gp; - -end FunctionTanCuPnt; diff --git a/src/GccIter/GccIter_FunctionTanCuPnt.gxx b/src/GccIter/GccIter_FunctionTanCuPnt.gxx deleted file mode 100644 index 2ff8050414..0000000000 --- a/src/GccIter/GccIter_FunctionTanCuPnt.gxx +++ /dev/null @@ -1,96 +0,0 @@ -// Created on: 1992-01-20 -// Created by: Remi GILET -// 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. - -#include -#include -#include -#include - -//========================================================================= -// soit P1 le point sur la courbe TheCurve d abscisse u. + -// soit C le point ThePoint. + -// Nous cherchons donc les zeros de la fonction suivante: + -// + -// --> --> + -// CP1 /\ T + -// --------------- = F(u) + -// ||CP1|| * ||T|| + -// + -// La derivee de cette fonction est : + -// CP1 /\ N (T.N)*((CP1/\T).((CP1/\T)) + -// f(u) = -------- - -------------------------------- + -// N.N N*N*N*CP1*CP1*CP1 + -//========================================================================= - -GccIter_FunctionTanCuPnt:: - GccIter_FunctionTanCuPnt(const TheCurve& C , - const gp_Pnt2d& Point ) { - TheCurv = C; - ThePoint = Point; - } - - -Standard_Boolean GccIter_FunctionTanCuPnt:: - Value (const Standard_Real X , - Standard_Real& Fval ) { - gp_Pnt2d Point; - gp_Vec2d Vect; - TheCurveTool::D1(TheCurv,X,Point,Vect); - Standard_Real NormeD1 = Vect.Magnitude(); - gp_Vec2d TheDirection(ThePoint,Point); - Standard_Real NormeDir = TheDirection.Magnitude(); - Fval = TheDirection.Crossed(Vect)/(NormeD1*NormeDir); - return Standard_True; -} - -Standard_Boolean GccIter_FunctionTanCuPnt:: - Derivative (const Standard_Real X , - Standard_Real& Deriv ) { - gp_Pnt2d Point; - gp_Vec2d Vec1; - gp_Vec2d Vec2; - TheCurveTool::D2(TheCurv,X,Point,Vec1,Vec2); - gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY())); - Standard_Real NormeD1 = Vec1.Magnitude(); - Standard_Real NormeDir = TheDirection.Magnitude(); - Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)- - (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))* - (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+ - Vec1.Dot(TheDirection)/(NormeDir*NormeDir)); - return Standard_True; -} - -Standard_Boolean GccIter_FunctionTanCuPnt:: - Values (const Standard_Real X , - Standard_Real& Fval , - Standard_Real& Deriv ) { - gp_Pnt2d Point; - gp_Vec2d Vec1; - gp_Vec2d Vec2; - TheCurveTool::D2(TheCurv,X,Point,Vec1,Vec2); - gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY())); - Standard_Real NormeD1 = Vec1.Magnitude(); - Standard_Real NormeDir = TheDirection.Magnitude(); - Fval = TheDirection.Crossed(Vec1)/(NormeD1*NormeDir); - Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)- - (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))* - (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+ - Vec1.Dot(TheDirection)/(NormeDir*NormeDir)); - -// cout << "U = "<< X << " F ="<< Fval <<" DF ="<< Deriv< -#include - -GccIter_FunctionTanObl:: - GccIter_FunctionTanObl(const TheCurve& C , - const gp_Dir2d& Dir ) { - TheCurv = C; - TheDirection = Dir; - } - - -Standard_Boolean GccIter_FunctionTanObl:: - Value (const Standard_Real X , - Standard_Real& Fval ) { - gp_Pnt2d Point; - gp_Vec2d Vect; - TheCurveTool::D1(TheCurv,X,Point,Vect); - Standard_Real NormeD1 = Vect.Magnitude(); - Fval = TheDirection.XY().Crossed(Vect.XY())/NormeD1; - return Standard_True; -} - -Standard_Boolean GccIter_FunctionTanObl:: - Derivative (const Standard_Real X , - Standard_Real& Deriv ) { - gp_Pnt2d Point; - gp_Vec2d Vec1; - gp_Vec2d Vec2; - TheCurveTool::D2(TheCurv,X,Point,Vec1,Vec2); - Standard_Real NormeD1 = Vec1.Magnitude(); - Deriv = TheDirection.XY().Crossed(Vec2.XY())/NormeD1- - Vec1.XY().Dot(Vec2.XY())*TheDirection.XY().Crossed(Vec1.XY())/NormeD1; - return Standard_True; -} - -Standard_Boolean GccIter_FunctionTanObl:: - Values (const Standard_Real X , - Standard_Real& Fval , - Standard_Real& Deriv ) { - gp_Pnt2d Point; - gp_Vec2d Vec1; - gp_Vec2d Vec2; - TheCurveTool::D2(TheCurv,X,Point,Vec1,Vec2); - Standard_Real NormeD1 = Vec1.Magnitude(); - Fval = TheDirection.XY().Crossed(Vec1.XY())/NormeD1; - Deriv = TheDirection.XY().Crossed(Vec2.XY())/NormeD1- - Vec1.XY().Dot(Vec2.XY())*TheDirection.XY().Crossed(Vec1.XY())/NormeD1; - return Standard_True; -} - diff --git a/src/GccIter/GccIter_Lin2d2Tan.cdl b/src/GccIter/GccIter_Lin2d2Tan.cdl deleted file mode 100644 index 10a9e42d48..0000000000 --- a/src/GccIter/GccIter_Lin2d2Tan.cdl +++ /dev/null @@ -1,174 +0,0 @@ --- Created on: 1991-04-24 --- Created by: Remi GILET --- Copyright (c) 1991-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. - -generic class Lin2d2Tan from GccIter ( - TheCurve as any; - TheCurveTool as any; - TheQualifiedCurve as any) -- as QualifiedCurve from GccEnt - -- (TheCurve) - - ---Purpose: This class implements the algorithms used to - -- create 2d lines tangent to 2 other elements which - -- can be circles, curves or points. - -- More than one argument must be a curve. - -- - -- Note: Some constructors may check the type of the qualified argument - -- and raise BadQualifier Error in case of incorrect couple (qualifier, - -- curv). - -- For example: "EnclosedCirc". - -uses Pnt2d from gp, - Lin2d from gp, - QualifiedCirc from GccEnt, - Position from GccEnt - -raises BadQualifier from GccEnt, - NotDone from StdFail - - -private class FuncTCuCu instantiates FunctionTanCuCu from GccIter( - TheCurve,TheCurveTool); - -private class FuncTCuPt instantiates FunctionTanCuPnt from GccIter( - TheCurve,TheCurveTool); - -private class FuncTCirCu instantiates FunctionTanCirCu from GccIter( - TheCurve,TheCurveTool); -is - -Create (Qualified1 : TheQualifiedCurve ; - ThePoint : Pnt2d ; - Param1 : Real ; - Tolang : Real ) returns Lin2d2Tan from GccIter - ---Purpose: This class implements the algorithms used to create 2d - -- lines passing thrue a point and tangent to a curve. - -- Tolang is used to determine the tolerance for the - -- tangency points. - -- Param2 is used for the initial guess on the curve. -raises BadQualifier from GccEnt; - -Create (Qualified1 : QualifiedCirc ; - Qualified2 : TheQualifiedCurve ; - Param2 : Real ; - Tolang : Real ) returns Lin2d2Tan from GccIter -raises BadQualifier from GccEnt; - ---Purpose: This class implements the algorithms used to create 2d - -- line tangent to a circle and to a cuve. - -- Tolang is used to determine the tolerance for the - -- tangency points. - -- Param2 is used for the initial guess on the curve. - -- Exception BadQualifier is raised in the case of - -- EnclosedCirc - -Create (Qualified1 : TheQualifiedCurve ; - Qualified2 : TheQualifiedCurve ; - Param1 : Real ; - Param2 : Real ; - Tolang : Real ) returns Lin2d2Tan from GccIter -raises BadQualifier from GccEnt; - ---Purpose: This class implements the algorithms used to create 2d - -- line tangent to two curves. - -- Tolang is used to determine the tolerance for the - -- tangency points. - -- Param1 is used for the initial guess on the first curve. - -- Param2 is used for the initial guess on the second curve. - --------------------------------------------------------------------------- - -IsDone (me) returns Boolean -is static; - ---Purpose: This methode returns true when there is a solution - -- and false in the other cases. - -ThisSolution(me) returns Lin2d -raises NotDone from StdFail -is static; - ---Purpose: Returns the solution. - -WhichQualifier(me ; - Qualif1 : out Position from GccEnt; - Qualif2 : out Position from GccEnt) -raises NotDone from StdFail -is static; - -- It returns the informations about the qualifiers of the tangency - -- arguments concerning the solution number Index. - -- It returns the real qualifiers (the qualifiers given to the - -- constructor method in case of enclosed, enclosing and outside - -- and the qualifiers computedin case of unqualified). - -Tangency1(me ; - ParSol,ParArg : out Real ; - PntSol : out Pnt2d) -raises NotDone from StdFail -is static; - ---Purpose: Returns informations about the tangency point between the - -- result and the first argument. - -- ParSol is the intrinsic parameter of the point PntSol on - -- the solution curv. - -- ParArg is the intrinsic parameter of the point PntSol on - -- the argument curv. - -Tangency2(me ; - ParSol,ParArg : out Real ; - PntSol : out Pnt2d) -raises NotDone from StdFail -is static; - -- Returns informations about the tangency point between the - -- result and the first argument. - -- ParSol is the intrinsic parameter of the point PntSol on the solution - -- curv. - -- ParArg is the intrinsic parameter of the point PntSol on the argument - -- curv. - -fields - - WellDone : Boolean; - -- True if the algorithm succeeded. - - linsol : Lin2d; - ---Purpose : The solutions. - - qualifier1 : Position from GccEnt; - -- The qualifiers of the first argument. - - qualifier2 : Position from GccEnt; - -- The qualifiers of the first argument. - - pnttg1sol : Pnt2d; - -- The tangency point between the solution and the first argument on - -- the solution. - - pnttg2sol : Pnt2d; - -- The tangency point between the solution and the second argument on - -- the solution. - - par1sol : Real; - -- The parameter of the tangency point between the solution and the - -- first argument on the solution. - - par2sol : Real; - -- The parameter of the tangency point between the solution and the - -- second argument on the solution. - - pararg1 : Real; - -- The parameter of the tangency point between the solution and the first - -- argument on the first argument. - - pararg2 : Real; - -- The parameter of the tangency point between the solution and the second - -- argument on the second argument. - -end Lin2d2Tan; diff --git a/src/GccIter/GccIter_Lin2d2Tan.gxx b/src/GccIter/GccIter_Lin2d2Tan.gxx deleted file mode 100644 index a23117f20e..0000000000 --- a/src/GccIter/GccIter_Lin2d2Tan.gxx +++ /dev/null @@ -1,278 +0,0 @@ -// Created on: 1991-12-20 -// Created by: Remi GILET -// Copyright (c) 1991-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. - -//======================================================================== -// CREATION D UNE LIGNE TANGENTE A DEUX COURBES. + -//======================================================================== - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -GccIter_Lin2d2Tan:: - GccIter_Lin2d2Tan (const GccEnt_QualifiedCirc& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const Standard_Real Param2 , - const Standard_Real Tolang ) { - - par1sol = 0.; - pararg1 = 0.; - - //Standard_Real Tol = Abs(Tolang); - - WellDone = Standard_False; - if (Qualified1.IsEnclosed()) { GccEnt_BadQualifier::Raise(); } - gp_Circ2d C1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - Standard_Real U1 = TheCurveTool::FirstParameter(Cu2); - Standard_Real U2 = TheCurveTool::LastParameter(Cu2); - GccIter_FuncTCirCu func(C1,Cu2); - math_FunctionRoot sol(func,Param2,TheCurveTool::EpsX(Cu2,Abs(Tolang)),U1,U2,100); - if (sol.IsDone()) { - Standard_Real Usol = sol.Root(); -// gp_Pnt2d Origine,Pt; -// Modified by Sergey KHROMOV - Thu Apr 5 17:39:47 2001 Begin - Standard_Real Norm; - func.Value(Usol, Norm); - if (Abs(Norm) < Tolang) { -// Modified by Sergey KHROMOV - Thu Apr 5 17:39:48 2001 End - gp_Pnt2d Origine; - gp_Vec2d Vect1; - gp_Vec2d Vect2; - TheCurveTool::D2(Cu2,Usol,Origine,Vect1,Vect2); - gp_Vec2d Vdir(C1.Location().XY() - Origine.XY()); - Standard_Real sign1 = Vect1.Dot(Vdir); - if (sign1 <= 0. ) { Vect1.Reverse(); } - Standard_Real sign2 = Vect2.Crossed(Vect1); - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing() && sign2<=0.) || - (Qualified2.IsOutside() && sign1 <= 0. && sign2 >= 0.) || - (Qualified2.IsEnclosed() && sign1 >= 0. && sign2 >= 0.)) { - if (Qualified1.IsUnqualified() || - (Qualified1.IsOutside() && Vect1.Angle(Vdir) <= 0.) || - (Qualified1.IsEnclosing() && Vect1.Angle(Vdir) >= 0.)) { - gp_Dir2d direc(Vect1); - Standard_Real R1 = C1.Radius(); - gp_XY normal(-R1*direc.Y(),R1*direc.X()); - sign1 = Vect1.Crossed(Vdir); - if (Qualified1.IsEnclosing()) { - pnttg1sol = gp_Pnt2d(C1.Location().XY()-normal); - } - else if (Qualified1.IsOutside()) { - pnttg1sol = gp_Pnt2d(C1.Location().XY()+normal); - } - else { - if (sign1 >= 0.) { - pnttg1sol = gp_Pnt2d(C1.Location().XY()-normal); - } - else { - pnttg1sol = gp_Pnt2d(C1.Location().XY()+normal); - } - } -// if (gp_Vec2d(direc.XY()).Angle(gp_Vec2d(pnttg1sol,Origine)) <= Tol) { - pnttg2sol = Origine; - linsol = gp_Lin2d(pnttg1sol,direc); - WellDone = Standard_True; - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pararg2 = Usol; - par1sol = 0.; - par2sol = pnttg2sol.Distance(pnttg1sol); - pararg1 = 0.; - } - } - } - } - } - -GccIter_Lin2d2Tan:: - GccIter_Lin2d2Tan (const TheQualifiedCurve& Qualified1 , - const TheQualifiedCurve& Qualified2 , - const Standard_Real Param1 , - const Standard_Real Param2 , - const Standard_Real Tolang ) { - par1sol = 0.; - pararg1 = 0.; - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - TheCurve Cu1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); - GccIter_FuncTCuCu Func(Cu1,Cu2); - math_Vector Umin(1,2); - math_Vector Umax(1,2); - math_Vector Ufirst(1,2); - math_Vector tol(1,2); - Umin(1) = TheCurveTool::FirstParameter(Cu1); - Umin(2) = TheCurveTool::FirstParameter(Cu2); - Umax(1) = TheCurveTool::LastParameter(Cu1); - Umax(2) = TheCurveTool::LastParameter(Cu2); - Ufirst(1) = Param1; - Ufirst(2) = Param2; - tol(1) = TheCurveTool::EpsX(Cu1,Abs(Tolang)); - tol(2) = TheCurveTool::EpsX(Cu2,Abs(Tolang)); - math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); - if (Root.IsDone()) { - Root.Root(Ufirst); -// Modified by Sergey KHROMOV - Thu Apr 5 17:45:00 2001 Begin - math_Vector Norm(1,2); - Func.Value(Ufirst, Norm); - if (Abs(Norm(1)) < Tolang && Abs(Norm(2)) < Tolang) { -// Modified by Sergey KHROMOV - Thu Apr 5 17:45:01 2001 End - gp_Pnt2d point1,point2; - gp_Vec2d Vect11,Vect12,Vect21,Vect22; - TheCurveTool::D2(Cu1,Ufirst(1),point1,Vect11,Vect12); - TheCurveTool::D2(Cu2,Ufirst(2),point2,Vect21,Vect22); - gp_Vec2d Vec(point1.XY(),point2.XY()); - Standard_Real Angle1 = Vec.Angle(Vect12); - Standard_Real sign1 = Vect11.Dot(Vec); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && Angle1 >= 0.) || - (Qualified1.IsOutside() && Angle1 <= 0. && sign1 <= 0.) || - (Qualified1.IsEnclosed() && Angle1 <= 0. && sign1 >= 0.)) { - Angle1 = Vec.Angle(Vect22); - sign1 = Vect21.Dot(Vec); - if (Qualified2.IsUnqualified() || - (Qualified2.IsEnclosing() && Angle1 >= 0.) || - (Qualified2.IsOutside() && Angle1 <= 0. && sign1 <= 0.) || - (Qualified2.IsEnclosed() && Angle1 <= 0. && sign1 >= 0.)) { - qualifier1 = Qualified1.Qualifier(); - qualifier2 = Qualified2.Qualifier(); - pararg1 = Ufirst(1); - par1sol = 0.; - pnttg1sol = point1; - pararg2 = Ufirst(2); - pnttg2sol = point2; - par2sol = pnttg2sol.Distance(pnttg1sol); - gp_Dir2d dir(pnttg2sol.X()-pnttg1sol.X(),pnttg2sol.Y()-pnttg1sol.Y()); - linsol = gp_Lin2d(pnttg1sol,dir); - WellDone = Standard_True; - } - } - } - } - } - -GccIter_Lin2d2Tan:: - GccIter_Lin2d2Tan (const TheQualifiedCurve& Qualified1 , - const gp_Pnt2d& ThePoint , - const Standard_Real Param1 , - const Standard_Real Tolang ) { - - par1sol = 0.; - pararg1 = 0.; - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - TheCurve Cu1 = Qualified1.Qualified(); - Standard_Real U1 = TheCurveTool::FirstParameter(Cu1); - Standard_Real U2 = TheCurveTool::LastParameter(Cu1); - GccIter_FuncTCuPt func(Cu1,ThePoint); - math_FunctionRoot sol(func,Param1,TheCurveTool::EpsX(Cu1,Abs(Tolang)),U1,U2,100); - if (sol.IsDone()) { - Standard_Real Usol = sol.Root(); -// Modified by Sergey KHROMOV - Thu Apr 5 17:45:17 2001 Begin - Standard_Real Norm; - func.Value(Usol, Norm); - if (Abs(Norm) < Tolang) { -// Modified by Sergey KHROMOV - Thu Apr 5 17:45:19 2001 End - gp_Pnt2d Origine; - gp_Vec2d Vect1; - gp_Vec2d Vect2; - TheCurveTool::D2(Cu1,Usol,Origine,Vect1,Vect2); - gp_Vec2d Vdir(ThePoint.XY()-Origine.XY()); - Standard_Real sign1 = Vect1.Dot(Vdir); - Standard_Real sign2 = Vect2.Crossed(Vdir); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && - ((sign1 >= 0. && sign2 <= 0.) || (sign1 <= 0. && sign2 <= 0.))) || - (Qualified1.IsOutside() && sign1 <= 0. && sign2 >= 0.) || - (Qualified1.IsEnclosed() && sign1 >= 0. && sign2 >= 0.)) { - WellDone = Standard_True; - linsol = gp_Lin2d(Origine,gp_Dir2d(Vdir)); - qualifier1 = Qualified1.Qualifier(); - qualifier2 = GccEnt_noqualifier; - pnttg1sol = Origine; - pnttg2sol = ThePoint; - pararg1 = Usol; - par1sol = 0.; - pararg2 = ThePoint.Distance(Origine); - par2sol = 0.; - } - } - } - } - -Standard_Boolean GccIter_Lin2d2Tan:: - IsDone () const { return WellDone; } - -gp_Lin2d GccIter_Lin2d2Tan:: - ThisSolution () const -{ - if (!WellDone) StdFail_NotDone::Raise(); - return linsol; -} - -void GccIter_Lin2d2Tan:: - WhichQualifier (GccEnt_Position& Qualif1 , - GccEnt_Position& Qualif2 ) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - Qualif1 = qualifier1; - Qualif2 = qualifier2; - } -} - -void GccIter_Lin2d2Tan:: - Tangency1 (Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& Pnt) const { - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - ParSol = par1sol; - ParArg = pararg1; - Pnt = pnttg1sol; - } - } - -void GccIter_Lin2d2Tan:: - Tangency2 (Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& Pnt) const { - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - ParSol = par2sol; - ParArg = pararg2; - Pnt = pnttg2sol; - } - } - diff --git a/src/GccIter/GccIter_Lin2dTanObl.cdl b/src/GccIter/GccIter_Lin2dTanObl.cdl deleted file mode 100644 index 6bf9c2d3c8..0000000000 --- a/src/GccIter/GccIter_Lin2dTanObl.cdl +++ /dev/null @@ -1,140 +0,0 @@ --- Created on: 1991-04-24 --- Created by: Remi GILET --- Copyright (c) 1991-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. - -generic class Lin2dTanObl from GccIter ( - TheCurve as any; - TheCurveTool as any; - TheQualifiedCurve as any) -- as QualifiedCurve from GccEnt - -- (TheCurve) - - ---Purpose: This class implements the algorithms used to - -- create 2d line tangent to a curve QualifiedCurv and - -- doing an angle Angle with a line TheLin. - -- The angle must be in Radian. - -uses Lin2d from gp, - Pnt2d from gp, - Position from GccEnt - -raises BadQualifier from GccEnt, - NotDone from StdFail, - IsParallel from GccIter - -private class FuncTObl instantiates FunctionTanObl from GccIter( - TheCurve,TheCurveTool); - -is - -Create (Qualified1 : TheQualifiedCurve ; - TheLin : Lin2d ; - Param1 : Real ; - TolAng : Real ; - Angle : Real = 0 ) returns Lin2dTanObl from GccIter -raises BadQualifier from GccEnt; - ---Purpose: This class implements the algorithm used to - -- create 2d line tangent to a curve and doing an - -- angle Angle with the line TheLin. - -- Angle must be in Radian. - -- Param2 is the initial guess on the curve QualifiedCurv. - -- Tolang is the angular tolerance. - --- ........................................................................ - -IsDone(me) returns Boolean -is static; - ---Purpose: This method returns true when there is a solution - -- and false in the other cases. - -ThisSolution(me) returns Lin2d -raises NotDone from StdFail -is static; - -- Returns the solution. - -WhichQualifier(me ; - Qualif1 : out Position from GccEnt) -raises NotDone from StdFail -is static; - -- It returns the informations about the qualifiers of the tangency - -- arguments concerning the solution number Index. - -- It returns the real qualifiers (the qualifiers given to the - -- constructor method in case of enclosed, enclosing and outside - -- and the qualifiers computedin case of unqualified). - -Tangency1(me ; - ParSol,ParArg : out Real ; - PntSol : out Pnt2d) -raises NotDone from StdFail -is static; - -- Returns informations about the tangency point between the - -- result and the first argument. - -- ParSol is the intrinsic parameter of the point ParSol on the solution - -- curv. - -- ParArg is the intrinsic parameter of the point PntSol on the argument - -- curv. - -Intersection2 (me ; - ParSol,ParArg : out Real ; - PntSol : out Pnt2d) -raises NotDone from StdFail, IsParallel from GccIter -is static; - -- Returns informations about the center (on the curv) of the - -- result and the third argument. - -IsParallel2(me) returns Boolean -raises NotDone from StdFail -is static; - -- Returns informations about the center (on the curv) of the - -- result and the third argument. - -fields - - WellDone : Boolean; - -- True if the algorithm succeeded. - - Paral2 : Boolean; - -- True if the solution is parallel to the second argument (Angle = 0). - - linsol : Lin2d; - ---Purpose : The solution. - - qualifier1 : Position from GccEnt; - -- The qualifiers of the first argument. - - pnttg1sol : Pnt2d; - -- The tangency point between the solution and the first argument on - -- the solution. - - pntint2sol : Pnt2d; - -- The tangency point between the solution and the second argument on - -- the solution. - - par1sol : Real; - -- The parameter of the tangency point between the solution and the - -- first argument on the solution. - - par2sol : Real; - -- The parameter of the intersection point between the solution and the - -- second argument on the solution. - - pararg1 : Real; - -- The parameter of the tangency point between the solution and the first - -- argument on the first argument. - - pararg2 : Real; - -- The parameter of the intersection point between the solution and - -- the second argument on the second argument. - -end Lin2dTanObl; diff --git a/src/GccIter/GccIter_Lin2dTanObl.gxx b/src/GccIter/GccIter_Lin2dTanObl.gxx deleted file mode 100644 index 288e864aeb..0000000000 --- a/src/GccIter/GccIter_Lin2dTanObl.gxx +++ /dev/null @@ -1,150 +0,0 @@ -// Created on: 1991-12-20 -// Created by: Remi GILET -// Copyright (c) 1991-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. - -//======================================================================== -// CREATION D UNE LIGNE TANGENTE A UNE COURBE ET PARALLELE A UNE DROITE. + -//======================================================================== - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -GccIter_Lin2dTanObl:: - GccIter_Lin2dTanObl (const TheQualifiedCurve& Qualified1 , - const gp_Lin2d& TheLin , - const Standard_Real Param1 , - const Standard_Real TolAng , - const Standard_Real Angle ) { - - par1sol = 0.; - pararg1 = 0.; - WellDone = Standard_False; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Paral2 = Standard_False; - TheCurve Cu1 = Qualified1.Qualified(); - Standard_Real U1 = TheCurveTool::FirstParameter(Cu1); - Standard_Real U2 = TheCurveTool::LastParameter(Cu1); - gp_Dir2d Dir(TheLin.Direction()); - Standard_Real A = Dir.X(); - Standard_Real B = Dir.Y(); - gp_Dir2d TheDirection(Dir); - if (Abs(Angle) > Abs(TolAng)) { - if (Abs(Abs(Angle)-M_PI) <= Abs(TolAng)) { - Paral2 = Standard_True; - TheDirection = Dir.Reversed(); - } - else if (Abs(Angle-M_PI/2) <= Abs(TolAng)) { TheDirection=gp_Dir2d(-B,A); } - else if (Abs(Angle+M_PI/2) <= Abs(TolAng)) { TheDirection=gp_Dir2d(B,-A); } - else { - TheDirection=gp_Dir2d(A*Cos(Angle)-B*Sin(Angle), - A*Sin(Angle)+B*Cos(Angle)); - } - } - else { Paral2 = Standard_True; } - GccIter_FuncTObl func(Cu1,TheDirection); - math_FunctionRoot sol(func,Param1, - TheCurveTool::EpsX(Cu1,Abs(TolAng)),U1,U2,100); - if (sol.IsDone()) { - Standard_Real Usol = sol.Root(); - gp_Pnt2d Origine; - gp_Vec2d Vect1,Vect2; - TheCurveTool::D2(Cu1,Usol,Origine,Vect1,Vect2); - Standard_Real sign1 = Vect1.XY().Dot(TheDirection.XY()); - Standard_Real sign2 = Vect2.XY().Crossed(TheDirection.XY()); - if (Qualified1.IsUnqualified() || - (Qualified1.IsEnclosing() && sign2<=0.) || - (Qualified1.IsOutside() && sign1 <= 0. && sign2 >= 0.) || - (Qualified1.IsEnclosed() && sign1 >= 0. && sign2 >= 0.)) { - WellDone = Standard_True; - linsol = gp_Lin2d(Origine,TheDirection); - pnttg1sol = Origine; - qualifier1 = Qualified1.Qualifier(); - pararg1 = Usol; - par1sol = 0.; - if (!Paral2) { - IntAna2d_AnaIntersection Intp(linsol,TheLin); - if (Intp.IsDone() && !Intp.IsEmpty()) { - if (Intp.NbPoints()==1) { - pntint2sol = Intp.Point(1).Value(); - par2sol = gp_Vec2d(linsol.Direction()). - Dot(gp_Vec2d(linsol.Location(),pntint2sol)); - pararg2 = gp_Vec2d(TheLin.Direction()). - Dot(gp_Vec2d(TheLin.Location(),pntint2sol)); - } - } - } - } - } - } - -Standard_Boolean GccIter_Lin2dTanObl:: - IsDone () const { return WellDone; } - -gp_Lin2d GccIter_Lin2dTanObl::ThisSolution () const -{ - if (!WellDone) StdFail_NotDone::Raise(); - - return linsol; -} - -void GccIter_Lin2dTanObl:: - WhichQualifier (GccEnt_Position& Qualif1) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - Qualif1 = qualifier1; - } -} - -Standard_Boolean GccIter_Lin2dTanObl:: - IsParallel2 () const { return Paral2; } - -void GccIter_Lin2dTanObl:: - Tangency1 (Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& PntSol) const { - if (!WellDone) { StdFail_NotDone::Raise(); } - else { - ParSol = par1sol; - ParArg = pararg1; - PntSol = gp_Pnt2d(pnttg1sol); - } - } - -void GccIter_Lin2dTanObl:: - Intersection2 (Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& PntSol ) const { - if (!WellDone) { StdFail_NotDone::Raise(); } - else if (Paral2) { GccIter_IsParallel::Raise(); } - else { - PntSol = pntint2sol; - ParSol = par2sol; - ParArg = pararg2; - } - } - diff --git a/src/Geom2dGcc/Geom2dGcc.cdl b/src/Geom2dGcc/Geom2dGcc.cdl index b8dae287a9..4a859d4767 100644 --- a/src/Geom2dGcc/Geom2dGcc.cdl +++ b/src/Geom2dGcc/Geom2dGcc.cdl @@ -33,7 +33,6 @@ package Geom2dGcc uses GccEnt, GccAna, - GccIter, StdFail, Geom2dInt, Geom2d, @@ -45,7 +44,8 @@ uses GccEnt, Adaptor3d, Adaptor2d, TColgp, - gp + gp, + math is @@ -79,25 +79,29 @@ class Circ2dTanCenGeo; class Circ2dTanOnRadGeo; -class MyC2d3Tan instantiates Circ2d3Tan from GccIter - (Curve from Geom2dAdaptor, - CurveTool from Geom2dGcc, - QCurve from Geom2dGcc); - -class MyC2d2TanOn instantiates Circ2d2TanOn from GccIter - (Curve from Geom2dAdaptor, - CurveTool from Geom2dGcc, - QCurve from Geom2dGcc); - -class MyL2dTanObl instantiates Lin2dTanObl from GccIter - (Curve from Geom2dAdaptor, - CurveTool from Geom2dGcc, - QCurve from Geom2dGcc); - -class MyL2d2Tan instantiates Lin2d2Tan from GccIter - (Curve from Geom2dAdaptor, - CurveTool from Geom2dGcc, - QCurve from Geom2dGcc); +class Circ2d3TanIter; +private class FunctionTanCuCuCu; + +class Circ2d2TanOnIter; +private class FunctionTanCuCuOnCu; + +class Lin2dTanOblIter; +private class FunctionTanObl; + +class Lin2d2TanIter; +private class FunctionTanCuCu; +private class FunctionTanCuPnt; +private class FunctionTanCirCu; + +enumeration Type1 is CuCuCu,CiCuCu,CiCiCu,CiLiCu,LiLiCu,LiCuCu; + +enumeration Type2 is CuCuOnCu,CiCuOnCu,LiCuOnCu,CuPtOnCu, + CuCuOnLi,CiCuOnLi,LiCuOnLi,CuPtOnLi, + CuCuOnCi,CiCuOnCi,LiCuOnCi,CuPtOnCi; + +enumeration Type3 is CuCu,CiCu; + +exception IsParallel inherits DomainError from Standard; Unqualified(Obj : Curve from Geom2dAdaptor) returns QualifiedCurve; ---Purpose: Constructs such a qualified curve that the relative diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cdl index e2778ff887..b68b3a4a33 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cdl @@ -43,7 +43,7 @@ uses Curve from Geom2dAdaptor, Circ2d from gp, Circ2d2TanOn from GccAna, Circ2d2TanOnGeo from Geom2dGcc, - MyC2d2TanOn from Geom2dGcc, + Circ2d2TanOnIter from Geom2dGcc, Position from GccEnt, Array1OfPosition from GccEnt @@ -285,7 +285,7 @@ fields -- CircAna : Circ2d2TanOn from GccAna; -- CircGeo : Circ2d2TanOnGeo from Geom2dGcc; --- CircIter : MyC2d2TanOn from Geom2dGcc; +-- CircIter : Circ2d2TanOnIter from Geom2dGcc; -- TypeAna : Boolean; end Circ2d2TanOn; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cxx index 54e6bdf35e..95fb5fdcd8 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cxx @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -267,18 +267,13 @@ Geom2dGcc_Circ2d2TanOn:: } } } - -//============================================================================= -// Appel a GccIter. + -//============================================================================= - else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); Geom2dGcc_QCurve Qc2(C2,Qualified2.Qualifier()); if ((Type3 == GeomAbs_Circle || Type3 == GeomAbs_Line)) { if (Type3 == GeomAbs_Circle) { Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); - Geom2dGcc_MyC2d2TanOn Circ(Qc1,Qc2,CCon->Circ2d(), + Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Qc2,CCon->Circ2d(), Param1,Param2,ParamOn,Tolerance); WellDone = Circ.IsDone(); NbrSol = 1; @@ -292,7 +287,7 @@ Geom2dGcc_Circ2d2TanOn:: } else { Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con); - Geom2dGcc_MyC2d2TanOn Circ(Qc1,Qc2,LLon->Lin2d(), + Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Qc2,LLon->Lin2d(), Param1,Param2,ParamOn,Tolerance); WellDone = Circ.IsDone(); NbrSol = 1; @@ -306,7 +301,7 @@ Geom2dGcc_Circ2d2TanOn:: Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1)); } } - Geom2dGcc_MyC2d2TanOn Circ(Qc1,Qc2,OnCurve, + Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Qc2,OnCurve, Param1,Param2,ParamOn,Tolerance); WellDone = Circ.IsDone(); NbrSol = 1; @@ -438,18 +433,13 @@ Geom2dGcc_Circ2d2TanOn:: Results(CircGeo); } } - } - -//============================================================================= -// Appel a GccIter. + -//============================================================================= - + } else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); if ((Type3 == GeomAbs_Circle || Type3 == GeomAbs_Line)) { if (Type3 == GeomAbs_Circle) { Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); - Geom2dGcc_MyC2d2TanOn Circ(Qc1,Point->Pnt2d(),CCon->Circ2d(), + Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Point->Pnt2d(),CCon->Circ2d(), Param1,ParamOn,Tolerance); WellDone = Circ.IsDone(); NbrSol = 1; @@ -462,7 +452,7 @@ Geom2dGcc_Circ2d2TanOn:: } else { Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con); - Geom2dGcc_MyC2d2TanOn Circ(Qc1,Point->Pnt2d(),LLon->Lin2d(), + Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Point->Pnt2d(),LLon->Lin2d(), Param1,ParamOn,Tolerance); WellDone = Circ.IsDone(); NbrSol = 1; @@ -475,7 +465,7 @@ Geom2dGcc_Circ2d2TanOn:: } } else { - Geom2dGcc_MyC2d2TanOn Circ(Qc1,Point->Pnt2d(),OnCurve, + Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Point->Pnt2d(),OnCurve, Param1,ParamOn,Tolerance); WellDone = Circ.IsDone(); NbrSol = 1; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cdl new file mode 100644 index 0000000000..2209e40289 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cdl @@ -0,0 +1,346 @@ +-- Created on: 1991-03-29 +-- Created by: Remi GILET +-- Copyright (c) 1991-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. + +class Circ2d2TanOnIter from Geom2dGcc + + ---Purpose: This class implements the algorithms used to + -- create 2d circles TANgent to 2 entities and + -- having the center ON a curv. + -- The order of the tangency argument is always + -- QualifiedCirc, QualifiedLin, QualifiedCurv, Pnt2d. + -- the arguments are : + -- - The two tangency arguments. + -- - The center line. + -- - The parameter for each tangency argument which + -- is a curve. + -- - The tolerance. + +-- inherits Entity from Standard + +uses Pnt2d from gp, + Lin2d from gp, + Circ2d from gp, + QualifiedCirc from GccEnt, + QualifiedLin from GccEnt, + Position from GccEnt, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + QCurve from Geom2dGcc + +raises NotDone from StdFail + +is + +-- On a 2d line .......................................................... + +Create(Qualified1 : QualifiedCirc ; + Qualified2 : QCurve from Geom2dGcc; + OnLine : Lin2d ; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d circle and a curve and + -- having the center ON a 2d line. + -- Param2 is the initial guess on the curve QualifiedCurv. + -- Tolerance is used for the limit cases. + +Create(Qualified1 : QualifiedLin ; + Qualified2 : QCurve from Geom2dGcc; + OnLine : Lin2d ; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d line and a curve and + -- having the center ON a 2d line. + -- Param2 is the initial guess on the curve QualifiedCurv. + -- Tolerance is used for the limit cases. + +Create(Qualified1 : QCurve from Geom2dGcc; + Qualified2 : QCurve from Geom2dGcc; + OnLine : Lin2d ; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to two curves and + -- having the center ON a 2d line. + -- Param1 is the initial guess on the first QualifiedCurv. + -- Param2 is the initial guess on the first QualifiedCurv. + -- Tolerance is used for the limit cases. + +Create(Qualified1 : QCurve from Geom2dGcc; + Point2 : Pnt2d ; + OnLine : Lin2d ; + Param1 : Real ; + Param2 : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d point and a curve and + -- having the center ON a 2d line. + -- Param2 is the initial guess on the curve QualifiedCurv. + -- Tolerance is used for the limit cases. + + +-- -- On a 2d Circle ..................................................... + +Create(Qualified1 : QualifiedCirc ; + Qualified2 : QCurve from Geom2dGcc; + OnCirc : Circ2d ; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d circle and a curve and + -- having the center ON a 2d circle. + -- Param2 is the initial guess on the curve QualifiedCurv. + -- Tolerance is used for the limit cases. + +Create(Qualified1 : QualifiedLin ; + Qualified2 : QCurve from Geom2dGcc; + OnCirc : Circ2d ; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d line and a curve and + -- having the center ON a 2d circle. + -- Param2 is the initial guess on the curve QualifiedCurv. + -- Tolerance is used for the limit cases. + +Create(Qualified1 : QCurve from Geom2dGcc; + Qualified2 : QCurve from Geom2dGcc; + OnCirc : Circ2d ; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to two curves and + -- having the center ON a 2d circle. + -- Param1 is the initial guess on the first QualifiedCurv. + -- Param2 is the initial guess on the first QualifiedCurv. + -- Tolerance is used for the limit cases. + +Create(Qualified1 : QCurve from Geom2dGcc; + Point2 : Pnt2d ; + OnCirc : Circ2d ; + Param1 : Real ; + Param2 : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d point and a curve and + -- having the center ON a 2d circle. + -- Param2 is the initial guess on the curve QualifiedCurv. + -- Tolerance is used for the limit cases. + +-- -- On a curve ..................................................... + +Create(Qualified1 : QualifiedCirc ; + Qualified2 : QCurve from Geom2dGcc; + OnCurv : Curve from Geom2dAdaptor; + Param1 : Real ; + Param2 : Real ; + ParamOn : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d circle and a curve and + -- having the center ON a 2d curve. + -- Param2 is the initial guess on the curve QualifiedCurv. + -- ParamOn is the initial guess on the center curve OnCurv. + -- Tolerance is used for the limit cases. + +Create(Qualified1 : QualifiedLin ; + Qualified2 : QCurve from Geom2dGcc; + OnCurve : Curve from Geom2dAdaptor; + Param1 : Real ; + Param2 : Real ; + ParamOn : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d line and a curve and + -- having the center ON a 2d curve. + -- Param2 is the initial guess on the curve QualifiedCurv. + -- ParamOn is the initial guess on the center curve OnCurv. + -- Tolerance is used for the limit cases. + +Create(Qualified1 : QCurve from Geom2dGcc; + Point2 : Pnt2d ; + OnCurve : Curve from Geom2dAdaptor; + Param1 : Real ; + ParamOn : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d Point and a curve and + -- having the center ON a 2d curve. + -- Param1 is the initial guess on the curve QualifiedCurv. + -- ParamOn is the initial guess on the center curve OnCurv. + -- Tolerance is used for the limit cases. + +Create(Qualified1 : QCurve from Geom2dGcc; + Qualified2 : QCurve from Geom2dGcc; + OnCurve : Curve from Geom2dAdaptor; + Param1 : Real ; + Param2 : Real ; + ParamOn : Real ; + Tolerance : Real ) returns Circ2d2TanOnIter from Geom2dGcc ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to two curves and + -- having the center ON a 2d curve. + -- Param1 is the initial guess on the first curve QualifiedCurv. + -- Param1 is the initial guess on the second curve QualifiedCurv. + -- ParamOn is the initial guess on the center curve OnCurv. + -- Tolerance is used for the limit cases. + +-- -- .................................................................... + +IsDone(me) returns Boolean +is static; + ---Purpose: This method returns True if the construction + -- algorithm succeeded. + +ThisSolution(me) returns Circ2d + ---Purpose: Returns the solution. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +WhichQualifier(me ; + Qualif1 : out Position from GccEnt; + Qualif2 : out Position from GccEnt) +raises NotDone from StdFail +is static; + -- It returns the informations about the qualifiers of the tangency + -- arguments concerning the solution number Index. + -- It returns the real qualifiers (the qualifiers given to the + -- constructor method in case of enclosed, enclosing and outside + -- and the qualifiers computedin case of unqualified). + +Tangency1(me ; + ParSol,ParArg : out Real ; + PntSol : out Pnt2d) + ---Purpose: Returns information about the tangency point between + -- the result and the first argument. + -- ParSol is the intrinsic parameter of the point PntSol + -- on the solution curv. + -- ParArg is the intrinsic parameter of the point PntSol + -- on the argument curv. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +Tangency2(me ; + ParSol,ParArg : out Real ; + PntSol : out Pnt2d) + ---Purpose: Returns information about the tangency point between + -- the result and the second argument. + -- ParSol is the intrinsic parameter of the point PntSol + -- on the solution curv. + -- ParArg is the intrinsic parameter of the point PntSol + -- on the argument curv. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +CenterOn3 (me ; + ParArg : out Real ; + PntSol : out Pnt2d) + ---Purpose: Returns information about the center (on the curv) of the + -- result and the third argument. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +IsTheSame1(me) returns Boolean + -- Returns True if the solution is equal to the first argument. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +IsTheSame2(me) returns Boolean + -- Returns True if the solution is equal to the second argument. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +fields + + WellDone : Boolean; + ---Purpose: True if the algorithm succeeded. + + cirsol : Circ2d from gp; + -- The solutions. + + qualifier1 : Position from GccEnt; + -- The qualifiers of the first argument. + + qualifier2 : Position from GccEnt; + -- The qualifiers of the first argument. + + TheSame1 : Boolean; + ---Purpose: True if the solution and the first argument are the + -- same in the tolerance of Tolerance. + -- False in the other cases. + + TheSame2 : Boolean; + ---Purpose: True if the solution and the second argument are the + -- same in the tolerance of Tolerance. + -- False in the other cases. + + pnttg1sol : Pnt2d; + ---Purpose: The tangency point between the solution and the first + -- argument on the solution. + + pnttg2sol : Pnt2d; + ---Purpose: The tangency point between the solution and the second + -- argument on the solution. + + pntcen : Pnt2d; + ---Purpose: The center point of the solution on the third argument. + + par1sol : Real; + ---Purpose: The parameter of the tangency point between the + -- solution and the first argument on the solution. + + par2sol : Real; + ---Purpose: The parameter of the tangency point between the + -- solution and the second argument on the solution. + + pararg1 : Real; + ---Purpose: The parameter of the tangency point between the + -- solution and the first argument on the first argument. + + pararg2 : Real; + ---Purpose: The parameter of the tangency point between the + -- solution and the second argument on the second argument. + + parcen3 : Real; + ---Purpose: The parameter of the center point of the solution + -- on the second argument. + +end Circ2d2TanOnIter; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx new file mode 100644 index 0000000000..aa6de8295a --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx @@ -0,0 +1,1302 @@ +// Created on: 1991-12-13 +// Created by: Remi GILET +// Copyright (c) 1991-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. + +//========================================================================= +// Creation d un cercle tangent a deux elements : Droite. + +// Cercle. + +// Point. + +// Courbes. + +// centre sur un troisieme : Droite. + +// Cercle. + +// Courbes. + +//========================================================================= + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const gp_Lin2d& OnLine , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolang ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + Standard_Real Tol = Abs(Tolang); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Dir2d dirx(1.,0.); + gp_Lin2d L1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + math_Vector Umin(1,4); + math_Vector Umax(1,4); + math_Vector Ufirst(1,4); + math_Vector tol(1,4); + Umin(1) = RealFirst(); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = RealFirst(); + Umin(4) = 0.; + Umax(1) = RealLast(); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = RealLast(); + Umax(4) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = 1.e-15; + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Tolang); + tol(3) = tol(1); + tol(4) = tol(1); + gp_Pnt2d point1 = ElCLib::Value(Param1,L1); + gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); + gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine); + Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnLine,Ufirst(4)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + // gp_Vec2d Tan1,Tan2,Nor1,Nor2; + gp_Vec2d Tan1,Tan2; + ElCLib::D1(Ufirst(1),L1,point1,Tan1); + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); + gp_Vec2d Tan3(OnLine.Direction().XY()); + gp_Pnt2d point3(OnLine.Location().XY()+Ufirst(3)*Tan3.XY()); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan2 = Tan2.Magnitude(); + gp_Vec2d Vec1(point1,point3); + gp_Vec2d Vec2(point2,point3); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real angle2; + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + angle2 = Vec2.Angle(Tan2); + } + else { angle2 = 0.; } + Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(), + L1.Direction().X())); + if (Qualified1.IsUnqualified() || + (Qualified1.IsOutside() && pscal <= 0.) || + (Qualified1.IsEnclosed() && pscal >= 0.)) { + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&angle2<=0.)|| + (Qualified2.IsOutside() && angle2 >= 0) || + (Qualified2.IsEnclosed() && angle2 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pnttg1sol = point1; + pararg1 = Ufirst(1); + par1sol = ElCLib::Parameter(cirsol,pnttg1sol); + pnttg2sol = point2; + pararg2 = Ufirst(2); + par2sol = ElCLib::Parameter(cirsol,pnttg2sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const gp_Lin2d& OnLine , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + gp_Dir2d dirx(1.,0.); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + math_Vector Umin(1,4); + math_Vector Umax(1,4); + math_Vector Ufirst(1,4); + math_Vector tol(1,4); + Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = RealFirst(); + Umin(4) = 0.; + Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = RealLast(); + Umax(4) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance)); + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = 1.e-15; + tol(4) = Tol/10.; + gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1); + gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); + gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine); + Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnLine,Ufirst(4)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + gp_Vec2d Tan1,Tan2; + Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1); + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); + gp_Vec2d Tan3(OnLine.Direction().XY()); + gp_Pnt2d point3(OnLine.Location().XY()+Ufirst(3)*Tan3.XY()); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + gp_Vec2d Vec1(point1,point3); + gp_Vec2d Vec2(point2,point3); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real angle1,angle2; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + angle1 = Vec1.Angle(Tan1); + } + else { angle1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + angle2 = Vec2.Angle(Tan2); + } + else { angle2 = 0.; } + if (Qualified1.IsUnqualified()|| + (Qualified1.IsEnclosing()&&angle1<=0.)|| + (Qualified1.IsOutside() && angle1 >= 0.) || + (Qualified1.IsEnclosed() && angle1 <= 0.)) { + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&angle2<=0.)|| + (Qualified2.IsOutside() && angle2 >= 0) || + (Qualified2.IsEnclosed() && angle2 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pnttg1sol = point1; + pararg1 = Ufirst(1); + par1sol = ElCLib::Parameter(cirsol,pnttg1sol); + pnttg2sol = point2; + pararg2 = Ufirst(2); + par2sol = ElCLib::Parameter(cirsol,pnttg2sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , + const gp_Pnt2d& Point2 , + const gp_Lin2d& OnLine , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Tolerance ) { + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + gp_Dir2d dirx(1.,0.); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Umin(2) = RealFirst(); + Umin(3) = 0.; + Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1); + Umax(2) = RealLast(); + Umax(3) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance)); + tol(2) = 1.e-15; + tol(3) = Tol/10.; + gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1); + gp_Pnt2d point3 = ElCLib::Value(Param2,OnLine); + Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnLine,Ufirst(3)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + gp_Pnt2d point1,point3; + gp_Vec2d Tan1,Tan3; + Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1); + ElCLib::D1(Ufirst(2),OnLine,point3,Tan3); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(Point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan1 = Tan1.Magnitude(); + gp_Vec2d Vec1(point1,point3); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real angle1; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + angle1 = Vec1.Angle(Tan1); + } + else { angle1 = 0.; } + if (Qualified1.IsUnqualified()|| + (Qualified1.IsEnclosing()&&angle1<=0.)|| + (Qualified1.IsOutside() && angle1 >= 0.) || + (Qualified1.IsEnclosed() && angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = GccEnt_noqualifier; + pnttg1sol = point1; + pararg1 = Ufirst(1); + par1sol = ElCLib::Parameter(cirsol,pnttg1sol); + pnttg2sol = Point2; + pararg2 = Ufirst(2); + par2sol = ElCLib::Parameter(cirsol,pnttg2sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const gp_Lin2d& OnLine , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + gp_Dir2d dirx(1.,0.); + gp_Circ2d C1 = Qualified1.Qualified(); + Standard_Real R1 = C1.Radius(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + math_Vector Umin(1,4); + math_Vector Umax(1,4); + math_Vector Ufirst(1,4); + math_Vector tol(1,4); + Umin(1) = RealFirst(); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = RealFirst(); + Umin(4) = 0.; + Umax(1) = RealLast(); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = RealLast(); + Umax(4) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = 2.e-15*M_PI; + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = 1.e-15; + tol(4) = Tol/10.; + gp_Pnt2d point1 = ElCLib::Value(Param1,C1); + gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); + gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine); + Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnLine,Ufirst(4)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + // gp_Vec2d Tan1,Tan2,Nor1,Nor2; + gp_Vec2d Tan1,Tan2,Nor2; + ElCLib::D2(Ufirst(1),C1,point1,Tan1,Nor2); + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); +#ifdef DEB + gp_Vec2d Tan3(OnLine.Direction().XY()); +#else + OnLine.Direction().XY(); +#endif + point3 = ElCLib::Value(Ufirst(1),OnLine); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan2 = Tan2.Magnitude(); + gp_Vec2d Vec1(point1,point3); + gp_Vec2d Vec2(point2,point3); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real angle2; + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + angle2 = Vec2.Angle(Tan2); + } + else { angle2 = 0.; } + Standard_Real dist = C1.Location().Distance(point3); + Standard_Real Rsol = cirsol.Radius(); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| + (Qualified1.IsOutside() && dist >= Rsol) || + (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&angle2<=0.)|| + (Qualified2.IsOutside() && angle2 >= 0) || + (Qualified2.IsEnclosed() && angle2 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pnttg1sol = point1; + pararg1 = Ufirst(1); + par1sol = ElCLib::Parameter(cirsol,pnttg1sol); + pnttg2sol = point2; + pararg2 = Ufirst(2); + par2sol = ElCLib::Parameter(cirsol,pnttg2sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const gp_Circ2d& OnCirc , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + gp_Dir2d dirx(1.,0.); + gp_Circ2d C1 = Qualified1.Qualified(); + Standard_Real R1 = C1.Radius(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + math_Vector Umin(1,4); + math_Vector Umax(1,4); + math_Vector Ufirst(1,4); + math_Vector tol(1,4); + Umin(1) = RealFirst(); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = RealFirst(); + Umin(4) = 0.; + Umax(1) = RealLast(); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = RealLast(); + Umax(4) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = 2.e-15*M_PI; + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = 2.e-15*M_PI; + tol(4) = Tol/10.; + gp_Pnt2d point1 = ElCLib::Value(Param1,C1); + gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); + gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc); + Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCirc,Ufirst(4)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + // gp_Vec2d Tan1,Tan2,Nor1; + gp_Vec2d Tan1,Tan2; + ElCLib::D1(Ufirst(1),C1,point1,Tan1); + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); +#ifdef DEB + gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3))); +#endif + point3 = ElCLib::Value(Ufirst(3),OnCirc); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan2 = Tan2.Magnitude(); + gp_Vec2d Vec1(point1,point3); + gp_Vec2d Vec2(point2,point3); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real angle2; + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + angle2 = Vec2.Angle(Tan2); + } + else { angle2 = 0.; } + Standard_Real dist = C1.Location().Distance(point3); + Standard_Real Rsol = cirsol.Radius(); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| + (Qualified1.IsOutside() && dist >= Rsol) || + (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&angle2<=0.)|| + (Qualified2.IsOutside() && angle2 >= 0) || + (Qualified2.IsEnclosed() && angle2 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pnttg1sol = point1; + pararg1 = Ufirst(1); + par1sol = ElCLib::Parameter(cirsol,pnttg1sol); + pnttg2sol = point2; + pararg2 = Ufirst(2); + par2sol = ElCLib::Parameter(cirsol,pnttg2sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const gp_Circ2d& OnCirc , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + gp_Dir2d dirx(1.,0.); + gp_Lin2d L1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + math_Vector Umin(1,4); + math_Vector Umax(1,4); + math_Vector Ufirst(1,4); + math_Vector tol(1,4); + Umin(1) = RealFirst(); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = RealFirst(); + Umin(4) = 0.; + Umax(1) = RealLast(); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = RealLast(); + Umax(4) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = 1.e-15; + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = 2.e-15*M_PI; + tol(4) = Tol/10.; + gp_Pnt2d point1 = ElCLib::Value(Param1,L1); + gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); + gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc); + Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCirc,Ufirst(4)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + gp_Pnt2d point1,point2; + gp_Vec2d Tan1,Tan2; + ElCLib::D1(Ufirst(1),L1,point1,Tan1); + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); +#ifdef DEB + gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3))); +#endif + point3 = ElCLib::Value(Ufirst(3),OnCirc); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan2 = Tan2.Magnitude(); + gp_Vec2d Vec1(point1,point3); + gp_Vec2d Vec2(point2,point3); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real angle2; + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + angle2 = Vec2.Angle(Tan2); + } + else { angle2 = 0.; } + Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(), + L1.Direction().X())); + if (Qualified1.IsUnqualified() || + (Qualified1.IsOutside() && pscal <= 0.) || + (Qualified1.IsEnclosed() && pscal >= 0.)) { + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&angle2<=0.)|| + (Qualified2.IsOutside() && angle2 >= 0) || + (Qualified2.IsEnclosed() && angle2 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pnttg1sol = point1; + pararg1 = Ufirst(1); + par1sol = ElCLib::Parameter(cirsol,pnttg1sol); + pnttg2sol = point2; + pararg2 = Ufirst(2); + par2sol = ElCLib::Parameter(cirsol,pnttg2sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const gp_Circ2d& OnCirc , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + gp_Dir2d dirx(1.,0.); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + math_Vector Umin(1,4); + math_Vector Umax(1,4); + math_Vector Ufirst(1,4); + math_Vector tol(1,4); + Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = RealFirst(); + Umin(4) = 0.; + Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = RealLast(); + Umax(4) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance)); + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = 2.e-15*M_PI; + tol(4) = Tol/10.; + gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1); + gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); + Standard_Real R1 = OnCirc.Radius(); + gp_Pnt2d point3(OnCirc.Location().XY()+R1*gp_XY(Cos(Param3),Sin(Param3))); + Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCirc,Ufirst(4)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + // gp_Vec2d Tan1,Tan2,Nor1; + gp_Vec2d Tan1,Tan2; + Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1); + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); +#ifdef DEB + gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3))); +#endif + point3 = gp_Pnt2d(OnCirc.Location().XY()+ + R1*gp_XY(Cos(Ufirst(3)),Sin(Ufirst(3)))); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + gp_Vec2d Vec1(point1,point3); + gp_Vec2d Vec2(point2,point3); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real angle1,angle2; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + angle1 = Vec1.Angle(Tan1); + } + else { angle1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + angle2 = Vec2.Angle(Tan2); + } + else { angle2 = 0.; } + if (Qualified1.IsUnqualified()|| + (Qualified1.IsEnclosing()&&angle1<=0.)|| + (Qualified1.IsOutside() && angle1 >= 0.) || + (Qualified1.IsEnclosed() && angle1 <= 0.)) { + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&angle2<=0.)|| + (Qualified2.IsOutside() && angle2 >= 0) || + (Qualified2.IsEnclosed() && angle2 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pararg1 = Ufirst(1); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(2); + pnttg2sol = point2; + par2sol = pnttg2sol.Distance(pnttg1sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , + const gp_Pnt2d& Point2 , + const gp_Circ2d& OnCirc , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Tolerance ) { + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + gp_Dir2d dirx(1.,0.); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Umin(2) = RealFirst(); + Umin(3) = 0.; + Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1); + Umax(2) = RealLast(); + Umax(3) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance)); + tol(2) = 2.e-15*M_PI; + tol(3) = Tol/10.; + gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1); + gp_Pnt2d point3 = ElCLib::Value(Param2,OnCirc); + Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCirc,Ufirst(3)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + gp_Pnt2d point1,point3; + gp_Vec2d Tan1,Tan3; + Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1); + ElCLib::D1(Ufirst(2),OnCirc,point3,Tan3); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(Point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan1 = Tan1.Magnitude(); + gp_Vec2d Vec1(point1,point3); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real angle1; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + angle1 = Vec1.Angle(Tan1); + } + else { angle1 = 0.; } + if (Qualified1.IsUnqualified()|| + (Qualified1.IsEnclosing()&&angle1<=0.)|| + (Qualified1.IsOutside() && angle1 >= 0.) || + (Qualified1.IsEnclosed() && angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = GccEnt_noqualifier; + pnttg1sol = point1; + pararg1 = Ufirst(1); + par1sol = ElCLib::Parameter(cirsol,pnttg1sol); + pnttg2sol = Point2; + pararg2 = 0.; + par2sol = ElCLib::Parameter(cirsol,pnttg2sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Dir2d dirx(1.,0.); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + math_Vector Umin(1,4); + math_Vector Umax(1,4); + math_Vector Ufirst(1,4); + math_Vector tol(1,4); + Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv); + Umin(4) = 0.; + Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv); + Umax(4) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance)); + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance)); + tol(4) = Tol/10.; + gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1); + gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); + gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,Param3); + Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCurv,Ufirst(4)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + gp_Vec2d Tan1,Tan2,Tan3; + Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1); + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); + Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + gp_Vec2d Vec1(point1,point3); + gp_Vec2d Vec2(point2,point3); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real angle1,angle2; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + angle1 = Vec1.Angle(Tan1); + } + else { angle1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + angle2 = Vec2.Angle(Tan2); + } + else { angle2 = 0.; } + if (Qualified1.IsUnqualified()|| + (Qualified1.IsEnclosing()&&angle1<=0.)|| + (Qualified1.IsOutside() && angle1 >= 0.) || + (Qualified1.IsEnclosed() && angle1 <= 0.)) { + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&angle2<=0.)|| + (Qualified2.IsOutside() && angle2 >= 0) || + (Qualified2.IsEnclosed() && angle2 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pararg1 = Ufirst(1); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(2); + pnttg2sol = point2; + par2sol = pnttg2sol.Distance(pnttg1sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real ParamOn , + const Standard_Real Tolerance ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + gp_Circ2d C1 = Qualified1.Qualified(); + Standard_Real R1 = C1.Radius(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + math_Vector Umin(1,4); + math_Vector Umax(1,4); + math_Vector Ufirst(1,4); + math_Vector tol(1,4); + Umin(1) = RealFirst(); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv); + Umin(4) = 0.; + Umax(1) = RealLast(); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv); + Umax(4) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = ParamOn; + tol(1) = 2.e-15*M_PI; + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance)); + tol(4) = Tol/10.;; + gp_Pnt2d point1 = ElCLib::Value(Param1,C1); + gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); + gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn); + Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCurv,Ufirst(4)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + gp_Vec2d Tan1,Tan2,Tan3; + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); + Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3); + ElCLib::D1(Ufirst(1),C1,point1,Tan1); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + gp_Dir2d dirx(1.,0.); + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan2 = Tan2.Magnitude(); + gp_Vec2d Vec1(point1.XY(),point3.XY()); + gp_Vec2d Vec2(point2.XY(),point3.XY()); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real angle2; + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + angle2 = Vec2.Angle(Tan2); + } + else { angle2 = 0.; } + Standard_Real dist = C1.Location().Distance(point3); + Standard_Real Rsol = cirsol.Radius(); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| + (Qualified1.IsOutside() && dist >= Rsol) || + (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&angle2<=0.)|| + (Qualified2.IsOutside() && angle2 >= 0) || + (Qualified2.IsEnclosed() && angle2 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pnttg1sol = point1; + pararg1 = Ufirst(1); + par1sol = ElCLib::Parameter(cirsol,pnttg1sol); + pnttg2sol = point2; + pararg2 = Ufirst(2); + par2sol = ElCLib::Parameter(cirsol,pnttg2sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real ParamOn , + const Standard_Real Tolerance ) { + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + gp_Dir2d dirx(1.,0.); + gp_Lin2d L1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + math_Vector Umin(1,4); + math_Vector Umax(1,4); + math_Vector Ufirst(1,4); + math_Vector tol(1,4); + Umin(1) = RealFirst(); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv); + Umin(4) = 0.; + Umax(1) = RealLast(); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv); + Umax(4) = RealLast(); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = ParamOn; + tol(1) = 1.e-15; + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance)); + tol(4) = Tol/10.; + gp_Pnt2d point1 = ElCLib::Value(Param1,L1); + gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); + gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn); + Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCurv,Ufirst(4)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + gp_Vec2d Tan1,Tan2,Tan3; + ElCLib::D1(Ufirst(1),L1,point1,Tan1); + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); + Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan2 = Tan2.Magnitude(); + gp_Vec2d Vec1(point1,point3); + gp_Vec2d Vec2(point2,point3); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real angle2; + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + angle2 = Vec2.Angle(Tan2); + } + else { angle2 = 0.; } + Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(), + L1.Direction().X())); + if (Qualified1.IsUnqualified() || + (Qualified1.IsOutside() && pscal <= 0.) || + (Qualified1.IsEnclosed() && pscal >= 0.)) { + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&angle2<=0.)|| + (Qualified2.IsOutside() && angle2 >= 0) || + (Qualified2.IsEnclosed() && angle2 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pnttg1sol = point1; + pararg1 = Ufirst(1); + par1sol = ElCLib::Parameter(cirsol,pnttg1sol); + pnttg2sol = point2; + pararg2 = Ufirst(2); + par2sol = ElCLib::Parameter(cirsol,pnttg2sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Circ2d2TanOnIter:: +Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , + const gp_Pnt2d& Point2 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Param1 , + const Standard_Real ParamOn , + const Standard_Real Tolerance ) +{ + TheSame1 = Standard_False; + TheSame2 = Standard_False; + par1sol = 0.; + par2sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + parcen3 = 0.; + + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + gp_Dir2d dirx(1.,0.); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Umin(2) = RealFirst(); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv); + Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1); + Umax(2) = RealLast(); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv); + Ufirst(1) = Param1; + Ufirst(2) = ParamOn; + tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance)); + tol(2) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance)); + tol(3) = Tol/10.; + gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1); + gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn); + Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.; + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCurv,Ufirst(3)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + Func.Value(Ufirst,Umin); + if (Root.IsDone()) { + Root.Root(Ufirst); + // gp_Vec2d Tan1,Tan2,Tan3; + gp_Vec2d Tan1,Tan3; + Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1); + Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3); + Standard_Real dist1 = point3.Distance(point1); + Standard_Real dist2 = point3.Distance(Point2); + if ( Abs(dist1-dist2)/2. <= Tol) { + cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.); + Standard_Real normetan1 = Tan1.Magnitude(); + gp_Vec2d Vec1(point1,point3); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real angle1; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + angle1 = Vec1.Angle(Tan1); + } + else { angle1 = 0.; } + if (Qualified1.IsUnqualified()|| + (Qualified1.IsEnclosing()&&angle1<=0.)|| + (Qualified1.IsOutside() && angle1 >= 0.) || + (Qualified1.IsEnclosed() && angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = GccEnt_noqualifier; + pnttg1sol = point1; + pararg1 = Ufirst(1); + par1sol = ElCLib::Parameter(cirsol,pnttg1sol); + pnttg2sol = Point2; + pararg2 = 0.; + par2sol = ElCLib::Parameter(cirsol,pnttg2sol); + pntcen = point3; + parcen3 = Ufirst(3); + WellDone = Standard_True; + } + } + } +} + +Standard_Boolean Geom2dGcc_Circ2d2TanOnIter:: +IsDone () const{ return WellDone; } + +gp_Circ2d Geom2dGcc_Circ2d2TanOnIter:: +ThisSolution () const{ return cirsol; } + +void Geom2dGcc_Circ2d2TanOnIter:: +WhichQualifier (GccEnt_Position& Qualif1 , + GccEnt_Position& Qualif2 ) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + Qualif1 = qualifier1; + Qualif2 = qualifier2; + } +} + +void Geom2dGcc_Circ2d2TanOnIter:: +Tangency1 (Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& PntSol ) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + if (TheSame1 == 0) { + ParSol = 0; + ParArg = 0; + PntSol = pnttg1sol; + } + else { StdFail_NotDone::Raise(); } + } +} + +void Geom2dGcc_Circ2d2TanOnIter:: +Tangency2 (Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& PntSol ) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + ParSol = 0; + ParArg = 0; + PntSol = pnttg2sol; + } +} + +void Geom2dGcc_Circ2d2TanOnIter:: +CenterOn3 (Standard_Real& ParArg , + gp_Pnt2d& PntSol ) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + ParArg = 0; + PntSol = pntcen; + } +} + +Standard_Boolean Geom2dGcc_Circ2d2TanOnIter:: +IsTheSame1 () const +{ + if (!WellDone) StdFail_NotDone::Raise(); + + if (TheSame1 == 0) + return Standard_False; + return Standard_True; +} + + +Standard_Boolean Geom2dGcc_Circ2d2TanOnIter:: +IsTheSame2 () const +{ + if (!WellDone) StdFail_NotDone::Raise(); + return Standard_False; +} diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cdl index 64512fee2f..2c83d664a0 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cdl @@ -47,7 +47,7 @@ uses QualifiedCurve from Geom2dGcc, Array1OfReal from TColStd, Circ2d3Tan from GccAna, Point from Geom2d, - MyC2d3Tan from Geom2dGcc, + Circ2d3TanIter from Geom2dGcc, Position from GccEnt, Array1OfPosition from GccEnt @@ -316,9 +316,4 @@ fields ---Purpose: The parameter of the tangency point between the solution and the third -- argument on the second argument. - --- CircAna : Circ2d2TanOn from GccAna; --- CircIter : Circ2d2TanOn from GccIter; --- TypeAna : Boolean; - end Circ2d3Tan; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx index 356a400cab..f97f1b3613 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -215,7 +215,7 @@ Geom2dGcc_Circ2d3Tan:: Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); Geom2dGcc_QCurve Qc2(C2,Qualified2.Qualifier()); Geom2dGcc_QCurve Qc3(C3,Qualified3.Qualifier()); - Geom2dGcc_MyC2d3Tan Circ(Qc1,Qc2,Qc3,Param1,Param2,Param3,Tolerance); + Geom2dGcc_Circ2d3TanIter Circ(Qc1,Qc2,Qc3,Param1,Param2,Param3,Tolerance); WellDone = Circ.IsDone(); NbrSol = 1; if (WellDone) { @@ -334,7 +334,7 @@ Geom2dGcc_Circ2d3Tan:: else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); Geom2dGcc_QCurve Qc2(C2,Qualified2.Qualifier()); - Geom2dGcc_MyC2d3Tan Circ(Qc1,Qc2,Point->Pnt2d(),Param1,Param2,Tolerance); + Geom2dGcc_Circ2d3TanIter Circ(Qc1,Qc2,Point->Pnt2d(),Param1,Param2,Tolerance); WellDone = Circ.IsDone(); NbrSol = 1; if (WellDone) { @@ -413,7 +413,7 @@ Geom2dGcc_Circ2d3Tan:: } else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); - Geom2dGcc_MyC2d3Tan Circ(Qc1,Point1->Pnt2d(),Point2->Pnt2d(), + Geom2dGcc_Circ2d3TanIter Circ(Qc1,Point1->Pnt2d(),Point2->Pnt2d(), Param1,Tolerance); WellDone = Circ.IsDone(); NbrSol = 1; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d3TanIter.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2d3TanIter.cdl new file mode 100644 index 0000000000..e01465d5a0 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d3TanIter.cdl @@ -0,0 +1,315 @@ +-- Created on: 1991-03-29 +-- Created by: Remi GILET +-- Copyright (c) 1991-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. + +class Circ2d3TanIter from Geom2dGcc + + ---Purpose: This class implements the algorithms used to + -- create 2d circles tangent to 3 points/lines/circles/ + -- curves with one curve or more. + -- The arguments of all construction methods are : + -- - The three qualifiied elements for the + -- tangency constrains (QualifiedCirc, QualifiedLine, + -- Qualifiedcurv, Points). + -- - A parameter for each QualifiedCurv. + +-- inherits Entity from Standard + +uses Pnt2d from gp, + Lin2d from gp, + Circ2d from gp, + QualifiedCirc from GccEnt, + QualifiedLin from GccEnt, + Position from GccEnt, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + QCurve from Geom2dGcc + +raises NotDone from StdFail + +is + +Create(Qualified1 : QualifiedCirc from GccEnt ; + Qualified2 : QualifiedCirc from GccEnt ; + Qualified3 : QCurve from Geom2dGcc; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) +returns Circ2d3TanIter from Geom2dGcc; + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to 2 circles and a curve. + +Create(Qualified1 : QualifiedCirc from GccEnt ; + Qualified2 : QCurve from Geom2dGcc; + Qualified3 : QCurve from Geom2dGcc; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) +returns Circ2d3TanIter from Geom2dGcc; + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to a circle and 2 curves. + +Create(Qualified1 : QualifiedCirc from GccEnt ; + Qualified2 : QualifiedLin from GccEnt ; + Qualified3 : QCurve from Geom2dGcc; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) +returns Circ2d3TanIter from Geom2dGcc; + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to a circle and a line and + -- a curve. + +Create(Qualified1 : QualifiedCirc from GccEnt ; + Qualified2 : QCurve from Geom2dGcc; + Point3 : Pnt2d ; + Param1 : Real ; + Param2 : Real ; + Tolerance : Real ) +returns Circ2d3TanIter from Geom2dGcc; + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to a circle and a point and + -- a curve. + +Create(Qualified1 : QualifiedLin from GccEnt ; + Qualified2 : QualifiedLin from GccEnt ; + Qualified3 : QCurve from Geom2dGcc; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) +returns Circ2d3TanIter from Geom2dGcc; + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to 2 lines and a curve. + +Create(Qualified1 : QualifiedLin from GccEnt ; + Qualified2 : QCurve from Geom2dGcc; + Qualified3 : QCurve from Geom2dGcc; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) +returns Circ2d3TanIter from Geom2dGcc; + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to a line and 2 curves. + +Create(Qualified1 : QualifiedLin from GccEnt ; + Qualified2 : QCurve from Geom2dGcc; + Point3 : Pnt2d ; + Param1 : Real ; + Param2 : Real ; + Tolerance : Real ) +returns Circ2d3TanIter from Geom2dGcc; + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to a line and a curve + -- and a point. + +Create(Qualified1 : QCurve from Geom2dGcc; + Point1 : Pnt2d ; + Point2 : Pnt2d ; + Param1 : Real ; + Tolerance : Real ) +returns Circ2d3TanIter from Geom2dGcc; + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to a curve and 2 points. + +Create(Qualified1 : QCurve from Geom2dGcc ; + Qualified2 : QCurve from Geom2dGcc ; + Point2 : Pnt2d ; + Param1 : Real ; + Param2 : Real ; + Tolerance : Real ) +returns Circ2d3TanIter from Geom2dGcc; + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to 2 curves and a point. + +Create(Qualified1 : QCurve from Geom2dGcc ; + Qualified2 : QCurve from Geom2dGcc ; + Qualified3 : QCurve from Geom2dGcc ; + Param1 : Real ; + Param2 : Real ; + Param3 : Real ; + Tolerance : Real ) +returns Circ2d3TanIter from Geom2dGcc; + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to 3 curves. + +-- -- .................................................................... + +IsDone(me) returns Boolean +is static; + ---Purpose: This method returns True if the construction + -- algorithm succeeded. + +ThisSolution(me) returns Circ2d + ---Purpose: Returns the solution. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +WhichQualifier(me ; + Qualif1 : out Position from GccEnt; + Qualif2 : out Position from GccEnt; + Qualif3 : out Position from GccEnt) +raises NotDone from StdFail +is static; + -- It returns the informations about the qualifiers of the tangency + -- arguments concerning the solution number Index. + -- It returns the real qualifiers (the qualifiers given to the + -- constructor method in case of enclosed, enclosing and outside + -- and the qualifiers computedin case of unqualified). + +Tangency1(me ; + ParSol,ParArg : out Real ; + PntSol : out Pnt2d) + ---Purpose: Returns informations about the tangency point between + -- the result and the first argument. + -- ParSol is the intrinsic parameter of the point PntSol + -- on the solution curv. + -- ParArg is the intrinsic parameter of the point PntSol + -- on the argument curv. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +Tangency2(me ; + ParSol,ParArg : out Real ; + PntSol : out Pnt2d) + ---Purpose: Returns informations about the tangency point between + -- the result and the second argument. + -- ParSol is the intrinsic parameter of the point PntSol + -- on the solution curv. + -- ParArg is the intrinsic parameter of the point PntSol + -- on the argument curv. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +Tangency3(me ; + ParSol,ParArg : out Real ; + PntSol : out Pnt2d) + ---Purpose: Returns informations about the tangency point between + -- the result and the third argument. + -- ParSol is the intrinsic parameter of the point PntSol + -- on the solution curv. + -- ParArg is the intrinsic parameter of the point PntSol + -- on the argument curv. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +IsTheSame1(me) returns Boolean + -- Returns True if the solution is equal to the first argument. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +IsTheSame2(me) returns Boolean + -- Returns True if the solution is equal to the second argument. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +IsTheSame3(me) returns Boolean + -- Returns True if the solution is equal to the third argument. +raises NotDone from StdFail +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +fields + + WellDone : Boolean; + ---Purpose: True if the algorithm succeeded. + + cirsol : Circ2d; + ---Purpose: The solutions. + + qualifier1 : Position from GccEnt; + -- The qualifiers of the first argument. + + qualifier2 : Position from GccEnt; + -- The qualifiers of the first argument. + + qualifier3 : Position from GccEnt; + -- The qualifiers of the first argument. + + TheSame1 : Boolean; + ---Purpose: True if the solution and the first argument are identical. + -- Two circles are identical if the difference between the + -- radius of one and the sum of the radius of the other and + -- the distance between the centers is less than Tolerance. + -- False in the other cases. + + TheSame2 : Boolean; + ---Purpose: True if the solution and the second argument are identical. + -- Two circles are identical if the difference between the + -- radius of one and the sum of the radius of the other and + -- the distance between the centers is less than Tolerance. + -- False in the other cases. + + TheSame3 : Boolean; + ---Purpose: True if the solution and the third argument are identical. + -- Two circles are identical if the difference between the + -- radius of one and the sum of the radius of the other and + -- the distance between the centers is less than Tolerance. + -- False in the other cases. + + pnttg1sol : Pnt2d; + ---Purpose: The tangency point between the solution and the first + -- argument on the solution. + + pnttg2sol : Pnt2d; + ---Purpose: The tangency point between the solution and the second + -- argument on the solution. + + pnttg3sol : Pnt2d; + ---Purpose: The tangency point between the solution and the third + -- argument on the solution. + + par1sol : Real; + ---Purpose: The parameter of the tangency point between the solution + -- and the first argument on the solution. + + par2sol : Real; + ---Purpose: The parameter of the tangency point between the solution + -- and the second argument on the solution. + + par3sol : Real; + ---Purpose: The parameter of the tangency point between the solution + -- and the third argument on the solution. + + pararg1 : Real; + ---Purpose: The parameter of the tangency point between the solution + -- and the first argument on the first argument. + + pararg2 : Real; + ---Purpose: The parameter of the tangency point between the solution + -- and the second argument on the second argument. + + pararg3 : Real; + ---Purpose: The parameter of the tangency point between the solution + -- and the third argument on the second argument. + +end Circ2d3TanIter; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d3TanIter.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d3TanIter.cxx new file mode 100644 index 0000000000..f50338005a --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d3TanIter.cxx @@ -0,0 +1,1356 @@ +// Created on: 1991-12-13 +// Created by: Remi GILET +// Copyright (c) 1991-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. + +//========================================================================= +// Creation d un cercle tangent a deux elements : Droite. + +// Cercle. + +// Point. + +// Courbes. + +// centre sur un troisieme : Droite. + +// Cercle. + +// Courbes. + +//========================================================================= + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +Geom2dGcc_Circ2d3TanIter:: +Geom2dGcc_Circ2d3TanIter (const Geom2dGcc_QCurve& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const Geom2dGcc_QCurve& Qualified3 , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + TheSame3 = Standard_False; + par1sol = 0.; + par2sol = 0.; + par3sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + pararg3 = 0.; + + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified()) || + !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || + Qualified3.IsOutside() || Qualified3.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + Geom2dAdaptor_Curve Cu3 = Qualified3.Qualified(); + Geom2dGcc_FunctionTanCuCuCu Func(Cu1,Cu2,Cu3); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(Cu3); + Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(Cu3); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance)); + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = Geom2dGcc_CurveTool::EpsX(Cu3,Abs(Tolerance)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Root.Root(Ufirst); + Func.Value(Ufirst,Umin); + gp_Pnt2d point1,point2,point3; + gp_Vec2d Tan1,Tan2,Tan3; + Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1); + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); + Geom2dGcc_CurveTool::D1(Cu3,Ufirst(3),point3,Tan3); + GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); + if (circ.IsDone()) { + cirsol = circ.ThisSolution(1); + gp_Pnt2d centre = cirsol.Location(); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + Standard_Real normetan3 = Tan3.Magnitude(); + gp_Vec2d Vec1(point1,centre); + gp_Vec2d Vec2(point2,centre); + gp_Vec2d Vec3(point3,centre); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real normevec3 = Vec3.Magnitude(); + Standard_Real dot1,dot2,dot3; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); + } + else { dot1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); + } + else { dot2 = 0.; } + if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { + dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); + } + else { dot3 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { + Standard_Real Angle1 = Vec1.Angle(Tan1); + if (Qualified1.IsUnqualified()|| + (Qualified1.IsEnclosing()&&Angle1<=0.)|| + (Qualified1.IsOutside() && Angle1 >= 0.) || + (Qualified1.IsEnclosed() && Angle1 <= 0.)) { + Angle1 = Vec2.Angle(Tan2); + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&Angle1<=0.)|| + (Qualified2.IsOutside() && Angle1 >= 0) || + (Qualified2.IsEnclosed() && Angle1 <= 0.)) { + Angle1 = Vec3.Angle(Tan3); + if (Qualified3.IsUnqualified() || + (Qualified3.IsEnclosing()&&Angle1<=0.)|| + (Qualified3.IsOutside() && Angle1 >= 0) || + (Qualified3.IsEnclosed() && Angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + qualifier3 = Qualified3.Qualifier(); + pararg1 = Ufirst(1); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(2); + pnttg2sol = point2; + par2sol = pnttg2sol.Distance(pnttg1sol); + pnttg3sol = point3; + pararg3 = Ufirst(3); + par3sol = pnttg3sol.Distance(pnttg1sol); + WellDone = Standard_True; + } + } + } + } + } + } +} + +Geom2dGcc_Circ2d3TanIter:: +Geom2dGcc_Circ2d3TanIter (const GccEnt_QualifiedCirc& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const Geom2dGcc_QCurve& Qualified3 , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + TheSame3 = Standard_False; + par1sol = 0.; + par2sol = 0.; + par3sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + pararg3 = 0.; + + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified()) || + !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || + Qualified3.IsOutside() || Qualified3.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Circ2d C1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + Geom2dAdaptor_Curve Cu3 = Qualified3.Qualified(); + Geom2dGcc_FunctionTanCuCuCu Func(C1,Cu2,Cu3); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = 0.; + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(Cu3); + Umax(1) = 2*M_PI; + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(Cu3); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = 2.e-15*M_PI; + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = Geom2dGcc_CurveTool::EpsX(Cu3,Abs(Tolerance)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Root.Root(Ufirst); + Func.Value(Ufirst,Umin); + gp_Pnt2d centre1(C1.Location()); + Standard_Real R1 = C1.Radius(); + gp_Pnt2d point1(centre1.XY()+R1*gp_XY(Cos(Ufirst(1)),Sin(Ufirst(1)))); + gp_Vec2d Tan1(gp_XY(-Sin(Ufirst(1)),Cos(Ufirst(1)))); + gp_Pnt2d point2,point3; + // gp_Vec2d Tan2,Tan3,Nor2,Nor3; + gp_Vec2d Tan2,Tan3; + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); + Geom2dGcc_CurveTool::D1(Cu3,Ufirst(3),point3,Tan3); + GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); + if (circ.IsDone()) { + cirsol = circ.ThisSolution(1); + gp_Pnt2d centre(cirsol.Location()); + Standard_Real dist = centre1.Distance(centre); + Standard_Real Rsol = cirsol.Radius(); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + Standard_Real normetan3 = Tan3.Magnitude(); + gp_Vec2d Vec1(point1,centre); + gp_Vec2d Vec2(point2,centre); + gp_Vec2d Vec3(point3,centre); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real normevec3 = Vec3.Magnitude(); + Standard_Real dot1,dot2,dot3; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); + } + else { dot1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); + } + else { dot2 = 0.; } + if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { + dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); + } + else { dot3 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| + (Qualified1.IsOutside() && dist >= Rsol) || + (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { + Standard_Real Angle1 = Vec2.Angle(Tan2); + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&Angle1<=0.)|| + (Qualified2.IsOutside() && Angle1 >= 0) || + (Qualified2.IsEnclosed() && Angle1 <= 0.)) { + Angle1 = Vec3.Angle(Tan3); + if (Qualified3.IsUnqualified() || + (Qualified3.IsEnclosing()&&Angle1<=0.)|| + (Qualified3.IsOutside() && Angle1 >= 0) || + (Qualified3.IsEnclosed() && Angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + qualifier3 = Qualified3.Qualifier(); + pararg1 = Ufirst(1); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(2); + pnttg2sol = point2; + par2sol = 0.; + pararg3 = Ufirst(3); + pnttg3sol = point3; + par3sol = 0.; + WellDone = Standard_True; + } + } + } + } + } + } +} + +Geom2dGcc_Circ2d3TanIter:: +Geom2dGcc_Circ2d3TanIter (const GccEnt_QualifiedCirc& Qualified1 , + const GccEnt_QualifiedCirc& Qualified2 , + const Geom2dGcc_QCurve& Qualified3 , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + TheSame3 = Standard_False; + par1sol = 0.; + par2sol = 0.; + par3sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + pararg3 = 0.; + + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified()) || + !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || + Qualified3.IsOutside() || Qualified3.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Circ2d C1 = Qualified1.Qualified(); + gp_Circ2d C2 = Qualified2.Qualified(); + Geom2dAdaptor_Curve Cu3 = Qualified3.Qualified(); + Geom2dGcc_FunctionTanCuCuCu Func(C1,C2,Cu3); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = 0.; + Umin(2) = 0.; + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(Cu3); + Umax(1) = 2*M_PI; + Umax(2) = 2*M_PI; + Umax(3) = Geom2dGcc_CurveTool::LastParameter(Cu3); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = 2.e-15*M_PI; + tol(2) = 2.e-15*M_PI; + tol(3) = Geom2dGcc_CurveTool::EpsX(Cu3,Abs(Tolerance)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Root.Root(Ufirst); + Func.Value(Ufirst,Umin); + gp_Pnt2d centre1(C1.Location()); + Standard_Real R1 = C1.Radius(); + gp_Pnt2d point1(centre1.XY()+R1*gp_XY(Cos(Ufirst(1)),Sin(Ufirst(1)))); + gp_Vec2d Tan1(gp_XY(-Sin(Ufirst(1)),Cos(Ufirst(1)))); + gp_Pnt2d centre2(C2.Location()); + Standard_Real R2 = C2.Radius(); + gp_Pnt2d point2(centre2.XY()+R2*gp_XY(Cos(Ufirst(2)),Sin(Ufirst(2)))); + gp_Vec2d Tan2(gp_XY(-Sin(Ufirst(2)),Cos(Ufirst(2)))); + gp_Pnt2d point3; + gp_Vec2d Tan3; + Geom2dGcc_CurveTool::D1(Cu3,Ufirst(3),point3,Tan3); + GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); + if (circ.IsDone()) { + cirsol = circ.ThisSolution(1); + gp_Pnt2d centre(cirsol.Location()); + Standard_Real dist = centre1.Distance(centre); + Standard_Real Rsol = cirsol.Radius(); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + Standard_Real normetan3 = Tan3.Magnitude(); + gp_Vec2d Vec1(point1,centre); + gp_Vec2d Vec2(point2,centre); + gp_Vec2d Vec3(point3,centre); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real normevec3 = Vec3.Magnitude(); + Standard_Real dot1,dot2,dot3; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); + } + else { dot1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); + } + else { dot2 = 0.; } + if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { + dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); + } + else { dot3 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| + (Qualified1.IsOutside() && dist >= Rsol) || + (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { + dist = centre2.Distance(centre); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && Rsol >= R2 && dist <= Rsol)|| + (Qualified1.IsOutside() && dist >= Rsol) || + (Qualified1.IsEnclosed() && Rsol <= R2 && dist <= Rsol)) { + gp_Vec2d Vec(point3,centre); + Standard_Real Angle1 = Vec.Angle(Tan3); + if (Qualified3.IsUnqualified() || + (Qualified3.IsEnclosing()&&Angle1<=0.)|| + (Qualified3.IsOutside() && Angle1 >= 0) || + (Qualified3.IsEnclosed() && Angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + qualifier3 = Qualified3.Qualifier(); + pararg1 = Ufirst(1); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(2); + pnttg2sol = point2; + par2sol = 0.; + pararg3 = Ufirst(3); + pnttg3sol = point3; + par3sol = 0.; + WellDone = Standard_True; + } + } + } + } + } + } +} + +Geom2dGcc_Circ2d3TanIter:: +Geom2dGcc_Circ2d3TanIter (const GccEnt_QualifiedLin& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const Geom2dGcc_QCurve& Qualified3 , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + TheSame3 = Standard_False; + par1sol = 0.; + par2sol = 0.; + par3sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + pararg3 = 0.; + + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified()) || + !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || + Qualified3.IsOutside() || Qualified3.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Lin2d L1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + Geom2dAdaptor_Curve Cu3 = Qualified3.Qualified(); + Geom2dGcc_FunctionTanCuCuCu Func(L1,Cu2,Cu3); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = RealFirst(); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(Cu3); + Umax(1) = RealLast(); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(Cu3); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = 1.e-15; + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + tol(3) = Geom2dGcc_CurveTool::EpsX(Cu3,Abs(Tolerance)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Root.Root(Ufirst); + Func.Value(Ufirst,Umin); + gp_Pnt2d centre1(L1.Location()); + gp_Pnt2d point1(centre1.XY()+Ufirst(1)*L1.Direction().XY()); + gp_Pnt2d point2,point3; + gp_Vec2d Tan2,Tan3; + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); + Geom2dGcc_CurveTool::D1(Cu3,Ufirst(3),point3,Tan3); + GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); + if (circ.IsDone()) { + cirsol = circ.ThisSolution(1); + gp_Pnt2d centre(cirsol.Location()); + + // creation vaariables intermediaires pour WNT + gp_XY dummy1 = centre.XY()-L1.Location().XY(); + gp_XY dummy2 (-L1.Direction().Y(),L1.Direction().X()); + Standard_Real pscal=dummy1.Dot(dummy2); + + gp_Vec2d Tan1(L1.Direction().XY()); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + Standard_Real normetan3 = Tan3.Magnitude(); + gp_Vec2d Vec1(point1,centre); + gp_Vec2d Vec2(point2,centre); + gp_Vec2d Vec3(point3,centre); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real normevec3 = Vec3.Magnitude(); + Standard_Real dot1,dot2,dot3; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); + } + else { dot1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); + } + else { dot2 = 0.; } + if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { + dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); + } + else { dot3 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { + if (Qualified1.IsUnqualified() || + (Qualified1.IsOutside() && pscal <= 0.) || + (Qualified1.IsEnclosed() && pscal >= 0.)) { + gp_Vec2d Vec(point2,centre); + Standard_Real Angle1 = Vec.Angle(Tan2); + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&Angle1<=0.)|| + (Qualified2.IsOutside() && Angle1 >= 0) || + (Qualified2.IsEnclosed() && Angle1 <= 0.)) { + Vec = gp_Vec2d(point3,centre); + Angle1 = Vec.Angle(Tan3); + if (Qualified3.IsUnqualified() || + (Qualified3.IsEnclosing()&&Angle1<=0.)|| + (Qualified3.IsOutside() && Angle1 >= 0) || + (Qualified3.IsEnclosed() && Angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + qualifier3 = Qualified3.Qualifier(); + pararg1 = Ufirst(1); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(2); + pnttg2sol = point2; + par2sol = 0.; + pararg3 = Ufirst(3); + pnttg3sol = point3; + par3sol = 0.; + WellDone = Standard_True; + } + } + } + } + } + } +} + +Geom2dGcc_Circ2d3TanIter:: +Geom2dGcc_Circ2d3TanIter (const GccEnt_QualifiedLin& Qualified1 , + const GccEnt_QualifiedLin& Qualified2 , + const Geom2dGcc_QCurve& Qualified3 , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ){ + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + TheSame3 = Standard_False; + par1sol = 0.; + par2sol = 0.; + par3sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + pararg3 = 0.; + + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || + Qualified2.IsOutside() || Qualified2.IsUnqualified()) || + !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || + Qualified3.IsOutside() || Qualified3.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Lin2d L1 = Qualified1.Qualified(); + gp_Lin2d L2 = Qualified2.Qualified(); + Geom2dAdaptor_Curve Cu3 = Qualified3.Qualified(); + Geom2dGcc_FunctionTanCuCuCu Func(L1,L2,Cu3); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = RealFirst(); + Umin(2) = RealFirst(); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(Cu3); + Umax(1) = RealLast(); + Umax(2) = RealLast(); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(Cu3); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = 1.e-15; + tol(2) = 1.e-15; + tol(3) = Geom2dGcc_CurveTool::EpsX(Cu3,Abs(Tolerance)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Root.Root(Ufirst); + Func.Value(Ufirst,Umin); + gp_Pnt2d centre1(L1.Location()); + gp_Pnt2d point1(centre1.XY()+Ufirst(1)*L1.Direction().XY()); + gp_Pnt2d centre2(L2.Location()); + gp_Pnt2d point2(centre2.XY()+Ufirst(2)*L2.Direction().XY()); + gp_Pnt2d point3; + gp_Vec2d Tan3; + Geom2dGcc_CurveTool::D1(Cu3,Ufirst(3),point3,Tan3); + GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); + if (circ.IsDone()) { + cirsol = circ.ThisSolution(1); + gp_Pnt2d centre(cirsol.Location()); + Standard_Real pscal=centre.XY().Dot(gp_XY(-L1.Direction().Y(), + L1.Direction().X())); + if (Qualified1.IsUnqualified() || + (Qualified1.IsOutside() && pscal <= 0.) || + (Qualified1.IsEnclosed() && pscal >= 0.)) { + Standard_Real pscal=centre.XY().Dot(gp_XY(-L1.Direction().Y(), + L1.Direction().X())); + gp_Vec2d Tan1(L1.Direction().XY()); + gp_Vec2d Tan2(L2.Direction().XY()); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + Standard_Real normetan3 = Tan3.Magnitude(); + gp_Vec2d Vec1(point1,centre); + gp_Vec2d Vec2(point2,centre); + gp_Vec2d Vec3(point3,centre); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real normevec3 = Vec3.Magnitude(); + Standard_Real dot1,dot2,dot3; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); + } + else { dot1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); + } + else { dot2 = 0.; } + if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { + dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); + } + else { dot3 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { + if (Qualified2.IsUnqualified() || + (Qualified2.IsOutside() && pscal <= 0.) || + (Qualified2.IsEnclosed() && pscal >= 0.)) { + Standard_Real Angle1 = Vec3.Angle(Tan3); + if (Qualified3.IsUnqualified() || + (Qualified3.IsEnclosing()&&Angle1<=0.)|| + (Qualified3.IsOutside() && Angle1 >= 0) || + (Qualified3.IsEnclosed() && Angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + qualifier3 = Qualified3.Qualifier(); + pararg1 = Ufirst(1); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(2); + pnttg2sol = point2; + par2sol = 0.; + pararg3 = Ufirst(3); + pnttg3sol = point3; + par3sol = 0.; + WellDone = Standard_True; + } + } + } + } + } + } +} + +Geom2dGcc_Circ2d3TanIter:: +Geom2dGcc_Circ2d3TanIter (const Geom2dGcc_QCurve& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const gp_Pnt2d& Point3 , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Tolerance ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + TheSame3 = Standard_False; + par1sol = 0.; + par2sol = 0.; + par3sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + pararg3 = 0.; + + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Circ2d C1(gp_Ax2d(Point3,gp_Dir2d(1.,0.)),0.); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + Geom2dGcc_FunctionTanCuCuCu Func(C1,Cu1,Cu2); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = 0.; + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umax(1) = 2*M_PI; + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu1); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Ufirst(1) = M_PI; + Ufirst(2) = Param1; + Ufirst(3) = Param2; + tol(1) = 2.e-15*M_PI; + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance)); + tol(3) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Root.Root(Ufirst); + Func.Value(Ufirst,Umin); + gp_Pnt2d point1,point2; + // gp_Vec2d Tan1,Tan2,Nor1,Nor2; + gp_Vec2d Tan1,Tan2; + Geom2dGcc_CurveTool::D1(Cu1,Ufirst(2),point1,Tan1); + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(3),point2,Tan2); + GccAna_Circ2d3Tan circ(Point3,point1,point2,Tol); + if (circ.IsDone()) { + cirsol = circ.ThisSolution(1); + gp_Pnt2d centre(cirsol.Location()); + gp_Vec2d Tan3(-Sin(Ufirst(1)),Cos(Ufirst(1))); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + Standard_Real normetan3 = Tan3.Magnitude(); + gp_Vec2d Vec1(point1,centre); + gp_Vec2d Vec2(point2,centre); + gp_Vec2d Vec3(Point3,centre); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real normevec3 = Vec3.Magnitude(); + Standard_Real dot1,dot2,dot3; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); + } + else { dot1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); + } + else { dot2 = 0.; } + if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { + dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); + } + else { dot3 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { + Standard_Real Angle1 = Vec1.Angle(Tan1); + if (Qualified1.IsUnqualified()|| + (Qualified1.IsEnclosing()&&Angle1<=0.)|| + (Qualified1.IsOutside() && Angle1 >= 0) || + (Qualified1.IsEnclosed() && Angle1 <= 0.)) { + Angle1 = Vec2.Angle(Tan2); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing()&&Angle1<=0.)|| + (Qualified1.IsOutside() && Angle1 >= 0) || + (Qualified1.IsEnclosed() && Angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + qualifier3 = GccEnt_noqualifier; + pararg1 = Ufirst(2); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(3); + pnttg2sol = point2; + par2sol = 0.; + pararg3 = 0.; + pnttg3sol = Point3; + par3sol = 0.; + WellDone = Standard_True; + } + } + } + } + } +} + +Geom2dGcc_Circ2d3TanIter:: +Geom2dGcc_Circ2d3TanIter (const Geom2dGcc_QCurve& Qualified1 , + const gp_Pnt2d& Point2 , + const gp_Pnt2d& Point3 , + const Standard_Real Param1 , + const Standard_Real Tolerance ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + TheSame3 = Standard_False; + par1sol = 0.; + par2sol = 0.; + par3sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + pararg3 = 0.; + + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Dir2d dirx(1.,0.); + gp_Circ2d C1(gp_Ax2d(Point2,dirx),0.); + gp_Circ2d C2(gp_Ax2d(Point3,dirx),0.); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + Geom2dGcc_FunctionTanCuCuCu Func(C1,C2,Cu1); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = 0.; + Umin(2) = 0.; + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Umax(1) = 2*M_PI; + Umax(2) = 2*M_PI; + Umax(3) = Geom2dGcc_CurveTool::LastParameter(Cu1); + Ufirst(1) = M_PI; + Ufirst(2) = M_PI; + Ufirst(3) = Param1; + tol(1) = 2.e-15*M_PI; + tol(2) = 2.e-15*M_PI; + tol(3) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Root.Root(Ufirst); + Func.Value(Ufirst,Umin); + gp_Pnt2d point3; + // gp_Vec2d Tan3,Nor3; + gp_Vec2d Tan3; + Geom2dGcc_CurveTool::D1(Cu1,Ufirst(3),point3,Tan3); + GccAna_Circ2d3Tan circ(Point2,Point3,point3,Tol); + if (circ.IsDone()) { + cirsol = circ.ThisSolution(1); + gp_Pnt2d centre(cirsol.Location()); + gp_Vec2d Tan2(-Sin(Ufirst(2)),Cos(Ufirst(2))); + gp_Vec2d Tan1(-Sin(Ufirst(1)),Cos(Ufirst(1))); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + Standard_Real normetan3 = Tan3.Magnitude(); + gp_Vec2d Vec1(Point2,centre); + gp_Vec2d Vec2(Point3,centre); + gp_Vec2d Vec3(point3,centre); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real normevec3 = Vec3.Magnitude(); + Standard_Real dot1,dot2,dot3; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); + } + else { dot1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); + } + else { dot2 = 0.; } + if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { + dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); + } + else { dot3 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { + Standard_Real Angle1 = Vec1.Angle(Tan1); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing()&&Angle1<=0.)|| + (Qualified1.IsOutside() && Angle1 >= 0) || + (Qualified1.IsEnclosed() && Angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = GccEnt_noqualifier; + qualifier3 = GccEnt_noqualifier; + pararg1 = Ufirst(3); + par1sol = 0.; + pnttg1sol = point3; + pararg2 = 0.; + pnttg2sol = Point2; + par2sol = 0.; + pararg3 = 0.; + pnttg3sol = Point3; + par3sol = 0.; + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Circ2d3TanIter:: +Geom2dGcc_Circ2d3TanIter (const GccEnt_QualifiedLin& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const gp_Pnt2d& Point3 , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Tolerance ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + TheSame3 = Standard_False; + par1sol = 0.; + par2sol = 0.; + par3sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + pararg3 = 0.; + + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Dir2d dirx(1.,0.); + gp_Lin2d L1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + gp_Circ2d C3(gp_Ax2d(Point3,dirx),0.); + Geom2dGcc_FunctionTanCuCuCu Func(C3,L1,Cu2); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(2) = RealFirst(); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(1) = 0.; + Umax(2) = RealLast(); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(1) = 2*M_PI; + Ufirst(2) = Param1; + Ufirst(3) = Param2; + Ufirst(1) = M_PI; + tol(1) = 2.e-15; + tol(2) = 1.e-15; + tol(3) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Root.Root(Ufirst); + Func.Value(Ufirst,Umin); + gp_Pnt2d centre1(L1.Location()); + gp_Pnt2d point1(centre1.XY()+Ufirst(2)*L1.Direction().XY()); + gp_Pnt2d point2; + gp_Vec2d Tan2; + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); + GccAna_Circ2d3Tan circ(point1,point2,Point3,Tol); + if (circ.IsDone()) { + cirsol = circ.ThisSolution(1); + gp_Pnt2d centre(cirsol.Location()); + Standard_Real pscal=centre.XY().Dot(gp_XY(-L1.Direction().Y(), + L1.Direction().X())); + gp_Vec2d Tan1(L1.Direction().XY()); + gp_Vec2d Tan3(-Sin(Ufirst(1)),Cos(Ufirst(1))); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + Standard_Real normetan3 = Tan3.Magnitude(); + gp_Vec2d Vec1(point1,centre); + gp_Vec2d Vec2(point2,centre); + gp_Vec2d Vec3(Point3,centre); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real normevec3 = Vec3.Magnitude(); + Standard_Real dot1,dot2,dot3; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); + } + else { dot1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); + } + else { dot2 = 0.; } + if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { + dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); + } + else { dot3 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { + if (Qualified1.IsUnqualified() || + (Qualified1.IsOutside() && pscal <= 0.) || + (Qualified1.IsEnclosed() && pscal >= 0.)) { + Standard_Real Angle1 = Vec2.Angle(Tan2); + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&Angle1<=0.)|| + (Qualified2.IsOutside() && Angle1 >= 0) || + (Qualified2.IsEnclosed() && Angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + qualifier3 = GccEnt_noqualifier; + pararg1 = Ufirst(2); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(3); + pnttg2sol = point2; + par2sol = 0.; + pararg3 = 0.; + pnttg3sol = Point3; + par3sol = 0.; + WellDone = Standard_True; + } + } + } + } + } +} + +Geom2dGcc_Circ2d3TanIter:: +Geom2dGcc_Circ2d3TanIter (const GccEnt_QualifiedCirc& Qualified1 , + const GccEnt_QualifiedLin& Qualified2 , + const Geom2dGcc_QCurve& Qualified3 , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Param3 , + const Standard_Real Tolerance ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + TheSame3 = Standard_False; + par1sol = 0.; + par2sol = 0.; + par3sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + pararg3 = 0.; + + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || + Qualified2.IsOutside() || Qualified2.IsUnqualified()) || + !(Qualified3.IsEnclosed() || Qualified3.IsEnclosing() || + Qualified3.IsOutside() || Qualified3.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Circ2d C1 = Qualified1.Qualified(); + gp_Lin2d L2 = Qualified2.Qualified(); + Geom2dAdaptor_Curve Cu3 = Qualified3.Qualified(); + Geom2dGcc_FunctionTanCuCuCu Func(C1,L2,Cu3); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = 0.; + Umin(2) = RealFirst(); + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(Cu3); + Umax(1) = 2*M_PI; + Umax(2) = RealLast(); + Umax(3) = Geom2dGcc_CurveTool::LastParameter(Cu3); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + Ufirst(3) = Param3; + tol(1) = 2.e-15*M_PI; + tol(2) = 1.e-15; + tol(3) = Geom2dGcc_CurveTool::EpsX(Cu3,Abs(Tolerance)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Func.Value(Ufirst,Umin); + Root.Root(Ufirst); + gp_Pnt2d centre1(C1.Location()); + Standard_Real R1 = C1.Radius(); + gp_Pnt2d point1(centre1.XY()+R1*gp_XY(Cos(Ufirst(1)),Sin(Ufirst(1)))); + gp_Pnt2d centre2(L2.Location()); + gp_Pnt2d point2(centre2.XY()+Ufirst(2)*L2.Direction().XY()); + gp_Pnt2d point3; + gp_Vec2d Tan3; + Geom2dGcc_CurveTool::D1(Cu3,Ufirst(3),point3,Tan3); + GccAna_Circ2d3Tan circ(point1,point2,point3,Tol); + if (circ.IsDone()) { + cirsol = circ.ThisSolution(1); + gp_Pnt2d centre(cirsol.Location()); + gp_Vec2d Tan1(-Sin(Ufirst(1)),Cos(Ufirst(1))); + gp_Vec2d Tan2(L2.Direction().XY()); + Standard_Real normetan1 = Tan1.Magnitude(); + Standard_Real normetan2 = Tan2.Magnitude(); + Standard_Real normetan3 = Tan3.Magnitude(); + gp_Vec2d Vec1(point1,centre); + gp_Vec2d Vec2(point2,centre); + gp_Vec2d Vec3(point3,centre); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real normevec3 = Vec3.Magnitude(); + Standard_Real dot1,dot2,dot3; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); + } + else { dot1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); + } + else { dot2 = 0.; } + if (normevec3 >= gp::Resolution() && normetan3 >= gp::Resolution()) { + dot3 = Vec3.Dot(Tan3)/(normevec3*normetan3); + } + else { dot3 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { + Standard_Real dist = centre1.Distance(centre); + Standard_Real Rsol = cirsol.Radius(); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| + (Qualified1.IsOutside() && dist >= Rsol) || + (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { + Standard_Real pscal=centre.XY().Dot(gp_XY(-L2.Direction().Y(), + L2.Direction().X())); + if (Qualified2.IsUnqualified() || + (Qualified2.IsOutside() && pscal <= 0.) || + (Qualified2.IsEnclosed() && pscal >= 0.)) { + Standard_Real Angle1 = Vec3.Angle(Tan3); + if (Qualified3.IsUnqualified() || + (Qualified3.IsEnclosing()&&Angle1<=0.)|| + (Qualified3.IsOutside() && Angle1 >= 0) || + (Qualified3.IsEnclosed() && Angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + qualifier3 = Qualified3.Qualifier(); + pararg1 = Ufirst(1); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(2); + pnttg2sol = point2; + par2sol = 0.; + pararg3 = Ufirst(3); + pnttg3sol = point3; + par3sol = 0.; + WellDone = Standard_True; + } + } + } + } + } + } +} + +Geom2dGcc_Circ2d3TanIter:: +Geom2dGcc_Circ2d3TanIter (const GccEnt_QualifiedCirc& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const gp_Pnt2d& Point3 , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Tolerance ) { + + TheSame1 = Standard_False; + TheSame2 = Standard_False; + TheSame3 = Standard_False; + par1sol = 0.; + par2sol = 0.; + par3sol = 0.; + pararg1 = 0.; + pararg2 = 0.; + pararg3 = 0.; + + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Circ2d C1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + gp_Dir2d dirx(1.,0.); + gp_Circ2d C3(gp_Ax2d(Point3,dirx),0.); + Geom2dGcc_FunctionTanCuCuCu Func(C1,C3,Cu2); + math_Vector Umin(1,3); + math_Vector Umax(1,3); + math_Vector Ufirst(1,3); + math_Vector tol(1,3); + Umin(1) = 0.; + Umin(3) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umin(2) = 0.; + Umax(1) = 2*M_PI; + Umax(3) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Umax(2) = 2*M_PI; + Ufirst(1) = Param1; + Ufirst(2) = M_PI; + Ufirst(3) = Param2; + tol(1) = 2.e-15*M_PI; + tol(2) = 2.e-15*M_PI; + tol(3) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Root.Root(Ufirst); + Func.Value(Ufirst,Umin); + gp_Pnt2d centre1(C1.Location()); + Standard_Real R1 = C1.Radius(); + gp_Pnt2d point1(centre1.XY()+R1*gp_XY(Cos(Ufirst(1)),Sin(Ufirst(1)))); + gp_Pnt2d point2; + // gp_Vec2d Tan2,Nor2; + gp_Vec2d Tan2; + Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2); + GccAna_Circ2d3Tan circ(point1,point2,Point3,Tol); + if (circ.IsDone()) { + cirsol = circ.ThisSolution(1); + gp_Pnt2d centre(cirsol.Location()); + gp_Vec2d Tan1(-Sin(Ufirst(1)),Cos(Ufirst(1))); + gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3))); + Standard_Real normetan2 = Tan2.Magnitude(); + gp_Vec2d Vec1(point1,centre); + gp_Vec2d Vec2(point2,centre); + gp_Vec2d Vec3(Point3,centre); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real normevec2 = Vec2.Magnitude(); + Standard_Real normevec3 = Vec3.Magnitude(); + Standard_Real dot1,dot2,dot3; + if (normevec1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1); + } + else { dot1 = 0.; } + if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) { + dot2 = Vec2.Dot(Tan2)/(normevec2*normetan2); + } + else { dot2 = 0.; } + if (normevec3 >= gp::Resolution()) { + dot3 = Vec3.Dot(Tan3)/(normevec3); + } + else { dot3 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol && dot2 <=Tol && dot3 <= Tol) { + Standard_Real dist = centre1.Distance(centre); + Standard_Real Rsol = cirsol.Radius(); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)|| + (Qualified1.IsOutside() && dist >= Rsol) || + (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) { + Standard_Real Angle1 = Vec2.Angle(Tan2); + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing()&&Angle1<=0.)|| + (Qualified2.IsOutside() && Angle1 >= 0) || + (Qualified2.IsEnclosed() && Angle1 <= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + qualifier3 = GccEnt_noqualifier; + pararg1 = Ufirst(1); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(2); + pnttg2sol = point2; + par2sol = 0.; + pararg3 = 0.; + pnttg3sol = Point3; + par3sol = 0.; + WellDone = Standard_True; + } + } + } + } + } +} + +Standard_Boolean Geom2dGcc_Circ2d3TanIter:: +IsDone () const{ return WellDone; } + +gp_Circ2d Geom2dGcc_Circ2d3TanIter:: +ThisSolution () const{ return cirsol; } + +void Geom2dGcc_Circ2d3TanIter:: +WhichQualifier (GccEnt_Position& Qualif1 , + GccEnt_Position& Qualif2 , + GccEnt_Position& Qualif3 ) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + Qualif1 = qualifier1; + Qualif2 = qualifier2; + Qualif3 = qualifier3; + } +} + +void Geom2dGcc_Circ2d3TanIter:: +Tangency1 (Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& PntSol ) const{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + if (TheSame1 == 0) { + ParSol = par1sol; + ParArg = pararg1; + PntSol = pnttg1sol; + } + else { StdFail_NotDone::Raise(); } + } +} + +void Geom2dGcc_Circ2d3TanIter:: +Tangency2 (Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& PntSol ) const{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + ParSol = par2sol; + ParArg = pararg2; + PntSol = pnttg2sol; + } +} + +void Geom2dGcc_Circ2d3TanIter:: +Tangency3 (Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& PntSol ) const{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + ParSol = par3sol; + ParArg = pararg3; + PntSol = pnttg3sol; + } +} + +Standard_Boolean Geom2dGcc_Circ2d3TanIter:: +IsTheSame1 () const +{ + if (!WellDone) StdFail_NotDone::Raise(); + + if (TheSame1 == 0) + return Standard_False; + + return Standard_True; +} + + +Standard_Boolean Geom2dGcc_Circ2d3TanIter:: +IsTheSame2 () const +{ + if (!WellDone) StdFail_NotDone::Raise(); + + if (TheSame3 == 0) + return Standard_False; + + return Standard_True; + +} + +Standard_Boolean Geom2dGcc_Circ2d3TanIter:: +IsTheSame3 () const +{ + if (!WellDone) StdFail_NotDone::Raise(); + + return Standard_True; +} diff --git a/src/Geom2dGcc/Geom2dGcc_FunctionTanCirCu.cdl b/src/Geom2dGcc/Geom2dGcc_FunctionTanCirCu.cdl new file mode 100644 index 0000000000..c640825b6a --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_FunctionTanCirCu.cdl @@ -0,0 +1,63 @@ +-- Created on: 1992-02-20 +-- Created by: Remy GILET +-- 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. + +private class FunctionTanCirCu from Geom2dGcc inherits FunctionWithDerivative from math + + ---Purpose: This abstract class describes a Function of 1 Variable + -- used to find a line tangent to a curve and a circle. + +uses + Circ2d from gp, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc + +is + +Create (Circ : Circ2d from gp ; + Curv : Curve from Geom2dAdaptor ) returns FunctionTanCirCu from Geom2dGcc; + +Value (me : in out ; + X : Real ; + F : out Real ) returns Boolean; + ---Purpose: Computes the value of the function F for the variable X. + -- It returns True if the computation is successfully done, + -- False otherwise. + +Derivative (me : in out ; + X : Real ; + Deriv : out Real ) returns Boolean; + ---Purpose: Computes the derivative of the function F for the variable X. + -- It returns True if the computation is successfully done, + -- False otherwise. + +Values (me : in out ; + X : Real ; + F : out Real ; + Deriv : out Real ) returns Boolean; + ---Purpose: Computes the value and the derivative of the function F + -- for the variable X. + -- It returns True if the computation is successfully done, + -- False otherwise. + +fields + +TheCirc : Circ2d from gp; +Curve : Curve from Geom2dAdaptor; +-- Modified by Sergey KHROMOV - Thu Apr 5 09:50:18 2001 Begin +myWeight : Real; +-- Modified by Sergey KHROMOV - Thu Apr 5 09:50:19 2001 End + +end FunctionTanCirCu; diff --git a/src/Geom2dGcc/Geom2dGcc_FunctionTanCirCu.cxx b/src/Geom2dGcc/Geom2dGcc_FunctionTanCirCu.cxx new file mode 100644 index 0000000000..0e30ca4df1 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_FunctionTanCirCu.cxx @@ -0,0 +1,138 @@ +// Created on: 1992-01-20 +// Created by: Remi GILET +// 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. + +#include + +#include +#include +#include +#include + +#include + +//========================================================================= +// soit P1 le point sur la courbe Geom2dAdaptor_Curve d abscisse u. + +// soit C le centre du cercle TheCirc. + +// Nous recherchons un point P2 appartenant au cercle tel que : + +// ---> --> + +// * P1P2 . CP2 = 0 + +// + +// * --> 2 2 + +// ||CP2|| = R + +// Nous cherchons donc les zeros de la fonction suivante: + +// --> --> 2 + +// --> 2 ( CP1 . T ) 2 + +// ||CP1|| - ----------- - R = F(u) + +// --> 2 + +// ||T|| + +// + +// La derivee de cette fonction est : + +// + +// 2*(CP1.T)(CP1.N) 2*(CP1.T)*(CP1.T)*T.N + +// f(u) = - ---------------- + --------------------- + +// T.T (T.T)*(T.T) + +//========================================================================= +// + +// skv: Small addition: The function and the derivative are normalized + +// by an average square distance between the circle + +// and the curve. + +//========================================================================= + +Geom2dGcc_FunctionTanCirCu:: +Geom2dGcc_FunctionTanCirCu(const gp_Circ2d& Circ , + const Geom2dAdaptor_Curve& Curv ) { + Curve = Curv; + TheCirc = Circ; + + // Modified by Sergey KHROMOV - Thu Apr 5 09:51:21 2001 Begin + Standard_Integer aNbSamp = Geom2dGcc_CurveTool::NbSamples(Curve); + Standard_Real aFirst = Geom2dGcc_CurveTool::FirstParameter(Curve); + Standard_Real aLast = Geom2dGcc_CurveTool::LastParameter(Curve); + Standard_Real aStep = (aLast - aFirst)/aNbSamp; + Standard_Real anX = aFirst + aStep/2.; + Standard_Integer aNbP = 0; + gp_XY aLoc(0., 0.); + + while (anX <= aLast) { + aLoc += (Geom2dGcc_CurveTool::Value(Curve, anX)).XY(); + anX += aStep; + aNbP++; + } + myWeight = Max((aLoc - TheCirc.Location().XY()).SquareModulus(), TheCirc.Radius()); + // Modified by Sergey KHROMOV - Thu Apr 5 09:51:25 2001 End +} + + +Standard_Boolean Geom2dGcc_FunctionTanCirCu:: +Value (const Standard_Real X , + Standard_Real& Fval ) { + gp_Pnt2d Point; + gp_Vec2d Vect1; + Geom2dGcc_CurveTool::D1(Curve,X,Point,Vect1); + Standard_Real NormeD1 = Vect1.Magnitude(); + gp_Vec2d TheDirection(TheCirc.Location(),Point); + Standard_Real squaredir = TheDirection.Dot(TheDirection); + Standard_Real R = TheCirc.Radius(); + Fval = squaredir-R*R- + (TheDirection.Dot(Vect1))*(TheDirection.Dot(Vect1))/(NormeD1*NormeD1); + // Modified by Sergey KHROMOV - Thu Apr 5 17:38:05 2001 Begin + Fval /= myWeight; + // Modified by Sergey KHROMOV - Thu Apr 5 17:38:06 2001 End + return Standard_True; +} + +Standard_Boolean Geom2dGcc_FunctionTanCirCu:: +Derivative (const Standard_Real X , + Standard_Real& Deriv ) { + gp_Pnt2d Point; + gp_Vec2d Vect1,Vect2; + Geom2dGcc_CurveTool::D2(Curve,X,Point,Vect1,Vect2); + Standard_Real NormeD1 = Vect1.SquareMagnitude(); + gp_Vec2d TheDirection(TheCirc.Location(),Point); + Standard_Real cp1dott = TheDirection.Dot(Vect1); + Deriv = -2.*(cp1dott/NormeD1)* + ((TheDirection.Dot(Vect2))-cp1dott*Vect1.Dot(Vect2)/NormeD1); + // Modified by Sergey KHROMOV - Thu Apr 5 17:38:15 2001 Begin + Deriv /= myWeight; + // Modified by Sergey KHROMOV - Thu Apr 5 17:38:15 2001 End + return Standard_True; +} + +Standard_Boolean Geom2dGcc_FunctionTanCirCu:: +Values (const Standard_Real X , + Standard_Real& Fval , + Standard_Real& Deriv ) { + gp_Pnt2d Point; + gp_Vec2d Vect1,Vect2; + Geom2dGcc_CurveTool::D2(Curve,X,Point,Vect1,Vect2); + Standard_Real NormeD1 = Vect1.SquareMagnitude(); + gp_Vec2d TheDirection(TheCirc.Location(),Point); + Standard_Real squaredir = TheDirection.SquareMagnitude(); + Standard_Real cp1dott = TheDirection.Dot(Vect1); + Standard_Real R = TheCirc.Radius(); + + Fval = squaredir-R*R-cp1dott*cp1dott/NormeD1; + // Modified by Sergey KHROMOV - Thu Apr 5 17:38:28 2001 Begin + Fval /= myWeight; + // Modified by Sergey KHROMOV - Thu Apr 5 17:38:28 2001 End + + Deriv = -2.*(cp1dott/NormeD1)* + ((TheDirection.Dot(Vect2))-cp1dott*Vect1.Dot(Vect2)/NormeD1); + // Modified by Sergey KHROMOV - Thu Apr 5 17:37:36 2001 Begin + Deriv /= myWeight; + // Modified by Sergey KHROMOV - Thu Apr 5 17:37:37 2001 End + return Standard_True; +} diff --git a/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCu.cdl b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCu.cdl new file mode 100644 index 0000000000..52476f2b24 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCu.cdl @@ -0,0 +1,88 @@ +-- Created on: 1992-02-20 +-- Created by: Remy GILET +-- 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. + +private class FunctionTanCuCu from Geom2dGcc inherits FunctionSetWithDerivatives from math + + ---Purpose: This abstract class describes a Function of 1 Variable + -- used to find a line tangent to two curves. + +uses Vector from math, + Matrix from math, + Circ2d from gp, + Pnt2d from gp, + Vec2d from gp, + Type3 from Geom2dGcc, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc + + +raises ConstructionError + +is + +Create (Curv1 : Curve from Geom2dAdaptor ; + Curv2 : Curve from Geom2dAdaptor ) returns FunctionTanCuCu from Geom2dGcc; + +Create (Circ1 : Circ2d from gp ; + Curv2 : Curve from Geom2dAdaptor ) returns FunctionTanCuCu from Geom2dGcc; + +InitDerivative(me : in out ; + X : Vector from math ; + Point1,Point2 : out Pnt2d from gp ; + Tan1,Tan2,D21,D22 : out Vec2d from gp ) +raises ConstructionError +is static; + +NbVariables(me) returns Integer; + ---Purpose: returns the number of variables of the function. + +NbEquations(me) returns Integer; + ---Purpose: returns the number of equations of the function. + +Value (me : in out ; + X : Vector from math; + F : out Vector from math) returns Boolean; + ---Purpose: Computes the value of the function F for the variable X. + -- It returns True if the computation is successfully done, + -- False otherwise. + +Derivatives (me : in out ; + X : Vector from math; + Deriv : out Matrix from math) returns Boolean; + ---Purpose: Computes the derivative of the function F for the variable X. + -- It returns True if the computation is successfully done, + -- False otherwise. + +Values (me : in out ; + X : Vector from math; + F : out Vector from math; + Deriv : out Matrix from math) returns Boolean; + ---Purpose: Computes the value and the derivative of the function F + -- for the variable X. + -- It returns True if the computation is successfully done, + -- False otherwise. + +fields + +TheCurve1 : Curve from Geom2dAdaptor ; +TheCurve2 : Curve from Geom2dAdaptor ; +TheCirc1 : Circ2d from gp ; +TheType : Type3 from Geom2dGcc ; + +end FunctionTanCuCu; + + + diff --git a/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCu.cxx b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCu.cxx new file mode 100644 index 0000000000..d3114ca3df --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCu.cxx @@ -0,0 +1,219 @@ +// Created on: 1992-01-20 +// Created by: Remi GILET +// 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. + +#include + +#include +#include +#include + +#include + +void Geom2dGcc_FunctionTanCuCu:: +InitDerivative(const math_Vector& X, + gp_Pnt2d& Point1, + gp_Pnt2d& Point2, + gp_Vec2d& Tan1 , + gp_Vec2d& Tan2 , + gp_Vec2d& D21 , + gp_Vec2d& D22 ) +{ + switch (TheType) + { + case Geom2dGcc_CuCu: + { + Geom2dGcc_CurveTool::D2(TheCurve1,X(1),Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(TheCurve2,X(2),Point2,Tan2,D22); + } + break; + case Geom2dGcc_CiCu: + { + ElCLib::D2(X(1),TheCirc1,Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(TheCurve2,X(2),Point2,Tan2,D22); + } + break; + default: + { + } + } +} + +Geom2dGcc_FunctionTanCuCu:: +Geom2dGcc_FunctionTanCuCu(const Geom2dAdaptor_Curve& C1 , + const Geom2dAdaptor_Curve& C2 ) { + TheCurve1 = C1; + TheCurve2 = C2; + TheType = Geom2dGcc_CuCu; +} + +Geom2dGcc_FunctionTanCuCu:: +Geom2dGcc_FunctionTanCuCu(const gp_Circ2d& C1 , + const Geom2dAdaptor_Curve& C2 ) { + TheCirc1 = C1; + TheCurve2 = C2; + TheType = Geom2dGcc_CiCu; +} + + +//========================================================================= +// soit P1 le point sur la courbe TheCurve1 d abscisse u1. + +// soit P2 le point sur la courbe TheCurve2 d abscisse u2. + +// soit T1 la tangente a la courbe TheCurve1 en P1. + +// soit T2 la tangente a la courbe TheCurve2 en P2. + +// Nous voulons P1 et P2 tels que : + +// ---> --> + +// * P1P2 /\ T1 = 0 + +// + +// --> --> + +// * T1 /\ T2 = 0 + +// + +// Nous cherchons donc les zeros des fonctions suivantes: + +// ---> --> + +// * P1P2 /\ T1 + +// --------------- = F1(u) + +// ---> --> + +// ||P1P2||*||T1|| + +// + +// --> --> + +// * T1 /\ T2 + +// --------------- = F2(u) + +// --> --> + +// ||T2||*||T1|| + +// + +// Les derivees de ces fonctions sont : + +// 2 2 + +// dF1 P1P2/\N1 (P1P2/\T1)*[T1*(-T1).P1P2+P1P2*(T1.N1)] + +// ----- = --------------- - ----------------------------------------- + +// du1 3 3 + +// ||P1P2||*||T1|| ||P1P2|| * ||T1|| + +// + +// 2 + +// dF1 T2/\T1 (P1P2/\T1)*[T1*(T2.P1P2) + +// ----- = --------------- - ----------------------------------------- + +// du2 3 3 + +// ||P1P2||*||T1|| ||P1P2|| * ||T1|| + +// + +// 2 + +// dF2 N1/\T2 T1/\T2*(N1.T1)T2 + +// ----- = ---------------- - ----------------------------- + +// du1 3 3 + +// ||T1||*||T2|| ||T1|| * ||T2|| + +// + +// 2 + +// dF2 T1/\N2 T1/\T2*(N2.T2)T1 + +// ----- = ---------------- - ----------------------------- + +// du2 3 3 + +// ||T1||*||T2|| ||T1|| * ||T2|| + +// + +//========================================================================= + +Standard_Integer Geom2dGcc_FunctionTanCuCu:: +NbVariables() const { return 2; } + +Standard_Integer Geom2dGcc_FunctionTanCuCu:: +NbEquations() const { return 2; } + +Standard_Boolean Geom2dGcc_FunctionTanCuCu:: +Value (const math_Vector& X , + math_Vector& Fval ) { + gp_Pnt2d Point1; + gp_Pnt2d Point2; + gp_Vec2d Vect11; + gp_Vec2d Vect21; + gp_Vec2d Vect12; + gp_Vec2d Vect22; + InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22); + Standard_Real NormeD11 = Vect11.Magnitude(); + Standard_Real NormeD21 = Vect21.Magnitude(); + gp_Vec2d TheDirection(Point1,Point2); + Standard_Real squaredir = TheDirection.Dot(TheDirection); + Fval(1) = TheDirection.Crossed(Vect11)/(NormeD11*squaredir); + Fval(2) = Vect11.Crossed(Vect21)/(NormeD11*NormeD21); + return Standard_True; +} + +Standard_Boolean Geom2dGcc_FunctionTanCuCu:: +Derivatives (const math_Vector& X , + math_Matrix& Deriv ) { + gp_Pnt2d Point1; + gp_Pnt2d Point2; + gp_Vec2d Vect11; + gp_Vec2d Vect21; + gp_Vec2d Vect12; + gp_Vec2d Vect22; + InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22); + Standard_Real NormeD11 = Vect11.Magnitude(); + Standard_Real NormeD21 = Vect21.Magnitude(); +#ifdef DEB + gp_Vec2d V2V1(Vect11.XY(),Vect21.XY()); +#else + Vect11.XY(); + Vect21.XY(); +#endif + gp_Vec2d TheDirection(Point1,Point2); + Standard_Real squaredir = TheDirection.Dot(TheDirection); + Deriv(1,1) = TheDirection.Crossed(Vect12)/(NormeD11*squaredir)+ + (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect11.Dot(TheDirection))/ + (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); + Deriv(1,2) = Vect21.Crossed(Vect11)/(NormeD11*squaredir)- + (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect21.Dot(TheDirection))/ + (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); + Deriv(2,1)=(Vect12.Crossed(Vect21))/(NormeD11*NormeD21)- + (Vect11.Crossed(Vect21))*(Vect12.Dot(Vect11))*NormeD21*NormeD21/ + (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); + Deriv(2,2)=(Vect11.Crossed(Vect22))/(NormeD11*NormeD21)- + (Vect11.Crossed(Vect21))*(Vect22.Dot(Vect21))*NormeD11*NormeD11/ + (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); + return Standard_True; +} + +Standard_Boolean Geom2dGcc_FunctionTanCuCu:: +Values (const math_Vector& X , + math_Vector& Fval , + math_Matrix& Deriv ) { + gp_Pnt2d Point1; + gp_Pnt2d Point2; + gp_Vec2d Vect11; + gp_Vec2d Vect21; + gp_Vec2d Vect12; + gp_Vec2d Vect22; + InitDerivative(X,Point1,Point2,Vect11,Vect21,Vect12,Vect22); + Standard_Real NormeD11 = Vect11.Magnitude(); + Standard_Real NormeD21 = Vect21.Magnitude(); +#ifdef DEB + gp_Vec2d V2V1(Vect11.XY(),Vect21.XY()); +#else + Vect11.XY(); + Vect21.XY(); +#endif + gp_Vec2d TheDirection(Point1,Point2); + Standard_Real squaredir = TheDirection.Dot(TheDirection); + Fval(1) = TheDirection.Crossed(Vect11)/(NormeD11*squaredir); + Fval(2) = Vect11.Crossed(Vect21)/(NormeD11*NormeD21); + Deriv(1,1) = TheDirection.Crossed(Vect12)/(NormeD11*squaredir)+ + (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect11.Dot(TheDirection))/ + (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); + Deriv(1,2) = Vect21.Crossed(Vect11)/(NormeD11*squaredir)- + (TheDirection.Crossed(Vect11)*NormeD11*NormeD11*Vect21.Dot(TheDirection))/ + (NormeD11*NormeD11*NormeD11*squaredir*squaredir*squaredir); + Deriv(2,1)=(Vect12.Crossed(Vect21))/(NormeD11*NormeD21)- + (Vect11.Crossed(Vect21))*(Vect12.Dot(Vect11))*NormeD21*NormeD21/ + (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); + Deriv(2,2)=(Vect11.Crossed(Vect22))/(NormeD11*NormeD21)- + (Vect11.Crossed(Vect21))*(Vect22.Dot(Vect21))*NormeD11*NormeD11/ + (NormeD11*NormeD11*NormeD11*NormeD21*NormeD21*NormeD21); + return Standard_True; +} diff --git a/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuCu.cdl b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuCu.cdl new file mode 100644 index 0000000000..221fec029f --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuCu.cdl @@ -0,0 +1,114 @@ +-- Created on: 1991-05-13 +-- Created by: Laurent PAINNOT +-- Copyright (c) 1991-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. + +private class FunctionTanCuCuCu from Geom2dGcc inherits FunctionSetWithDerivatives from math + + ---Purpose: This abstract class describes a set on N Functions of + -- M independant variables. + +uses Vector from math, + Matrix from math, + Circ2d from gp, + Lin2d from gp, + Pnt2d from gp, + Vec2d from gp, + Type1 from Geom2dGcc, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc + +raises ConstructionError + +is + + Create (C1 : Curve from Geom2dAdaptor ; + C2 : Curve from Geom2dAdaptor ; + C3 : Curve from Geom2dAdaptor ) returns FunctionTanCuCuCu from Geom2dGcc; + + Create (C1 : Circ2d from gp ; + C2 : Curve from Geom2dAdaptor ; + C3 : Curve from Geom2dAdaptor ) returns FunctionTanCuCuCu from Geom2dGcc; + + Create (C1 : Circ2d from gp ; + C2 : Circ2d from gp ; + C3 : Curve from Geom2dAdaptor ) returns FunctionTanCuCuCu from Geom2dGcc; + + Create (C1 : Circ2d from gp ; + L2 : Lin2d from gp ; + C3 : Curve from Geom2dAdaptor ) returns FunctionTanCuCuCu from Geom2dGcc; + + Create (L1 : Lin2d from gp ; + L2 : Lin2d from gp ; + C3 : Curve from Geom2dAdaptor ) returns FunctionTanCuCuCu from Geom2dGcc; + + Create (L1 : Lin2d from gp ; + C2 : Curve from Geom2dAdaptor ; + C3 : Curve from Geom2dAdaptor ) returns FunctionTanCuCuCu from Geom2dGcc; + + Create (C1 : Circ2d from gp ; + C2 : Curve from Geom2dAdaptor ; + P3 : Pnt2d from gp ) returns FunctionTanCuCuCu from Geom2dGcc; + + Create (L1 : Lin2d from gp ; + C2 : Curve from Geom2dAdaptor ; + P3 : Pnt2d from gp ) returns FunctionTanCuCuCu from Geom2dGcc; + + Create (C1 : Curve from Geom2dAdaptor ; + P2 : Pnt2d from gp ; + P3 : Pnt2d from gp ) returns FunctionTanCuCuCu from Geom2dGcc; + +InitDerivative(me : in out ; + X : Vector from math ; + Point1,Point2,Point3 : out Pnt2d from gp ; + Tan1,Tan2,Tan3,D21,D22,D23 : out Vec2d from gp ) +raises ConstructionError +is static; + + NbVariables(me) returns Integer; + ---Purpose: Returns the number of variables of the function. + + NbEquations(me) returns Integer; + ---Purpose: Returns the number of equations of the function. + + Value(me : in out ; + X : Vector from math; + F : out Vector from math) returns Boolean; + ---Purpose: Computes the values of the Functions for the variable . + + Derivatives(me : in out ; + X : Vector from math; + D : out Matrix from math) returns Boolean; + ---Purpose: Returns the values of the derivatives for the variable . + + Values(me : in out ; + X : Vector from math; + F : out Vector from math; + D : out Matrix from math) returns Boolean; + ---Purpose: Returns the values of the functions and the derivatives + -- for the variable . + +fields + +Curv1 : Curve from Geom2dAdaptor ; +Curv2 : Curve from Geom2dAdaptor ; +Curv3 : Curve from Geom2dAdaptor ; +Circ1 : Circ2d from gp ; +Circ2 : Circ2d from gp ; +Lin1 : Lin2d from gp ; +Lin2 : Lin2d from gp ; +TheType : Type1 from Geom2dGcc; + +end FunctionTanCuCuCu; + diff --git a/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuCu.cxx b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuCu.cxx new file mode 100644 index 0000000000..ca18995fcf --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuCu.cxx @@ -0,0 +1,484 @@ +// Created on: 1992-01-20 +// Created by: Remi GILET +// 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. + +#include + +#include +#include +#include + +#include + +void Geom2dGcc_FunctionTanCuCuCu:: +InitDerivative(const math_Vector& X, + gp_Pnt2d& Point1, + gp_Pnt2d& Point2, + gp_Pnt2d& Point3, + gp_Vec2d& Tan1, + gp_Vec2d& Tan2, + gp_Vec2d& Tan3, + gp_Vec2d& D21, + gp_Vec2d& D22, + gp_Vec2d& D23) { + switch (TheType) { + case Geom2dGcc_CiCuCu: + { + ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + Geom2dGcc_CurveTool::D2(Curv3,X(3),Point3,Tan3,D23); + } + break; + case Geom2dGcc_CiCiCu: + { + ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); + ElCLib::D2(X(2),Circ2,Point2,Tan2,D22); + Geom2dGcc_CurveTool::D2(Curv3,X(3),Point3,Tan3,D23); + } + break; + case Geom2dGcc_CiLiCu: + { + ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); + ElCLib::D1(X(2),Lin2,Point2,Tan2); + D22 = gp_Vec2d(0.,0.); + Geom2dGcc_CurveTool::D2(Curv3,X(3),Point3,Tan3,D23); + } + break; + case Geom2dGcc_LiCuCu: + { + ElCLib::D1(X(1),Lin1,Point1,Tan1); + D21 = gp_Vec2d(0.,0.); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + Geom2dGcc_CurveTool::D2(Curv3,X(3),Point3,Tan3,D23); + } + break; + case Geom2dGcc_LiLiCu: + { + ElCLib::D1(X(1),Lin1,Point1,Tan1); + D21 = gp_Vec2d(0.,0.); + ElCLib::D1(X(2),Lin2,Point2,Tan2); + D22 = gp_Vec2d(0.,0.); + Geom2dGcc_CurveTool::D2(Curv3,X(3),Point3,Tan3,D23); + } + break; + case Geom2dGcc_CuCuCu: + { + Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + Geom2dGcc_CurveTool::D2(Curv3,X(3),Point3,Tan3,D23); + } + break; + default: + { + Standard_ConstructionError::Raise(); + } + } +} + +Geom2dGcc_FunctionTanCuCuCu:: +Geom2dGcc_FunctionTanCuCuCu(const Geom2dAdaptor_Curve& C1 , + const Geom2dAdaptor_Curve& C2 , + const Geom2dAdaptor_Curve& C3 ) { + Curv1 = C1; + Curv2 = C2; + Curv3 = C3; + TheType = Geom2dGcc_CuCuCu; +} + +Geom2dGcc_FunctionTanCuCuCu:: +Geom2dGcc_FunctionTanCuCuCu(const gp_Circ2d& C1 , + const Geom2dAdaptor_Curve& C2 , + const Geom2dAdaptor_Curve& C3 ) { + Circ1 = C1; + Curv2 = C2; + Curv3 = C3; + TheType = Geom2dGcc_CiCuCu; +} + +Geom2dGcc_FunctionTanCuCuCu:: +Geom2dGcc_FunctionTanCuCuCu(const gp_Circ2d& C1 , + const gp_Circ2d& C2 , + const Geom2dAdaptor_Curve& C3 ) { + Circ1 = C1; + Circ2 = C2; + Curv3 = C3; + TheType = Geom2dGcc_CiCiCu; +} + +Geom2dGcc_FunctionTanCuCuCu:: +Geom2dGcc_FunctionTanCuCuCu(const gp_Circ2d& C1 , + const gp_Lin2d& L2 , + const Geom2dAdaptor_Curve& C3 ) { + Circ1 = C1; + Lin2 = L2; + Curv3 = C3; + TheType = Geom2dGcc_CiLiCu; +} + +Geom2dGcc_FunctionTanCuCuCu:: +Geom2dGcc_FunctionTanCuCuCu(const gp_Lin2d& L1 , + const gp_Lin2d& L2 , + const Geom2dAdaptor_Curve& C3 ) { + Lin1 = L1; + Lin2 = L2; + Curv3 = C3; + TheType = Geom2dGcc_LiLiCu; +} + +Geom2dGcc_FunctionTanCuCuCu:: +Geom2dGcc_FunctionTanCuCuCu(const gp_Lin2d& L1 , + const Geom2dAdaptor_Curve& C2 , + const Geom2dAdaptor_Curve& C3 ) { + Lin1 = L1; + Curv2 = C2; + Curv3 = C3; + TheType = Geom2dGcc_LiCuCu; +} + +//========================================================================== + +Standard_Integer Geom2dGcc_FunctionTanCuCuCu:: +NbVariables () const { return 3; } + +Standard_Integer Geom2dGcc_FunctionTanCuCuCu:: +NbEquations () const { return 3; } + +Standard_Boolean Geom2dGcc_FunctionTanCuCuCu:: +Value (const math_Vector& X , + math_Vector& Fval ) { + gp_Pnt2d Point1; + gp_Pnt2d Point2; + gp_Pnt2d Point3; + gp_Vec2d Tan1; + gp_Vec2d Tan2; + gp_Vec2d Tan3; + gp_Vec2d D21; + gp_Vec2d D22; + gp_Vec2d D23; + InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); + //pipj (normes) et PiPj (non Normes). + gp_XY P1P2(gp_Vec2d(Point1,Point2).XY()); + gp_XY P2P3(gp_Vec2d(Point2,Point3).XY()); + gp_XY P3P1(gp_Vec2d(Point3,Point1).XY()); + Standard_Real NorP1P2 = P1P2.Modulus(); + Standard_Real NorP2P3 = P2P3.Modulus(); + Standard_Real NorP3P1 = P3P1.Modulus(); + gp_XY p1p2,p2p3,p3p1; + if (NorP1P2 >= gp::Resolution()) { p1p2 = P1P2/NorP1P2; } + else { p1p2 = gp_XY(0.,0.); } + if (NorP2P3 >= gp::Resolution()) { p2p3 = P2P3/NorP2P3; } + else { p2p3 = gp_XY(0.,0.); } + if (NorP3P1 >= gp::Resolution()) { p3p1 = P3P1/NorP3P1; } + else { p3p1 = gp_XY(0.,0.); } + //derivees premieres non normees Deriv1ui. + gp_XY Deriv1u1(Tan1.XY()); + gp_XY Deriv1u2(Tan2.XY()); + gp_XY Deriv1u3(Tan3.XY()); + //normales aux courbes. + Standard_Real nnor1 = Deriv1u1.Modulus(); + Standard_Real nnor2 = Deriv1u2.Modulus(); + Standard_Real nnor3 = Deriv1u3.Modulus(); + gp_XY Nor1(-Deriv1u1.Y(),Deriv1u1.X()); + gp_XY Nor2(-Deriv1u2.Y(),Deriv1u2.X()); + gp_XY Nor3(-Deriv1u3.Y(),Deriv1u3.X()); + gp_XY nor1,nor2,nor3; + if (nnor1 >= gp::Resolution()) { nor1 = Nor1/nnor1; } + else { nor1 = gp_XY(0.,0.); } + if (nnor2 >= gp::Resolution()) { nor2 = Nor2/nnor2; } + else { nor2 = gp_XY(0.,0.); } + if (nnor3 >= gp::Resolution()) { nor3 = Nor3/nnor3; } + else { nor3 = gp_XY(0.,0.); } + //determination des signes pour les produits scalaires. + Standard_Real signe1 = 1.; + Standard_Real signe2 = 1.; + Standard_Real signe3 = 1.; + gp_Pnt2d Pcenter(gp_XY(Point1.XY()+Point2.XY()+Point3.XY())/3.); + gp_XY fic1(Pcenter.XY()-Point1.XY()); + gp_XY fic2(Pcenter.XY()-Point2.XY()); + gp_XY fic3(Pcenter.XY()-Point3.XY()); + Standard_Real pscal11 = nor1.Dot(fic1); + Standard_Real pscal22 = nor2.Dot(fic2); + Standard_Real pscal33 = nor3.Dot(fic3); + if (pscal11 <= 0.) { signe1 = -1; } + if (pscal22 <= 0.) { signe2 = -1; } + if (pscal33 <= 0.) { signe3 = -1; } + // Fonctions Fui. + // ============== + Fval(1) = signe1*nor1.Dot(p1p2)+signe2*nor2.Dot(p1p2); + Fval(2) = signe2*nor2.Dot(p2p3)+signe3*nor3.Dot(p2p3); + Fval(3) = signe3*nor3.Dot(p3p1)+signe1*nor1.Dot(p3p1); + return Standard_True; +} + + + +Standard_Boolean Geom2dGcc_FunctionTanCuCuCu::Derivatives (const math_Vector&, + math_Matrix&) +{ +#if 0 + gp_Pnt2d Point1; + gp_Pnt2d Point2; + gp_Pnt2d Point3; + gp_Vec2d Tan1; + gp_Vec2d Tan2; + gp_Vec2d Tan3; + gp_Vec2d D21; + gp_Vec2d D22; + gp_Vec2d D23; + InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); + //derivees premieres non normees Deriv1ui. + gp_XY Deriv1u1(Tan1.XY()); + gp_XY Deriv1u2(Tan2.XY()); + gp_XY Deriv1u3(Tan3.XY()); + //pipj (normes) et PiPj (non Normes). + gp_XY P1P2(gp_Vec2d(Point1,Point2).XY()); + gp_XY P2P3(gp_Vec2d(Point2,Point3).XY()); + gp_XY P3P1(gp_Vec2d(Point3,Point1).XY()); + Standard_Real NorP1P2 = P1P2.Modulus(); + Standard_Real NorP2P3 = P2P3.Modulus(); + Standard_Real NorP3P1 = P3P1.Modulus(); + gp_XY p1p2,p2p3,p3p1; + if (NorP1P2 >= gp::Resolution()) { p1p2 = P1P2/NorP1P2; } + else { p1p2 = gp_XY(0.,0.); } + if (NorP2P3 >= gp::Resolution()) { p2p3 = P2P3/NorP2P3; } + else { p2p3 = gp_XY(0.,0.); } + if (NorP3P1 >= gp::Resolution()) { p3p1 = P3P1/NorP3P1; } + else { p3p1 = gp_XY(0.,0.); } + //normales au courbes normees Nori et non nromees nori et norme des nori. + Standard_Real nnor1 = Deriv1u1.Modulus(); + Standard_Real nnor2 = Deriv1u2.Modulus(); + Standard_Real nnor3 = Deriv1u3.Modulus(); + gp_XY Nor1(-Deriv1u1.Y(),Deriv1u1.X()); + gp_XY Nor2(-Deriv1u2.Y(),Deriv1u2.X()); + gp_XY Nor3(-Deriv1u3.Y(),Deriv1u3.X()); + gp_XY nor1,nor2,nor3; + if (nnor1 >= gp::Resolution()) { nor1 = Nor1/nnor1; } + else { nor1 = gp_XY(0.,0.); } + if (nnor2 >= gp::Resolution()) { nor2 = Nor2/nnor2; } + else { nor2 = gp_XY(0.,0.); } + if (nnor3 >= gp::Resolution()) { nor3 = Nor3/nnor3; } + else { nor3 = gp_XY(0.,0.); } + //derivees des normales. + gp_XY NorD21,NorD22,NorD23; + NorD21 = gp_XY(-D21.Y(),D21.X()); + NorD22 = gp_XY(-D22.Y(),D22.X()); + NorD23 = gp_XY(-D23.Y(),D23.X()); + //determination des signes pour les produits scalaires. + Standard_Real signe1 = 1.; + Standard_Real signe2 = 1.; + Standard_Real signe3 = 1.; + gp_XY P = Point1.XY(); + P += Point2.XY(); + P += Point3.XY(); + P /= 3.; + gp_Pnt2d Pcenter(P); + gp_XY fic1 = Pcenter.XY(); + fic1 -= Point1.XY(); + gp_XY fic2 = Pcenter.XY(); + fic2 -= Point2.XY(); + gp_XY fic3 = Pcenter.XY(); + fic3 -= Point3.XY(); + Standard_Real pscal11 = nor1.Dot(fic1); + Standard_Real pscal22 = nor2.Dot(fic2); + Standard_Real pscal33 = nor3.Dot(fic3); + if (pscal11 <= 0.) { signe1 = -1; } + if (pscal22 <= 0.) { signe2 = -1; } + if (pscal33 <= 0.) { signe3 = -1; } + + // Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3 + // ============================================= + Standard_Real partie1,partie2; + if (nnor1 <= gp::Resolution()) { partie1 = 0.; } + else { partie1 = (signe1*NorD21/nnor1-(Nor1.Dot(NorD21)/(nnor1*nnor1*nnor1)) + *Nor1).Dot(p1p2); } + if (NorP1P2 <= gp::Resolution()) { partie2 = 0.; } + else {partie2=((Deriv1u1.Dot(p1p2)/(NorP1P2*NorP1P2))*P1P2-Deriv1u1/NorP1P2) + .Dot(signe1*nor1+signe2*nor2); } + Deriv(1,1) = partie1 + partie2; + if (nnor2 <= gp::Resolution()) { partie1 = 0.; } + else { partie1=(signe2*NorD22/(nnor2)-(Nor2.Dot(NorD22)/(nnor2*nnor2*nnor2)) + *Nor2).Dot(p1p2); } + if (NorP1P2 <= gp::Resolution()) { partie2 = 0.; } + else{partie2=((-Deriv1u2.Dot(p1p2)/(NorP1P2*NorP1P2))*P1P2+Deriv1u2/NorP1P2) + .Dot(signe1*nor1+signe2*nor2); } + Deriv(1,2) = partie1 + partie2; + Deriv(1,3) = 0.; + Deriv(2,1) = 0.; + if (nnor2 <= gp::Resolution()) { partie1 = 0.; } + else { partie1=(signe2*NorD22/(nnor2)-(Nor2.Dot(NorD22)/(nnor2*nnor2*nnor2)) + *Nor2).Dot(p2p3); } + if (NorP2P3 <= gp::Resolution()) { partie2 = 0.; } + else { partie2=((Deriv1u2.Dot(p2p3)/(NorP2P3*NorP2P3))*P2P3-Deriv1u2/NorP2P3) + .Dot(signe2*nor2+signe3*nor3); } + Deriv(2,2) = partie1 +partie2; + if (nnor3 <= gp::Resolution()) { partie1 = 0.; } + else { partie1=(signe3*NorD23/(nnor3)-(Nor3.Dot(NorD23)/(nnor3*nnor3*nnor3)) + *Nor3).Dot(p2p3); } + if (NorP2P3 <= gp::Resolution()) { partie2 = 0.; } + else {partie2=((-Deriv1u3.Dot(p2p3)/(NorP2P3*NorP2P3))*P2P3+Deriv1u3/NorP2P3) + .Dot(signe2*nor2+signe3*nor3); } + Deriv(2,3) = partie1 + partie2; + if (nnor1 <= gp::Resolution()) { partie1 = 0.; } + else { partie1 =(signe1*NorD21/(nnor1)-(Nor1.Dot(NorD21)/(nnor1*nnor1*nnor1)) + *Nor1).Dot(p3p1); } + if (NorP3P1 <= gp::Resolution()) { partie2 = 0.; } + else {partie2=((-Deriv1u1.Dot(p3p1)/(NorP3P1*NorP3P1))*P3P1+Deriv1u1/NorP3P1) + .Dot(signe1*nor1+signe3*nor3); } + Deriv(3,1) = partie1 + partie2; + Deriv(3,2) = 0.; + if (nnor3 <= gp::Resolution()) { partie1 = 0.; } + else { partie1=(signe3*NorD23/(nnor3)-(Nor3.Dot(NorD23)/(nnor3*nnor3*nnor3)) + *Nor3).Dot(p3p1); } + if (NorP3P1 <= gp::Resolution()) { partie2 = 0.; } + else {partie2=((Deriv1u3.Dot(p3p1)/(NorP3P1*NorP3P1))*P3P1-Deriv1u3/NorP3P1) + .Dot(signe1*nor1+signe3*nor3); } + Deriv(3,3) = partie1+partie2; +#endif + return Standard_True; +} + + +Standard_Boolean Geom2dGcc_FunctionTanCuCuCu:: Values (const math_Vector&, + math_Vector&, + math_Matrix& ) +{ +#if 0 + gp_Pnt2d Point1; + gp_Pnt2d Point2; + gp_Pnt2d Point3; + gp_Vec2d Tan1; + gp_Vec2d Tan2; + gp_Vec2d Tan3; + gp_Vec2d D21; + gp_Vec2d D22; + gp_Vec2d D23; + InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); + //derivees premieres non normees Deriv1ui. + gp_XY Deriv1u1(Tan1.XY()); + gp_XY Deriv1u2(Tan2.XY()); + gp_XY Deriv1u3(Tan3.XY()); + //pipj (normes) et PiPj (non Normes). + gp_XY P1P2(gp_Vec2d(Point1,Point2).XY()); + gp_XY P2P3(gp_Vec2d(Point2,Point3).XY()); + gp_XY P3P1(gp_Vec2d(Point3,Point1).XY()); + Standard_Real NorP1P2 = P1P2.Modulus(); + Standard_Real NorP2P3 = P2P3.Modulus(); + Standard_Real NorP3P1 = P3P1.Modulus(); + gp_XY p1p2,p2p3,p3p1; + if (NorP1P2 >= gp::Resolution()) { p1p2 = P1P2/NorP1P2; } + else { p1p2 = gp_XY(0.,0.); } + if (NorP2P3 >= gp::Resolution()) { p2p3 = P2P3/NorP2P3; } + else { p2p3 = gp_XY(0.,0.); } + if (NorP3P1 >= gp::Resolution()) { p3p1 = P3P1/NorP3P1; } + else { p3p1 = gp_XY(0.,0.); } + //normales au courbes normees Nori et non nromees nori et norme des nori. + Standard_Real nnor1 = Deriv1u1.Modulus(); + Standard_Real nnor2 = Deriv1u2.Modulus(); + Standard_Real nnor3 = Deriv1u3.Modulus(); + gp_XY Nor1(-Deriv1u1.Y(),Deriv1u1.X()); + gp_XY Nor2(-Deriv1u2.Y(),Deriv1u2.X()); + gp_XY Nor3(-Deriv1u3.Y(),Deriv1u3.X()); + gp_XY nor1,nor2,nor3; + if (nnor1 >= gp::Resolution()) { nor1 = Nor1/nnor1; } + else { nor1 = gp_XY(0.,0.); } + if (nnor2 >= gp::Resolution()) { nor2 = Nor2/nnor2; } + else { nor2 = gp_XY(0.,0.); } + if (nnor3 >= gp::Resolution()) { nor3 = Nor3/nnor3; } + else { nor3 = gp_XY(0.,0.); } + //derivees des normales. + gp_XY NorD21,NorD22,NorD23; + NorD21 = gp_XY(-D21.Y(),D21.X()); + NorD22 = gp_XY(-D22.Y(),D22.X()); + NorD23 = gp_XY(-D23.Y(),D23.X()); + //determination des signes pour les produits scalaires. + Standard_Real signe1 = 1.; + Standard_Real signe2 = 1.; + Standard_Real signe3 = 1.; + gp_XY P = Point1.XY(); + P += Point2.XY(); + P += Point3.XY(); + P /= 3.; + gp_Pnt2d Pcenter(P); + gp_XY fic1 = Pcenter.XY(); + fic1 -= Point1.XY(); + gp_XY fic2 = Pcenter.XY(); + fic2 -= Point2.XY(); + gp_XY fic3 = Pcenter.XY(); + fic3 -= Point3.XY(); + Standard_Real pscal11 = nor1.Dot(fic1); + Standard_Real pscal22 = nor2.Dot(fic2); + Standard_Real pscal33 = nor3.Dot(fic3); + if (pscal11 <= 0.) { signe1 = -1; } + if (pscal22 <= 0.) { signe2 = -1; } + if (pscal33 <= 0.) { signe3 = -1; } + + // Fonctions Fui. + // ============== + Fval(1) = signe1*nor1.Dot(p1p2)+signe2*nor2.Dot(p1p2); + Fval(2) = signe2*nor2.Dot(p2p3)+signe3*nor3.Dot(p2p3); + Fval(3) = signe3*nor3.Dot(p3p1)+signe1*nor1.Dot(p3p1); + // Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3 + // ============================================= + Standard_Real partie1,partie2; + if (nnor1 <= gp::Resolution()) { partie1 = 0.; } + else { partie1 = signe1*(NorD21/nnor1-(Nor1.Dot(NorD21)/(nnor1*nnor1*nnor1)) + *Nor1).Dot(p1p2); } + if (NorP1P2 <= gp::Resolution()) { partie2 = 0.; } + else {partie2=((Deriv1u1.Dot(p1p2)/(NorP1P2*NorP1P2))*P1P2-Deriv1u1/NorP1P2) + .Dot(signe1*nor1+signe2*nor2); } + Deriv(1,1) = partie1 + partie2; + if (nnor2 <= gp::Resolution()) { partie1 = 0.; } + else { partie1=signe2*(NorD22/(nnor2)-(Nor2.Dot(NorD22)/(nnor2*nnor2*nnor2)) + *Nor2).Dot(p1p2); } + if (NorP1P2 <= gp::Resolution()) { partie2 = 0.; } + else{partie2=((-Deriv1u2.Dot(p1p2)/(NorP1P2*NorP1P2))*P1P2+Deriv1u2/NorP1P2) + .Dot(signe1*nor1+signe2*nor2); } + Deriv(1,2) = partie1 + partie2; + Deriv(1,3) = 0.; + Deriv(2,1) = 0.; + if (nnor2 <= gp::Resolution()) { partie1 = 0.; } + else { partie1=signe2*(NorD22/(nnor2)-(Nor2.Dot(NorD22)/(nnor2*nnor2*nnor2)) + *Nor2).Dot(p2p3); } + if (NorP2P3 <= gp::Resolution()) { partie2 = 0.; } + else { partie2=((Deriv1u2.Dot(p2p3)/(NorP2P3*NorP2P3))*P2P3-Deriv1u2/NorP2P3) + .Dot(signe2*nor2+signe3*nor3); } + Deriv(2,2) = partie1 +partie2; + if (nnor3 <= gp::Resolution()) { partie1 = 0.; } + else { partie1=signe3*(NorD23/(nnor3)-(Nor3.Dot(NorD23)/(nnor3*nnor3*nnor3)) + *Nor3).Dot(p2p3); } + if (NorP2P3 <= gp::Resolution()) { partie2 = 0.; } + else {partie2=((-Deriv1u3.Dot(p2p3)/(NorP2P3*NorP2P3))*P2P3+Deriv1u3/NorP2P3) + .Dot(signe2*nor2+signe3*nor3); } + Deriv(2,3) = partie1 + partie2; + if (nnor1 <= gp::Resolution()) { partie1 = 0.; } + else { partie1 =signe1*(NorD21/(nnor1)-(Nor1.Dot(NorD21)/(nnor1*nnor1*nnor1)) + *Nor1).Dot(p3p1); } + if (NorP3P1 <= gp::Resolution()) { partie2 = 0.; } + else {partie2=((-Deriv1u1.Dot(p3p1)/(NorP3P1*NorP3P1))*P3P1+Deriv1u1/NorP3P1) + .Dot(signe1*nor1+signe3*nor3); } + Deriv(3,1) = partie1 + partie2; + Deriv(3,2) = 0.; + if (nnor3 <= gp::Resolution()) { partie1 = 0.; } + else { partie1=signe3*(NorD23/(nnor3)-(Nor3.Dot(NorD23)/(nnor3*nnor3*nnor3)) + *Nor3).Dot(p3p1); } + if (NorP3P1 <= gp::Resolution()) { partie2 = 0.; } + else {partie2=((Deriv1u3.Dot(p3p1)/(NorP3P1*NorP3P1))*P3P1-Deriv1u3/NorP3P1) + .Dot(signe1*nor1+signe3*nor3); } + Deriv(3,3) = partie1+partie2; +#endif + return Standard_True; +} + + diff --git a/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuOnCu.cdl b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuOnCu.cdl new file mode 100644 index 0000000000..10fe7ac8d0 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuOnCu.cdl @@ -0,0 +1,156 @@ +-- Created on: 1991-05-13 +-- Created by: Laurent PAINNOT +-- Copyright (c) 1991-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. + +private class FunctionTanCuCuOnCu from Geom2dGcc inherits FunctionSetWithDerivatives from math + + ---Purpose: This abstract class describes a set on N Functions of + -- M independant variables. + +uses Vector from math, + Matrix from math, + Circ2d from gp, + Lin2d from gp, + Pnt2d from gp, + Vec2d from gp, + Type2 from Geom2dGcc, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc + +raises ConstructionError + +is + + Create (C1 : Curve from Geom2dAdaptor; + C2 : Curve from Geom2dAdaptor; + OnCi : Circ2d from gp ; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + + Create (C1 : Circ2d from gp ; + C2 : Curve from Geom2dAdaptor; + OnCi : Circ2d from gp ; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + + Create (L1 : Lin2d from gp ; + C2 : Curve from Geom2dAdaptor; + OnCi : Circ2d from gp ; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + + Create (C1 : Curve from Geom2dAdaptor; + P2 : Pnt2d from gp ; + OnCi : Circ2d from gp ; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + +------------------------------------------------------------------------ + + Create (C1 : Curve from Geom2dAdaptor; + C2 : Curve from Geom2dAdaptor; + OnLi : Lin2d from gp ; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + + Create (C1 : Circ2d from gp ; + C2 : Curve from Geom2dAdaptor; + OnLi : Lin2d from gp ; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + + Create (L1 : Lin2d from gp ; + C2 : Curve from Geom2dAdaptor; + OnLi : Lin2d from gp ; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + + Create (C1 : Curve from Geom2dAdaptor; + P2 : Pnt2d from gp ; + OnLi : Lin2d from gp ; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + +----------------------------------------------------------------------- + + Create (C1 : Curve from Geom2dAdaptor; + C2 : Curve from Geom2dAdaptor; + OnCu : Curve from Geom2dAdaptor; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + + Create (C1 : Circ2d from gp ; + C2 : Curve from Geom2dAdaptor; + OnCu : Curve from Geom2dAdaptor; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + + Create (L1 : Lin2d from gp ; + C2 : Curve from Geom2dAdaptor; + OnCu : Curve from Geom2dAdaptor; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + + Create (C1 : Curve from Geom2dAdaptor; + P1 : Pnt2d from gp ; + OnCu : Curve from Geom2dAdaptor; + Rad : Real from Standard ) +returns FunctionTanCuCuOnCu from Geom2dGcc; + +InitDerivative(me : in out ; + X : Vector from math ; + Point1,Point2,Point3 : out Pnt2d from gp ; + Tan1,Tan2,Tan3,D21,D22,D23 : out Vec2d from gp ) +raises ConstructionError +is static; + + NbVariables(me) returns Integer; + ---Purpose: Returns the number of variables of the function. + + NbEquations(me) returns Integer; + ---Purpose: Returns the number of equations of the function. + + Value(me : in out ; + X : Vector from math; + F : out Vector from math) returns Boolean; + ---Purpose: Computes the values of the Functions for the variable . + + Derivatives(me : in out ; + X : Vector from math; + D : out Matrix from math) returns Boolean; + ---Purpose: Returns the values of the derivatives for the variable . + + Values(me : in out ; + X : Vector from math; + F : out Vector from math; + D : out Matrix from math) returns Boolean; + ---Purpose: Returns the values of the functions and the derivatives + -- for the variable . + +fields + +Curv1 : Curve from Geom2dAdaptor; +Curv2 : Curve from Geom2dAdaptor; +Circ1 : Circ2d from gp ; +Lin1 : Lin2d from gp ; +Pnt2 : Pnt2d from gp ; +Circon : Circ2d from gp ; +Linon : Lin2d from gp ; +Curvon : Curve from Geom2dAdaptor; +FirstRad : Real from Standard ; +TheType : Type2 from Geom2dGcc ; + +end FunctionTanCuCuOnCu; + diff --git a/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuOnCu.cxx b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuOnCu.cxx new file mode 100644 index 0000000000..1cce9a2151 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuCuOnCu.cxx @@ -0,0 +1,413 @@ +// Created on: 1992-01-20 +// Created by: Remi GILET +// 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. + +#include + +#include +#include + +#include + +void Geom2dGcc_FunctionTanCuCuOnCu:: + InitDerivative(const math_Vector& X, + gp_Pnt2d& Point1, + gp_Pnt2d& Point2, + gp_Pnt2d& Point3, + gp_Vec2d& Tan1, + gp_Vec2d& Tan2, + gp_Vec2d& Tan3, + gp_Vec2d& D21, + gp_Vec2d& D22, + gp_Vec2d& D23) { + switch (TheType) { + case Geom2dGcc_CuCuOnCu: + { + Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23); + } + break; + case Geom2dGcc_CiCuOnCu: + { + ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23); + } + break; + case Geom2dGcc_LiCuOnCu: + { + ElCLib::D1(X(1),Lin1,Point1,Tan1); + D21 = gp_Vec2d(0.,0.); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23); + } + break; + case Geom2dGcc_CuPtOnCu: + { + Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(Curvon,X(3),Point3,Tan3,D23); + Point2 = Pnt2; + Tan2 = gp_Vec2d(0.,0.); + D22 = gp_Vec2d(0.,0.); + } + break; + case Geom2dGcc_CuCuOnCi: + { + Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + ElCLib::D2(X(3),Circon,Point3,Tan3,D23); + } + break; + case Geom2dGcc_CiCuOnCi: + { + ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + ElCLib::D2(X(3),Circon,Point3,Tan3,D23); + } + break; + case Geom2dGcc_LiCuOnCi: + { + ElCLib::D1(X(1),Lin1,Point1,Tan1); + D21 = gp_Vec2d(0.,0.); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + ElCLib::D2(X(3),Circon,Point3,Tan3,D23); + } + break; + case Geom2dGcc_CuPtOnCi: + { + Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21); + Point2 = Pnt2; + Tan2 = gp_Vec2d(0.,0.); + D22 = gp_Vec2d(0.,0.); + ElCLib::D2(X(3),Circon,Point3,Tan3,D23); + } + break; + case Geom2dGcc_CuCuOnLi: + { + Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + ElCLib::D1(X(3),Linon,Point3,Tan3); + D23 = gp_Vec2d(0.,0.); + } + break; + case Geom2dGcc_CiCuOnLi: + { + ElCLib::D2(X(1),Circ1,Point1,Tan1,D21); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + ElCLib::D1(X(3),Linon,Point3,Tan3); + D23 = gp_Vec2d(0.,0.); + } + break; + case Geom2dGcc_LiCuOnLi: + { + ElCLib::D1(X(1),Lin1,Point1,Tan1); + Geom2dGcc_CurveTool::D2(Curv2,X(2),Point2,Tan2,D22); + D21 = gp_Vec2d(0.,0.); + ElCLib::D1(X(3),Linon,Point3,Tan3); + D23 = gp_Vec2d(0.,0.); + } + break; + case Geom2dGcc_CuPtOnLi: + { + Geom2dGcc_CurveTool::D2(Curv1,X(1),Point1,Tan1,D21); + Point2 = Pnt2; + Tan2 = gp_Vec2d(0.,0.); + D22 = gp_Vec2d(0.,0.); + ElCLib::D1(X(3),Linon,Point3,Tan3); + D23 = gp_Vec2d(0.,0.); + } + break; + default: + { + Standard_ConstructionError::Raise(); + } + } +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 , + const Geom2dAdaptor_Curve& C2 , + const Geom2dAdaptor_Curve& C3 , + const Standard_Real Rad ) { + Curv1 = C1; + Curv2 = C2; + Curvon = C3; + FirstRad = Rad; + TheType = Geom2dGcc_CuCuOnCu; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const gp_Circ2d& C1 , + const Geom2dAdaptor_Curve& C2 , + const Geom2dAdaptor_Curve& C3 , + const Standard_Real Rad ) { + Circ1 = C1; + Curv2 = C2; + Curvon = C3; + FirstRad = Rad; + TheType = Geom2dGcc_CiCuOnCu; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const gp_Lin2d& L1 , + const Geom2dAdaptor_Curve& C2 , + const Geom2dAdaptor_Curve& C3 , + const Standard_Real Rad ) { + Lin1 = L1; + Curv2 = C2; + Curvon = C3; + FirstRad = Rad; + TheType = Geom2dGcc_LiCuOnCu; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 , + const gp_Pnt2d& P2 , + const Geom2dAdaptor_Curve& C3 , + const Standard_Real Rad ) { + Curv1 = C1; + Pnt2 = P2; + Curvon = C3; + FirstRad = Rad; + TheType = Geom2dGcc_CuPtOnCu; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 , + const Geom2dAdaptor_Curve& C2 , + const gp_Lin2d& OnLi , + const Standard_Real Rad ) { + Curv1 = C1; + Curv2 = C2; + Linon = OnLi; + FirstRad = Rad; + TheType = Geom2dGcc_CuCuOnLi; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const gp_Circ2d& C1 , + const Geom2dAdaptor_Curve& C2 , + const gp_Lin2d& OnLi , + const Standard_Real Rad ) { + Circ1 = C1; + Curv2 = C2; + Linon = OnLi; + FirstRad = Rad; + TheType = Geom2dGcc_CiCuOnLi; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const gp_Lin2d& L1 , + const Geom2dAdaptor_Curve& C2 , + const gp_Lin2d& OnLi , + const Standard_Real Rad ) { + Lin1 = L1; + Curv2 = C2; + Linon = OnLi; + FirstRad = Rad; + TheType = Geom2dGcc_LiCuOnLi; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 , + const gp_Pnt2d& P2 , + const gp_Lin2d& OnLi , + const Standard_Real Rad ) { + Curv1 = C1; + Pnt2 = P2; + Linon = OnLi; + FirstRad = Rad; + TheType = Geom2dGcc_CuPtOnLi; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 , + const Geom2dAdaptor_Curve& C2 , + const gp_Circ2d& OnCi , + const Standard_Real Rad ) { + Curv1 = C1; + Curv2 = C2; + Circon = OnCi; + FirstRad = Rad; + TheType = Geom2dGcc_CuCuOnCi; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const gp_Circ2d& C1 , + const Geom2dAdaptor_Curve& C2 , + const gp_Circ2d& OnCi , + const Standard_Real Rad ) { + Circ1 = C1; + Curv2 = C2; + Circon = OnCi; + FirstRad = Rad; + TheType = Geom2dGcc_CuCuOnCi; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const gp_Lin2d& L1 , + const Geom2dAdaptor_Curve& C2 , + const gp_Circ2d& OnCi , + const Standard_Real Rad ) { + Lin1 = L1; + Curv2 = C2; + Circon = OnCi; + FirstRad = Rad; + TheType = Geom2dGcc_LiCuOnCi; +} + +Geom2dGcc_FunctionTanCuCuOnCu:: + Geom2dGcc_FunctionTanCuCuOnCu(const Geom2dAdaptor_Curve& C1 , + const gp_Pnt2d& P2 , + const gp_Circ2d& OnCi , + const Standard_Real Rad ) { + Curv1 = C1; + Pnt2 = P2; + Circon = OnCi; + FirstRad = Rad; + TheType = Geom2dGcc_CuPtOnCi; +} + +Standard_Integer Geom2dGcc_FunctionTanCuCuOnCu:: + NbVariables () const { return 4; } + +Standard_Integer Geom2dGcc_FunctionTanCuCuOnCu:: + NbEquations () const { return 4; } + +Standard_Boolean Geom2dGcc_FunctionTanCuCuOnCu:: + Value (const math_Vector& X , + math_Vector& Fval ) { + gp_Pnt2d Point1,Point2,Point3; + gp_Vec2d Tan1,Tan2,Tan3,D21,D22,D23; + InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); +//pipj (normes) et PiPj (non Normes). + gp_Vec2d P1P2(Point1,Point2); + gp_Vec2d P2P3(Point2,Point3); + gp_Vec2d P3P1(Point3,Point1); + gp_Vec2d p1p2,p2p3,p3p1; +// if (FirstRad < 1.) {FirstRad = 1.; } + p1p2 = P1P2/FirstRad; + p2p3 = P2P3/FirstRad; + p3p1 = P3P1/FirstRad; +//norme des Tani. + Standard_Real nnor1 = Tan1.Magnitude(); + Standard_Real nnor2 = Tan2.Magnitude(); +// Fonctions Fui. +// ============== + Fval(1) = (P3P1.Dot(P3P1)-X(4)*X(4))/(FirstRad*FirstRad); + Fval(2) = (P2P3.Dot(P2P3)-X(4)*X(4))/(FirstRad*FirstRad); + Fval(3) = P3P1.Dot(Tan1)/(nnor1*FirstRad); + Fval(4) = P2P3.Dot(Tan2)/(nnor2*FirstRad); + return Standard_True; +} + +Standard_Boolean Geom2dGcc_FunctionTanCuCuOnCu:: + Derivatives (const math_Vector& X , + math_Matrix& Deriv ) { + gp_Pnt2d Point1,Point2,Point3; + gp_Vec2d Tan1,Tan2,Tan3; + gp_Vec2d D21,D22,D23; + InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); +//pipj (normes) et PiPj (non Normes). + gp_Vec2d P1P2(Point1,Point2); + gp_Vec2d P2P3(Point2,Point3); + gp_Vec2d P3P1(Point3,Point1); + gp_Vec2d p1p2,p2p3,p3p1; +// if (FirstRad < 1.) {FirstRad = 1.; } + p1p2 = P1P2/FirstRad; + p2p3 = P2P3/FirstRad; + p3p1 = P3P1/FirstRad; +//normales au courbes normees Nori et non nromees nori et norme des nori. + Standard_Real nnor1 = Tan1.Magnitude(); + Standard_Real nnor2 = Tan2.Magnitude(); +// Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3 +// ============================================= + Deriv(1,1) = 2.*Tan1.Dot(P3P1)/(FirstRad*FirstRad); + Deriv(1,2) = 0.; + Deriv(1,3) = -2.*Tan3.Dot(P3P1)/(FirstRad*FirstRad); + Deriv(1,4) = -2.*X(4)/(FirstRad*FirstRad); + + Deriv(2,1) = 0.; + Deriv(2,2) = -2.*Tan2.Dot(P2P3)/(FirstRad*FirstRad); + Deriv(2,3) = 2.*Tan3.Dot(P2P3)/(FirstRad*FirstRad); + Deriv(2,4) = -2.*X(4)/(FirstRad*FirstRad); + + Deriv(3,1) = (P3P1.Dot(D21)+Tan1.Dot(Tan1))/(FirstRad*nnor1)- + (P3P1.Dot(Tan1)*D21.Dot(Tan1))/(FirstRad*nnor1*nnor1*nnor1); + Deriv(3,2) = 0.; + Deriv(3,3) = -(Tan3.Dot(Tan1))/(FirstRad*nnor1); + Deriv(3,4) = 0.; + + Deriv(4,1) = 0.; + Deriv(4,2) = (P2P3.Dot(D22)-Tan2.Dot(Tan2))/(FirstRad*nnor2)- + P2P3.Dot(Tan2)*Tan2.Dot(D22)/(FirstRad*nnor2*nnor2*nnor2); + Deriv(4,3) = Tan3.Dot(Tan2)/(FirstRad*nnor1); + Deriv(4,4) = 0.; + return Standard_True; +} + +Standard_Boolean Geom2dGcc_FunctionTanCuCuOnCu:: + Values (const math_Vector& X , + math_Vector& Fval , + math_Matrix& Deriv ) { + gp_Pnt2d Point1,Point2,Point3; + gp_Vec2d Tan1,Tan2,Tan3; + gp_Vec2d D21,D22,D23; + InitDerivative(X,Point1,Point2,Point3,Tan1,Tan2,Tan3,D21,D22,D23); +//pipj (normes) et PiPj (non Normes). + gp_Vec2d P1P2(Point1,Point2); + gp_Vec2d P2P3(Point2,Point3); + gp_Vec2d P3P1(Point3,Point1); + gp_Vec2d p1p2,p2p3,p3p1; +// if (FirstRad < 1.) {FirstRad = 1.; } + p1p2 = P1P2/FirstRad; + p2p3 = P2P3/FirstRad; + p3p1 = P3P1/FirstRad; +//normales au courbes normees Nori et non nromees nori et norme des nori. + Standard_Real nnor1 = Tan1.Magnitude(); + Standard_Real nnor2 = Tan2.Magnitude(); +// Fonctions Fui. +// ============== + Fval(1) = (P3P1.Dot(P3P1)-X(4)*X(4))/(FirstRad*FirstRad); + Fval(2) = (P2P3.Dot(P2P3)-X(4)*X(4))/(FirstRad*FirstRad); + Fval(3) = P3P1.Dot(Tan1)/(nnor1*FirstRad); + Fval(4) = P2P3.Dot(Tan2)/(nnor2*FirstRad); +// Derivees dFui/uj 1 <= ui <= 3 , 1 <= uj <= 3 +// ============================================= + Deriv(1,1) = 2.*Tan1.Dot(P3P1)/(FirstRad*FirstRad); + Deriv(1,2) = 0.; + Deriv(1,3) = -2.*Tan3.Dot(P3P1)/(FirstRad*FirstRad); + Deriv(1,4) = -2.*X(4)/(FirstRad*FirstRad); + + Deriv(2,1) = 0.; + Deriv(2,2) = -2.*Tan2.Dot(P2P3)/(FirstRad*FirstRad); + Deriv(2,3) = 2.*Tan3.Dot(P2P3)/(FirstRad*FirstRad); + Deriv(2,4) = -2.*X(4)/(FirstRad*FirstRad); + + Deriv(3,1) = (P3P1.Dot(D21)+Tan1.Dot(Tan1))/(FirstRad*nnor1)- + (P3P1.Dot(Tan1)*D21.Dot(Tan1))/(FirstRad*nnor1*nnor1*nnor1); + Deriv(3,2) = 0.; + Deriv(3,3) = -(Tan3.Dot(Tan1))/(FirstRad*nnor1); + Deriv(3,4) = 0.; + + Deriv(4,1) = 0.; + Deriv(4,2) = (P2P3.Dot(D22)-Tan2.Dot(Tan2))/(FirstRad*nnor2)- + P2P3.Dot(Tan2)*Tan2.Dot(D22)/(FirstRad*nnor2*nnor2*nnor2); + Deriv(4,3) = Tan3.Dot(Tan2)/(FirstRad*nnor1); + Deriv(4,4) = 0.; + return Standard_True; +} + diff --git a/src/Geom2dGcc/Geom2dGcc_FunctionTanCuPnt.cdl b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuPnt.cdl new file mode 100644 index 0000000000..e7041d9649 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuPnt.cdl @@ -0,0 +1,63 @@ +-- Created on: 1992-02-20 +-- Created by: Remy GILET +-- 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. + +private class FunctionTanCuPnt from Geom2dGcc + +inherits FunctionWithDerivative from math + + ---Purpose: This abstract class describes a Function of 1 Variable + -- used to find a line tangent to a curve and passing + -- through a point. + +uses + Pnt2d from gp, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc + +is + +Create (C : Curve from Geom2dAdaptor ; + Point : Pnt2d from gp ) returns FunctionTanCuPnt from Geom2dGcc; + +Value (me : in out ; + X : Real ; + F : out Real ) returns Boolean; + ---Purpose: Computes the value of the function F for the variable X. + -- It returns True if the computation is successfully done, + -- False otherwise. + +Derivative (me : in out ; + X : Real ; + Deriv : out Real ) returns Boolean; + ---Purpose: Computes the derivative of the function F for the variable X. + -- It returns True if the computation is successfully done, + -- False otherwise. + +Values (me : in out ; + X : Real ; + F : out Real ; + Deriv : out Real ) returns Boolean; + ---Purpose: Computes the value and the derivative of the function F + -- for the variable X. + -- It returns True if the computation is successfully done, + -- False otherwise. + +fields + +TheCurv : Curve from Geom2dAdaptor; +ThePoint : Pnt2d from gp; + +end FunctionTanCuPnt; diff --git a/src/Geom2dGcc/Geom2dGcc_FunctionTanCuPnt.cxx b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuPnt.cxx new file mode 100644 index 0000000000..a52f486ed9 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_FunctionTanCuPnt.cxx @@ -0,0 +1,100 @@ +// Created on: 1992-01-20 +// Created by: Remi GILET +// 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. + +#include + +#include +#include +#include +#include + +#include + +//========================================================================= +// soit P1 le point sur la courbe Geom2dAdaptor_Curve d abscisse u. + +// soit C le point ThePoint. + +// Nous cherchons donc les zeros de la fonction suivante: + +// + +// --> --> + +// CP1 /\ T + +// --------------- = F(u) + +// ||CP1|| * ||T|| + +// + +// La derivee de cette fonction est : + +// CP1 /\ N (T.N)*((CP1/\T).((CP1/\T)) + +// f(u) = -------- - -------------------------------- + +// N.N N*N*N*CP1*CP1*CP1 + +//========================================================================= + +Geom2dGcc_FunctionTanCuPnt:: +Geom2dGcc_FunctionTanCuPnt(const Geom2dAdaptor_Curve& C , + const gp_Pnt2d& Point ) { + TheCurv = C; + ThePoint = Point; +} + + +Standard_Boolean Geom2dGcc_FunctionTanCuPnt:: +Value (const Standard_Real X , + Standard_Real& Fval ) { + gp_Pnt2d Point; + gp_Vec2d Vect; + Geom2dGcc_CurveTool::D1(TheCurv,X,Point,Vect); + Standard_Real NormeD1 = Vect.Magnitude(); + gp_Vec2d TheDirection(ThePoint,Point); + Standard_Real NormeDir = TheDirection.Magnitude(); + Fval = TheDirection.Crossed(Vect)/(NormeD1*NormeDir); + return Standard_True; +} + +Standard_Boolean Geom2dGcc_FunctionTanCuPnt:: +Derivative (const Standard_Real X , + Standard_Real& Deriv ) { + gp_Pnt2d Point; + gp_Vec2d Vec1; + gp_Vec2d Vec2; + Geom2dGcc_CurveTool::D2(TheCurv,X,Point,Vec1,Vec2); + gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY())); + Standard_Real NormeD1 = Vec1.Magnitude(); + Standard_Real NormeDir = TheDirection.Magnitude(); + Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)- + (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))* + (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+ + Vec1.Dot(TheDirection)/(NormeDir*NormeDir)); + return Standard_True; +} + +Standard_Boolean Geom2dGcc_FunctionTanCuPnt:: +Values (const Standard_Real X , + Standard_Real& Fval , + Standard_Real& Deriv ) { + gp_Pnt2d Point; + gp_Vec2d Vec1; + gp_Vec2d Vec2; + Geom2dGcc_CurveTool::D2(TheCurv,X,Point,Vec1,Vec2); + gp_Vec2d TheDirection(ThePoint.XY(),gp_XY(Point.XY())); + Standard_Real NormeD1 = Vec1.Magnitude(); + Standard_Real NormeDir = TheDirection.Magnitude(); + Fval = TheDirection.Crossed(Vec1)/(NormeD1*NormeDir); + Deriv = TheDirection.Crossed(Vec2)/(NormeD1*NormeDir)- + (TheDirection.Crossed(Vec1)/(NormeD1*NormeDir))* + (Vec1.Dot(Vec2)/(NormeD1*NormeD1)+ + Vec1.Dot(TheDirection)/(NormeDir*NormeDir)); + + // cout << "U = "<< X << " F ="<< Fval <<" DF ="<< Deriv< + +#include +#include + +#include +#include + +Geom2dGcc_FunctionTanObl:: +Geom2dGcc_FunctionTanObl(const Geom2dAdaptor_Curve& C, + const gp_Dir2d& Dir ) +{ + TheCurv = C; + TheDirection = Dir; +} + + +Standard_Boolean Geom2dGcc_FunctionTanObl:: +Value (const Standard_Real X, + Standard_Real& Fval ) { + gp_Pnt2d Point; + gp_Vec2d Vect; + Geom2dGcc_CurveTool::D1(TheCurv,X,Point,Vect); + Standard_Real NormeD1 = Vect.Magnitude(); + Fval = TheDirection.XY().Crossed(Vect.XY())/NormeD1; + return Standard_True; +} + +Standard_Boolean Geom2dGcc_FunctionTanObl:: +Derivative (const Standard_Real X, + Standard_Real& Deriv ) +{ + gp_Pnt2d Point; + gp_Vec2d Vec1; + gp_Vec2d Vec2; + Geom2dGcc_CurveTool::D2(TheCurv,X,Point,Vec1,Vec2); + Standard_Real NormeD1 = Vec1.Magnitude(); + Deriv = TheDirection.XY().Crossed(Vec2.XY())/NormeD1- + Vec1.XY().Dot(Vec2.XY())*TheDirection.XY().Crossed(Vec1.XY())/NormeD1; + return Standard_True; +} + +Standard_Boolean Geom2dGcc_FunctionTanObl:: +Values (const Standard_Real X , + Standard_Real& Fval , + Standard_Real& Deriv ) { + gp_Pnt2d Point; + gp_Vec2d Vec1; + gp_Vec2d Vec2; + Geom2dGcc_CurveTool::D2(TheCurv,X,Point,Vec1,Vec2); + Standard_Real NormeD1 = Vec1.Magnitude(); + Fval = TheDirection.XY().Crossed(Vec1.XY())/NormeD1; + Deriv = TheDirection.XY().Crossed(Vec2.XY())/NormeD1- + Vec1.XY().Dot(Vec2.XY())*TheDirection.XY().Crossed(Vec1.XY())/NormeD1; + return Standard_True; +} + diff --git a/src/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cdl b/src/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cdl index d9318e385a..c82711b5cf 100644 --- a/src/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cdl @@ -43,7 +43,7 @@ uses Pnt2d from gp, Array1OfLin2d from TColgp, Position from GccEnt, Array1OfPosition from GccEnt, - MyL2d2Tan from Geom2dGcc, + Lin2d2TanIter from Geom2dGcc, Curve from Geom2dAdaptor raises NotDone from StdFail, @@ -187,7 +187,7 @@ is static; -- Modified by Sergey KHROMOV - Wed Oct 16 12:04:52 2002 Begin Add(me: in out; theIndex: Integer from Standard; - theLin : MyL2d2Tan from Geom2dGcc; + theLin : Lin2d2TanIter from Geom2dGcc; theTol : Real from Standard; theC1 : Curve from Geom2dAdaptor; theC2 : Curve from Geom2dAdaptor) diff --git a/src/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cxx b/src/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cxx index a34b0e64c2..d9f5284420 100644 --- a/src/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Lin2d2Tan.cxx @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -93,7 +93,7 @@ Geom2dGcc_Lin2d2Tan:: Param2 = a2FPar; for (j = 0; j <= aNbSamples2 && NbrSol < 4; j++) { - Geom2dGcc_MyL2d2Tan Lin(Qc1,Qc2,Param1,Param2,Tolang); + Geom2dGcc_Lin2d2TanIter Lin(Qc1,Qc2,Param1,Param2,Tolang); if (Lin.IsDone()) { if (Add(NbrSol + 1, Lin, Tolang, C1, C2)) @@ -158,7 +158,7 @@ Geom2dGcc_Lin2d2Tan:: Standard_Integer i; for (i = 0; i <= aNbSamples && NbrSol < 2; i++) { - Geom2dGcc_MyL2d2Tan Lin(Qc1,ThePoint,Param1,Tolang); + Geom2dGcc_Lin2d2TanIter Lin(Qc1,ThePoint,Param1,Tolang); if (Lin.IsDone()) { if (Add(NbrSol + 1, Lin, Tolang, C1, Geom2dAdaptor_Curve())) @@ -226,7 +226,7 @@ Geom2dGcc_Lin2d2Tan:: else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); Geom2dGcc_QCurve Qc2(C2,Qualified2.Qualifier()); - Geom2dGcc_MyL2d2Tan Lin(Qc1,Qc2,Param1,Param2,Tolang); + Geom2dGcc_Lin2d2TanIter Lin(Qc1,Qc2,Param1,Param2,Tolang); WellDone = Lin.IsDone(); // Modified by Sergey KHROMOV - Thu Apr 5 17:51:59 2001 Begin if (WellDone) { @@ -284,7 +284,7 @@ Geom2dGcc_Lin2d2Tan:: } else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); - Geom2dGcc_MyL2d2Tan Lin(Qc1,ThePoint,Param1,Tolang); + Geom2dGcc_Lin2d2TanIter Lin(Qc1,ThePoint,Param1,Tolang); WellDone = Lin.IsDone(); // Modified by Sergey KHROMOV - Thu Apr 5 17:53:01 2001 Begin if (WellDone) { @@ -355,7 +355,7 @@ void Geom2dGcc_Lin2d2Tan:: } Standard_Boolean Geom2dGcc_Lin2d2Tan::Add(const Standard_Integer theIndex, - const Geom2dGcc_MyL2d2Tan &theLin, + const Geom2dGcc_Lin2d2TanIter &theLin, const Standard_Real theTol, const Geom2dAdaptor_Curve &theC1, const Geom2dAdaptor_Curve &theC2) diff --git a/src/Geom2dGcc/Geom2dGcc_Lin2d2TanIter.cdl b/src/Geom2dGcc/Geom2dGcc_Lin2d2TanIter.cdl new file mode 100644 index 0000000000..73ae1eb924 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Lin2d2TanIter.cdl @@ -0,0 +1,164 @@ +-- Created on: 1991-04-24 +-- Created by: Remi GILET +-- Copyright (c) 1991-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. + +class Lin2d2TanIter from Geom2dGcc + + ---Purpose: This class implements the algorithms used to + -- create 2d lines tangent to 2 other elements which + -- can be circles, curves or points. + -- More than one argument must be a curve. + -- + -- Note: Some constructors may check the type of the qualified argument + -- and raise BadQualifier Error in case of incorrect couple (qualifier, + -- curv). + -- For example: "EnclosedCirc". + +uses Pnt2d from gp, + Lin2d from gp, + QualifiedCirc from GccEnt, + Position from GccEnt, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + QCurve from Geom2dGcc + +raises BadQualifier from GccEnt, + NotDone from StdFail + +is + +Create (Qualified1 : QCurve from Geom2dGcc ; + ThePoint : Pnt2d ; + Param1 : Real ; + Tolang : Real ) returns Lin2d2TanIter from Geom2dGcc + ---Purpose: This class implements the algorithms used to create 2d + -- lines passing thrue a point and tangent to a curve. + -- Tolang is used to determine the tolerance for the + -- tangency points. + -- Param2 is used for the initial guess on the curve. +raises BadQualifier from GccEnt; + +Create (Qualified1 : QualifiedCirc ; + Qualified2 : QCurve from Geom2dGcc ; + Param2 : Real ; + Tolang : Real ) returns Lin2d2TanIter from Geom2dGcc +raises BadQualifier from GccEnt; + ---Purpose: This class implements the algorithms used to create 2d + -- line tangent to a circle and to a cuve. + -- Tolang is used to determine the tolerance for the + -- tangency points. + -- Param2 is used for the initial guess on the curve. + -- Exception BadQualifier is raised in the case of + -- EnclosedCirc + +Create (Qualified1 : QCurve from Geom2dGcc ; + Qualified2 : QCurve from Geom2dGcc ; + Param1 : Real ; + Param2 : Real ; + Tolang : Real ) returns Lin2d2TanIter from Geom2dGcc +raises BadQualifier from GccEnt; + ---Purpose: This class implements the algorithms used to create 2d + -- line tangent to two curves. + -- Tolang is used to determine the tolerance for the + -- tangency points. + -- Param1 is used for the initial guess on the first curve. + -- Param2 is used for the initial guess on the second curve. + +-------------------------------------------------------------------------- + +IsDone (me) returns Boolean +is static; + ---Purpose: This methode returns true when there is a solution + -- and false in the other cases. + +ThisSolution(me) returns Lin2d +raises NotDone from StdFail +is static; + ---Purpose: Returns the solution. + +WhichQualifier(me ; + Qualif1 : out Position from GccEnt; + Qualif2 : out Position from GccEnt) +raises NotDone from StdFail +is static; + -- It returns the informations about the qualifiers of the tangency + -- arguments concerning the solution number Index. + -- It returns the real qualifiers (the qualifiers given to the + -- constructor method in case of enclosed, enclosing and outside + -- and the qualifiers computedin case of unqualified). + +Tangency1(me ; + ParSol,ParArg : out Real ; + PntSol : out Pnt2d) +raises NotDone from StdFail +is static; + ---Purpose: Returns informations about the tangency point between the + -- result and the first argument. + -- ParSol is the intrinsic parameter of the point PntSol on + -- the solution curv. + -- ParArg is the intrinsic parameter of the point PntSol on + -- the argument curv. + +Tangency2(me ; + ParSol,ParArg : out Real ; + PntSol : out Pnt2d) +raises NotDone from StdFail +is static; + -- Returns informations about the tangency point between the + -- result and the first argument. + -- ParSol is the intrinsic parameter of the point PntSol on the solution + -- curv. + -- ParArg is the intrinsic parameter of the point PntSol on the argument + -- curv. + +fields + + WellDone : Boolean; + -- True if the algorithm succeeded. + + linsol : Lin2d; + ---Purpose : The solutions. + + qualifier1 : Position from GccEnt; + -- The qualifiers of the first argument. + + qualifier2 : Position from GccEnt; + -- The qualifiers of the first argument. + + pnttg1sol : Pnt2d; + -- The tangency point between the solution and the first argument on + -- the solution. + + pnttg2sol : Pnt2d; + -- The tangency point between the solution and the second argument on + -- the solution. + + par1sol : Real; + -- The parameter of the tangency point between the solution and the + -- first argument on the solution. + + par2sol : Real; + -- The parameter of the tangency point between the solution and the + -- second argument on the solution. + + pararg1 : Real; + -- The parameter of the tangency point between the solution and the first + -- argument on the first argument. + + pararg2 : Real; + -- The parameter of the tangency point between the solution and the second + -- argument on the second argument. + +end Lin2d2TanIter; diff --git a/src/Geom2dGcc/Geom2dGcc_Lin2d2TanIter.cxx b/src/Geom2dGcc/Geom2dGcc_Lin2d2TanIter.cxx new file mode 100644 index 0000000000..b0e28a0ce4 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Lin2d2TanIter.cxx @@ -0,0 +1,286 @@ +// Created on: 1991-12-20 +// Created by: Remi GILET +// Copyright (c) 1991-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. + +//======================================================================== +// CREATION D UNE LIGNE TANGENTE A DEUX COURBES. + +//======================================================================== + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +Geom2dGcc_Lin2d2TanIter:: +Geom2dGcc_Lin2d2TanIter (const GccEnt_QualifiedCirc& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const Standard_Real Param2 , + const Standard_Real Tolang ) { + + par1sol = 0.; + pararg1 = 0.; + + //Standard_Real Tol = Abs(Tolang); + + WellDone = Standard_False; + if (Qualified1.IsEnclosed()) { GccEnt_BadQualifier::Raise(); } + gp_Circ2d C1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + Standard_Real U1 = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Standard_Real U2 = Geom2dGcc_CurveTool::LastParameter(Cu2); + Geom2dGcc_FunctionTanCirCu func(C1,Cu2); + math_FunctionRoot sol(func,Param2,Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolang)),U1,U2,100); + if (sol.IsDone()) { + Standard_Real Usol = sol.Root(); + // gp_Pnt2d Origine,Pt; + // Modified by Sergey KHROMOV - Thu Apr 5 17:39:47 2001 Begin + Standard_Real Norm; + func.Value(Usol, Norm); + if (Abs(Norm) < Tolang) { + // Modified by Sergey KHROMOV - Thu Apr 5 17:39:48 2001 End + gp_Pnt2d Origine; + gp_Vec2d Vect1; + gp_Vec2d Vect2; + Geom2dGcc_CurveTool::D2(Cu2,Usol,Origine,Vect1,Vect2); + gp_Vec2d Vdir(C1.Location().XY() - Origine.XY()); + Standard_Real sign1 = Vect1.Dot(Vdir); + if (sign1 <= 0. ) { Vect1.Reverse(); } + Standard_Real sign2 = Vect2.Crossed(Vect1); + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing() && sign2<=0.) || + (Qualified2.IsOutside() && sign1 <= 0. && sign2 >= 0.) || + (Qualified2.IsEnclosed() && sign1 >= 0. && sign2 >= 0.)) { + if (Qualified1.IsUnqualified() || + (Qualified1.IsOutside() && Vect1.Angle(Vdir) <= 0.) || + (Qualified1.IsEnclosing() && Vect1.Angle(Vdir) >= 0.)) { + gp_Dir2d direc(Vect1); + Standard_Real R1 = C1.Radius(); + gp_XY normal(-R1*direc.Y(),R1*direc.X()); + sign1 = Vect1.Crossed(Vdir); + if (Qualified1.IsEnclosing()) { + pnttg1sol = gp_Pnt2d(C1.Location().XY()-normal); + } + else if (Qualified1.IsOutside()) { + pnttg1sol = gp_Pnt2d(C1.Location().XY()+normal); + } + else { + if (sign1 >= 0.) { + pnttg1sol = gp_Pnt2d(C1.Location().XY()-normal); + } + else { + pnttg1sol = gp_Pnt2d(C1.Location().XY()+normal); + } + } + // if (gp_Vec2d(direc.XY()).Angle(gp_Vec2d(pnttg1sol,Origine)) <= Tol) { + pnttg2sol = Origine; + linsol = gp_Lin2d(pnttg1sol,direc); + WellDone = Standard_True; + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pararg2 = Usol; + par1sol = 0.; + par2sol = pnttg2sol.Distance(pnttg1sol); + pararg1 = 0.; + } + } + } + } +} + +Geom2dGcc_Lin2d2TanIter:: +Geom2dGcc_Lin2d2TanIter (const Geom2dGcc_QCurve& Qualified1 , + const Geom2dGcc_QCurve& Qualified2 , + const Standard_Real Param1 , + const Standard_Real Param2 , + const Standard_Real Tolang ) { + par1sol = 0.; + pararg1 = 0.; + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + Geom2dGcc_FunctionTanCuCu Func(Cu1,Cu2); + math_Vector Umin(1,2); + math_Vector Umax(1,2); + math_Vector Ufirst(1,2); + math_Vector tol(1,2); + Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); + Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1); + Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); + Ufirst(1) = Param1; + Ufirst(2) = Param2; + tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolang)); + tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolang)); + math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax); + if (Root.IsDone()) { + Root.Root(Ufirst); + // Modified by Sergey KHROMOV - Thu Apr 5 17:45:00 2001 Begin + math_Vector Norm(1,2); + Func.Value(Ufirst, Norm); + if (Abs(Norm(1)) < Tolang && Abs(Norm(2)) < Tolang) { + // Modified by Sergey KHROMOV - Thu Apr 5 17:45:01 2001 End + gp_Pnt2d point1,point2; + gp_Vec2d Vect11,Vect12,Vect21,Vect22; + Geom2dGcc_CurveTool::D2(Cu1,Ufirst(1),point1,Vect11,Vect12); + Geom2dGcc_CurveTool::D2(Cu2,Ufirst(2),point2,Vect21,Vect22); + gp_Vec2d Vec(point1.XY(),point2.XY()); + Standard_Real Angle1 = Vec.Angle(Vect12); + Standard_Real sign1 = Vect11.Dot(Vec); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && Angle1 >= 0.) || + (Qualified1.IsOutside() && Angle1 <= 0. && sign1 <= 0.) || + (Qualified1.IsEnclosed() && Angle1 <= 0. && sign1 >= 0.)) { + Angle1 = Vec.Angle(Vect22); + sign1 = Vect21.Dot(Vec); + if (Qualified2.IsUnqualified() || + (Qualified2.IsEnclosing() && Angle1 >= 0.) || + (Qualified2.IsOutside() && Angle1 <= 0. && sign1 <= 0.) || + (Qualified2.IsEnclosed() && Angle1 <= 0. && sign1 >= 0.)) { + qualifier1 = Qualified1.Qualifier(); + qualifier2 = Qualified2.Qualifier(); + pararg1 = Ufirst(1); + par1sol = 0.; + pnttg1sol = point1; + pararg2 = Ufirst(2); + pnttg2sol = point2; + par2sol = pnttg2sol.Distance(pnttg1sol); + gp_Dir2d dir(pnttg2sol.X()-pnttg1sol.X(),pnttg2sol.Y()-pnttg1sol.Y()); + linsol = gp_Lin2d(pnttg1sol,dir); + WellDone = Standard_True; + } + } + } + } +} + +Geom2dGcc_Lin2d2TanIter:: +Geom2dGcc_Lin2d2TanIter (const Geom2dGcc_QCurve& Qualified1 , + const gp_Pnt2d& ThePoint , + const Standard_Real Param1 , + const Standard_Real Tolang ) { + + par1sol = 0.; + pararg1 = 0.; + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + Standard_Real U1 = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Standard_Real U2 = Geom2dGcc_CurveTool::LastParameter(Cu1); + Geom2dGcc_FunctionTanCuPnt func(Cu1,ThePoint); + math_FunctionRoot sol(func,Param1,Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolang)),U1,U2,100); + if (sol.IsDone()) { + Standard_Real Usol = sol.Root(); + // Modified by Sergey KHROMOV - Thu Apr 5 17:45:17 2001 Begin + Standard_Real Norm; + func.Value(Usol, Norm); + if (Abs(Norm) < Tolang) { + // Modified by Sergey KHROMOV - Thu Apr 5 17:45:19 2001 End + gp_Pnt2d Origine; + gp_Vec2d Vect1; + gp_Vec2d Vect2; + Geom2dGcc_CurveTool::D2(Cu1,Usol,Origine,Vect1,Vect2); + gp_Vec2d Vdir(ThePoint.XY()-Origine.XY()); + Standard_Real sign1 = Vect1.Dot(Vdir); + Standard_Real sign2 = Vect2.Crossed(Vdir); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && + ((sign1 >= 0. && sign2 <= 0.) || (sign1 <= 0. && sign2 <= 0.))) || + (Qualified1.IsOutside() && sign1 <= 0. && sign2 >= 0.) || + (Qualified1.IsEnclosed() && sign1 >= 0. && sign2 >= 0.)) { + WellDone = Standard_True; + linsol = gp_Lin2d(Origine,gp_Dir2d(Vdir)); + qualifier1 = Qualified1.Qualifier(); + qualifier2 = GccEnt_noqualifier; + pnttg1sol = Origine; + pnttg2sol = ThePoint; + pararg1 = Usol; + par1sol = 0.; + pararg2 = ThePoint.Distance(Origine); + par2sol = 0.; + } + } + } +} + +Standard_Boolean Geom2dGcc_Lin2d2TanIter:: +IsDone () const { return WellDone; } + +gp_Lin2d Geom2dGcc_Lin2d2TanIter:: +ThisSolution () const +{ + if (!WellDone) StdFail_NotDone::Raise(); + return linsol; +} + +void Geom2dGcc_Lin2d2TanIter:: +WhichQualifier (GccEnt_Position& Qualif1 , + GccEnt_Position& Qualif2 ) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + Qualif1 = qualifier1; + Qualif2 = qualifier2; + } +} + +void Geom2dGcc_Lin2d2TanIter:: +Tangency1 (Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& Pnt) const { + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + ParSol = par1sol; + ParArg = pararg1; + Pnt = pnttg1sol; + } +} + +void Geom2dGcc_Lin2d2TanIter:: +Tangency2 (Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& Pnt) const { + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + ParSol = par2sol; + ParArg = pararg2; + Pnt = pnttg2sol; + } +} + diff --git a/src/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cdl b/src/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cdl index c92a849e8f..40ef11e00a 100644 --- a/src/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cdl @@ -39,11 +39,11 @@ uses Lin2d from gp, Position from GccEnt, Array1OfPosition from GccEnt, Curve from Geom2dAdaptor, - MyL2dTanObl from Geom2dGcc + Lin2dTanOblIter from Geom2dGcc raises BadQualifier from GccEnt, NotDone from StdFail, - IsParallel from GccIter, + IsParallel from Geom2dGcc, OutOfRange from Standard is @@ -151,7 +151,7 @@ Intersection2 (me ; Index : Integer from Standard; ParSol,ParArg : out Real from Standard; PntSol : out Pnt2d from gp ) -raises NotDone from StdFail, IsParallel from GccIter, OutOfRange from Standard +raises NotDone from StdFail, IsParallel from Geom2dGcc, OutOfRange from Standard is static; ---Purpose: Returns the point of intersection PntSol between the -- solution of index Index and the second argument (the line) of this algorithm. @@ -159,7 +159,7 @@ is static; -- solution. ParArg is the parameter of the point PntSol on the second argument (the line). -- Exceptions -- StdFail_NotDone if the construction fails. - -- GccIter_IsParallel if the solution and the second + -- Geom2dGcc_IsParallel if the solution and the second -- argument (the line) are parallel. -- Standard_OutOfRange if Index is less than zero or -- greater than the number of solutions computed by this algorithm. @@ -174,7 +174,7 @@ is static; -- Modified by Sergey KHROMOV - Wed Oct 16 12:04:52 2002 Begin Add(me: in out; theIndex: Integer from Standard; - theLin : MyL2dTanObl from Geom2dGcc; + theLin : Lin2dTanOblIter from Geom2dGcc; theTol : Real from Standard; theC1 : Curve from Geom2dAdaptor) returns Boolean from Standard diff --git a/src/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cxx b/src/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cxx index 2f744e9a4c..710bb243e0 100644 --- a/src/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Lin2dTanObl.cxx @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -75,7 +75,7 @@ Geom2dGcc_Lin2dTanObl:: Standard_Integer i; for (i = 0; i <= aNbSamples && NbrSol < 2; i++) { - Geom2dGcc_MyL2dTanObl Lin(Qc1,TheLine,Param1,TolAng,Angle); + Geom2dGcc_Lin2dTanOblIter Lin(Qc1,TheLine,Param1,TolAng,Angle); if (Lin.IsDone()) { if (Add(NbrSol + 1, Lin, TolAng, C1)) @@ -132,7 +132,7 @@ Geom2dGcc_Lin2dTanObl:: } else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); - Geom2dGcc_MyL2dTanObl Lin(Qc1,TheLine,TolAng,Param1,Angle); + Geom2dGcc_Lin2dTanOblIter Lin(Qc1,TheLine,TolAng,Param1,Angle); WellDone = Lin.IsDone(); if(WellDone) { linsol(1) = Lin.ThisSolution(); @@ -195,7 +195,7 @@ void Geom2dGcc_Lin2dTanObl:: Standard_Boolean Geom2dGcc_Lin2dTanObl::Add (const Standard_Integer theIndex, - const Geom2dGcc_MyL2dTanObl &theLin, + const Geom2dGcc_Lin2dTanOblIter &theLin, const Standard_Real theTol, const Geom2dAdaptor_Curve &theC1) { diff --git a/src/Geom2dGcc/Geom2dGcc_Lin2dTanOblIter.cdl b/src/Geom2dGcc/Geom2dGcc_Lin2dTanOblIter.cdl new file mode 100644 index 0000000000..5966ec1320 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Lin2dTanOblIter.cdl @@ -0,0 +1,136 @@ +-- Created on: 1991-04-24 +-- Created by: Remi GILET +-- Copyright (c) 1991-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. + +class Lin2dTanOblIter from Geom2dGcc + + ---Purpose: This class implements the algorithms used to + -- create 2d line tangent to a curve QualifiedCurv and + -- doing an angle Angle with a line TheLin. + -- The angle must be in Radian. + +uses Lin2d from gp, + Pnt2d from gp, + Position from GccEnt, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + QCurve from Geom2dGcc + +raises BadQualifier from GccEnt, + NotDone from StdFail, + IsParallel from Geom2dGcc + +is + +Create (Qualified1 : QCurve from Geom2dGcc ; + TheLin : Lin2d ; + Param1 : Real ; + TolAng : Real ; + Angle : Real = 0 ) returns Lin2dTanOblIter from Geom2dGcc +raises BadQualifier from GccEnt; + ---Purpose: This class implements the algorithm used to + -- create 2d line tangent to a curve and doing an + -- angle Angle with the line TheLin. + -- Angle must be in Radian. + -- Param2 is the initial guess on the curve QualifiedCurv. + -- Tolang is the angular tolerance. + +-- ........................................................................ + +IsDone(me) returns Boolean +is static; + ---Purpose: This method returns true when there is a solution + -- and false in the other cases. + +ThisSolution(me) returns Lin2d +raises NotDone from StdFail +is static; + -- Returns the solution. + +WhichQualifier(me ; + Qualif1 : out Position from GccEnt) +raises NotDone from StdFail +is static; + -- It returns the informations about the qualifiers of the tangency + -- arguments concerning the solution number Index. + -- It returns the real qualifiers (the qualifiers given to the + -- constructor method in case of enclosed, enclosing and outside + -- and the qualifiers computedin case of unqualified). + +Tangency1(me ; + ParSol,ParArg : out Real ; + PntSol : out Pnt2d) +raises NotDone from StdFail +is static; + -- Returns informations about the tangency point between the + -- result and the first argument. + -- ParSol is the intrinsic parameter of the point ParSol on the solution + -- curv. + -- ParArg is the intrinsic parameter of the point PntSol on the argument + -- curv. + +Intersection2 (me ; + ParSol,ParArg : out Real ; + PntSol : out Pnt2d) +raises NotDone from StdFail, IsParallel from Geom2dGcc +is static; + -- Returns informations about the center (on the curv) of the + -- result and the third argument. + +IsParallel2(me) returns Boolean +raises NotDone from StdFail +is static; + -- Returns informations about the center (on the curv) of the + -- result and the third argument. + +fields + + WellDone : Boolean; + -- True if the algorithm succeeded. + + Paral2 : Boolean; + -- True if the solution is parallel to the second argument (Angle = 0). + + linsol : Lin2d; + ---Purpose : The solution. + + qualifier1 : Position from GccEnt; + -- The qualifiers of the first argument. + + pnttg1sol : Pnt2d; + -- The tangency point between the solution and the first argument on + -- the solution. + + pntint2sol : Pnt2d; + -- The tangency point between the solution and the second argument on + -- the solution. + + par1sol : Real; + -- The parameter of the tangency point between the solution and the + -- first argument on the solution. + + par2sol : Real; + -- The parameter of the intersection point between the solution and the + -- second argument on the solution. + + pararg1 : Real; + -- The parameter of the tangency point between the solution and the first + -- argument on the first argument. + + pararg2 : Real; + -- The parameter of the intersection point between the solution and + -- the second argument on the second argument. + +end Lin2dTanOblIter; diff --git a/src/Geom2dGcc/Geom2dGcc_Lin2dTanOblIter.cxx b/src/Geom2dGcc/Geom2dGcc_Lin2dTanOblIter.cxx new file mode 100644 index 0000000000..5c889a4d57 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Lin2dTanOblIter.cxx @@ -0,0 +1,156 @@ +// Created on: 1991-12-20 +// Created by: Remi GILET +// Copyright (c) 1991-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. + +//======================================================================== +// CREATION D UNE LIGNE TANGENTE A UNE COURBE ET PARALLELE A UNE DROITE. + +//======================================================================== + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +Geom2dGcc_Lin2dTanOblIter:: +Geom2dGcc_Lin2dTanOblIter (const Geom2dGcc_QCurve& Qualified1 , + const gp_Lin2d& TheLin , + const Standard_Real Param1 , + const Standard_Real TolAng , + const Standard_Real Angle ) +{ + + par1sol = 0.; + pararg1 = 0.; + WellDone = Standard_False; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Paral2 = Standard_False; + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + Standard_Real U1 = Geom2dGcc_CurveTool::FirstParameter(Cu1); + Standard_Real U2 = Geom2dGcc_CurveTool::LastParameter(Cu1); + gp_Dir2d Dir(TheLin.Direction()); + Standard_Real A = Dir.X(); + Standard_Real B = Dir.Y(); + gp_Dir2d TheDirection(Dir); + if (Abs(Angle) > Abs(TolAng)) { + if (Abs(Abs(Angle)-M_PI) <= Abs(TolAng)) { + Paral2 = Standard_True; + TheDirection = Dir.Reversed(); + } + else if (Abs(Angle-M_PI/2) <= Abs(TolAng)) { TheDirection=gp_Dir2d(-B,A); } + else if (Abs(Angle+M_PI/2) <= Abs(TolAng)) { TheDirection=gp_Dir2d(B,-A); } + else { + TheDirection=gp_Dir2d(A*Cos(Angle)-B*Sin(Angle), + A*Sin(Angle)+B*Cos(Angle)); + } + } + else { Paral2 = Standard_True; } + Geom2dGcc_FunctionTanObl func(Cu1,TheDirection); + math_FunctionRoot sol(func,Param1, + Geom2dGcc_CurveTool::EpsX(Cu1,Abs(TolAng)),U1,U2,100); + if (sol.IsDone()) { + Standard_Real Usol = sol.Root(); + gp_Pnt2d Origine; + gp_Vec2d Vect1,Vect2; + Geom2dGcc_CurveTool::D2(Cu1,Usol,Origine,Vect1,Vect2); + Standard_Real sign1 = Vect1.XY().Dot(TheDirection.XY()); + Standard_Real sign2 = Vect2.XY().Crossed(TheDirection.XY()); + if (Qualified1.IsUnqualified() || + (Qualified1.IsEnclosing() && sign2<=0.) || + (Qualified1.IsOutside() && sign1 <= 0. && sign2 >= 0.) || + (Qualified1.IsEnclosed() && sign1 >= 0. && sign2 >= 0.)) { + WellDone = Standard_True; + linsol = gp_Lin2d(Origine,TheDirection); + pnttg1sol = Origine; + qualifier1 = Qualified1.Qualifier(); + pararg1 = Usol; + par1sol = 0.; + if (!Paral2) { + IntAna2d_AnaIntersection Intp(linsol,TheLin); + if (Intp.IsDone() && !Intp.IsEmpty()) { + if (Intp.NbPoints()==1) { + pntint2sol = Intp.Point(1).Value(); + par2sol = gp_Vec2d(linsol.Direction()). + Dot(gp_Vec2d(linsol.Location(),pntint2sol)); + pararg2 = gp_Vec2d(TheLin.Direction()). + Dot(gp_Vec2d(TheLin.Location(),pntint2sol)); + } + } + } + } + } +} + +Standard_Boolean Geom2dGcc_Lin2dTanOblIter:: +IsDone () const { return WellDone; } + +gp_Lin2d Geom2dGcc_Lin2dTanOblIter::ThisSolution () const +{ + if (!WellDone) StdFail_NotDone::Raise(); + + return linsol; +} + +void Geom2dGcc_Lin2dTanOblIter:: +WhichQualifier (GccEnt_Position& Qualif1) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + Qualif1 = qualifier1; + } +} + +Standard_Boolean Geom2dGcc_Lin2dTanOblIter:: +IsParallel2 () const { return Paral2; } + +void Geom2dGcc_Lin2dTanOblIter:: +Tangency1 (Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& PntSol) const { + if (!WellDone) { StdFail_NotDone::Raise(); } + else { + ParSol = par1sol; + ParArg = pararg1; + PntSol = gp_Pnt2d(pnttg1sol); + } +} + +void Geom2dGcc_Lin2dTanOblIter:: +Intersection2 (Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& PntSol ) const { + if (!WellDone) { StdFail_NotDone::Raise(); } + else if (Paral2) { Geom2dGcc_IsParallel::Raise(); } + else { + PntSol = pntint2sol; + ParSol = par2sol; + ParArg = pararg2; + } +} + diff --git a/src/QABugs/QABugs_17.cxx b/src/QABugs/QABugs_17.cxx index 28d7a61d1f..03aa9a5cda 100644 --- a/src/QABugs/QABugs_17.cxx +++ b/src/QABugs/QABugs_17.cxx @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -156,7 +156,7 @@ static Standard_Integer BUC60843 (Draw_Interpretor& di, Standard_Integer argc,co Geom2dAdaptor_Curve acur(aCur2d2); Geom2dGcc_QCurve qcur(acur, GccEnt_unqualified); GccEnt_QualifiedCirc qfromcur(aCir2d->Circ2d(), GccEnt_unqualified); - Geom2dGcc_MyL2d2Tan lintan(qfromcur, qcur , par1, tol); + Geom2dGcc_Lin2d2TanIter lintan(qfromcur, qcur , par1, tol); if (lintan.IsDone()) { gp_Lin2d lin = lintan.ThisSolution(); Handle(Geom2d_Line) glin = new Geom2d_Line(lin); @@ -170,7 +170,7 @@ static Standard_Integer BUC60843 (Draw_Interpretor& di, Standard_Integer argc,co Geom2dAdaptor_Curve acur2(aCur2d2); Geom2dGcc_QCurve qcur1(acur1, GccEnt_unqualified); Geom2dGcc_QCurve qcur2(acur2, GccEnt_unqualified); - Geom2dGcc_MyL2d2Tan lintan(qcur1, qcur2 , par1, par2, tol); + Geom2dGcc_Lin2d2TanIter lintan(qcur1, qcur2 , par1, par2, tol); if (lintan.IsDone()) { gp_Lin2d lin = lintan.ThisSolution(); Handle(Geom2d_Line) glin = new Geom2d_Line(lin); diff --git a/src/TKGeomAlgo/PACKAGES b/src/TKGeomAlgo/PACKAGES index d80a909504..37fda2a0a6 100755 --- a/src/TKGeomAlgo/PACKAGES +++ b/src/TKGeomAlgo/PACKAGES @@ -16,7 +16,6 @@ ApproxInt GccAna GccEnt GccInt -GccIter HatchGen Geom2dHatch Law