From: dln Date: Fri, 28 Mar 2014 05:35:15 +0000 (+0400) Subject: 0024773: Convertation of the generic classes to the non-generic. Part 7 X-Git-Tag: V6_8_0_beta~435 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=578ce4bebf7b8bc7c265869977c16097f789720b;p=occt-copy.git 0024773: Convertation of the generic classes to the non-generic. Part 7 1) Generic classes: "GccGeo_Circ2dTanOn", "GccGeo_Circ2d2TanRad", "GccGeo_Circ2d2TanCen", "GccGeo_Circ2d2TanOnRad", "GccGeo_CurvePGTool" from "GccGeo" package converted to the non-generic classes and moved to the "Geom2dGcc" package. Names of this classes were changed to: "Geom2dGcc_Circ2dTanOnGeo", "Geom2dGcc_Circ2d2TanRadGeo", "Geom2dGcc_Circ2d2TanCenGeo", "Geom2dGcc_Circ2d2TanOnRadGeo", "Geom2dGcc_CurveToolGeo". Also "GccGeo_PanGenCurve" unused generic class was deleted. And "GccGeo" package was deleted. --- diff --git a/adm/UDLIST b/adm/UDLIST index 57729e760e..5c2527255d 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -133,7 +133,6 @@ p FairCurve p FilletSurf p GccAna p GccEnt -p GccGeo p GccInt p GccIter p Geom2dAPI diff --git a/src/GccGeo/GccGeo.cdl b/src/GccGeo/GccGeo.cdl deleted file mode 100644 index 8e9d28f13a..0000000000 --- a/src/GccGeo/GccGeo.cdl +++ /dev/null @@ -1,55 +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 GccGeo - - - ---Purpose : - -- This package provides an implementation of analytic algorithms - -- (using only non-persistant entities) used to create 2d lines or - -- circles with geometric constraints. - -uses GccEnt, - GccInt, - IntCurve, - GeomAbs, - TColStd, - Standard, - StdFail, - TColgp, - gp - -is - -generic class CurvePGTool; - -generic class ParGenCurve; - -generic class Circ2dTanCen; - -- Create a 2d circle TANgent to a 2d entity and CENtered on a 2d point. - -generic class Circ2d2TanRad; - -- Create a 2d circle TANgent to 2 2d entities with the given RADius. - -generic class Circ2dTanOnRad; - -- Create a 2d circle TANgent to a 2d entity and centered ON a 2d - -- entity (not a point) with the given radius. - -generic class Circ2d2TanOn; - -- Create a 2d circle TANgent to 2 2d entities (circle, line or point) - -- and centered ON a 2d curve. - -end GccGeo; diff --git a/src/GccGeo/GccGeo_Circ2d2TanOn.cdl b/src/GccGeo/GccGeo_Circ2d2TanOn.cdl deleted file mode 100644 index 60b70808be..0000000000 --- a/src/GccGeo/GccGeo_Circ2d2TanOn.cdl +++ /dev/null @@ -1,301 +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 GccGeo ( - TheCurve as any; -- - TheTool as any; -- - TheQCurve as any; -- as QualifiedCurve from GccEnt - -- (TheCurve) - TheParGenCurve as any; -- as ParGenCurve from GccGeo - -- (TheCurve) - TheHParGenCurve as Transient; - TheCurvePGTool as any; -- as CurvePGTool from GccGeo - -- (Thecurve, - -- TheTool, - -- TheParGenCurve) - TheIntConicCurve as any) -- as TheIntConicCurveOfGOffsetInter from IntCurve - -- (TheParGenCurve, - -- TheCurvePGTool) - - - ---Purpose: This class implements the algorithms used to - -- create 2d circles TANgent to 2 entities and - -- having the center ON a curve. - -- The order of the tangency argument is always - -- QualifiedCirc, QualifiedLin, QualifiedCurv, Pnt2d. - -- the arguments are : - -- - The two tangency arguments (lines, circles or points). - -- - The center line (a curve). - -- - 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, - Array1OfCirc2d from TColgp, - Array1OfPnt2d from TColgp, - Array1OfInteger from TColStd, - Array1OfReal from TColStd, - Position from GccEnt, - Array1OfPosition from GccEnt - -raises NotDone from StdFail, - BadQualifier from GccEnt, - OutOfRange from Standard - -is - -Create(Qualified1 : QualifiedCirc from GccEnt ; - Qualified2 : QualifiedCirc from GccEnt ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to two 2d circles and - -- having the center ON a curve. -raises BadQualifier from GccEnt; - -Create(Qualified1 : QualifiedCirc from GccEnt ; - Qualified2 : QualifiedLin from GccEnt ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d circle and a 2d line - -- having the center ON a curve. -raises BadQualifier from GccEnt; - -Create(Qualified1 : QualifiedCirc from GccEnt ; - Point2 : Pnt2d from gp ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d circle and a point - -- having the center ON a curve. -raises BadQualifier from GccEnt; - -Create(Qualified1 : QualifiedLin from GccEnt ; - Qualified2 : QualifiedLin from GccEnt ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to two 2d lines - -- having the center ON a curve. -raises BadQualifier from GccEnt; - -Create(Qualified1 : QualifiedLin from GccEnt ; - Qualified2 : Pnt2d from gp ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d line and a point - -- having the center ON a 2d line. -raises BadQualifier from GccEnt; - -Create(Point1 : Pnt2d from gp ; - Point2 : Pnt2d from gp ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn ; - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to two points - -- having the center ON a 2d line. - --- .................................................................... - -IsDone(me) returns Boolean from Standard -is static; - ---Purpose: This method returns True if the construction - -- algorithm succeeded. - -NbSolutions(me) returns Integer from Standard - ---Purpose: This method returns the number of solutions. -raises NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -ThisSolution(me ; Index : Integer) returns Circ2d from gp - ---Purpose: Returns the solution number Index and raises OutOfRange - -- exception if Index is greater than the number of solutions. - -- Be careful: the Index is only a way to get all the - -- solutions, but is not associated to those outside the - -- context of the algorithm-object. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions. - -WhichQualifier(me ; - Index : Integer from Standard; - Qualif1 : out Position from GccEnt ; - Qualif2 : out Position from GccEnt ) -raises OutOfRange, NotDone -is static; - ---Purpose: 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 ; - Index : Integer from Standard; - ParSol,ParArg : out Real from Standard; - PntSol : out Pnt2d from gp ) - ---Purpose: Returns informations about the tangency point between the - -- result number Index and the first argument. - -- ParSol is the intrinsic parameter of the point on the - -- solution curv. - -- ParArg is the intrinsic parameter of the point on the - -- argument curv. - -- PntSol is the tangency point on the solution curv. - -- PntArg is the tangency point on the argument curv. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions. - -Tangency2(me ; - Index : Integer from Standard; - ParSol,ParArg : out Real from Standard; - PntSol : out Pnt2d from gp ) - ---Purpose: Returns informations about the tangency point between the - -- result number Index and the second argument. - -- ParSol is the intrinsic parameter of the point on the - -- solution curv. - -- ParArg is the intrinsic parameter of the point on the - -- argument curv. - -- PntSol is the tangency point on the solution curv. - -- PntArg is the tangency point on the argument curv. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions. - -CenterOn3 (me ; - Index : Integer from Standard; - ParArg : out Real from Standard; - PntSol : out Pnt2d from gp ) - ---Purpose: Returns informations about the center (on the curv) - -- of the result. - -- ParArg is the intrinsic parameter of the point on - -- the argument curv. - -- PntSol is the center point of the solution curv. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions. - -IsTheSame1(me ; - Index : Integer from Standard) returns Boolean from Standard - ---Purpose: Returns True if the solution number Index is equal to - -- the first argument and False in the other cases. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions. - -IsTheSame2(me ; - Index : Integer from Standard) returns Boolean from Standard - ---Purpose: Returns True if the solution number Index is equal to - -- the second argument and False in the other cases. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions. - -fields - - WellDone : Boolean from Standard; - ---Purpose: True if the algorithm succeeded. - - NbrSol : Integer from Standard; - ---Purpose: Number of solutions. - - cirsol : Array1OfCirc2d from TColgp; - ---Purpose: The solutions. - - qualifier1 : Array1OfPosition from GccEnt; - ---Purpose: The qualifiers of the first argument. - - qualifier2 : Array1OfPosition from GccEnt; - ---Purpose: The qualifiers of the second argument. - - TheSame1 : Array1OfInteger from TColStd; - ---Purpose: 1 if the solution and the first argument are the same - -- (2 circles). - -- If R1 is the radius of the first argument and Rsol the radius - -- of the solution and dist the distance between the two centers, - -- we consider the two circles are identical if R1+dist-Rsol is - -- less than Tolerance. - -- 0 in the other cases. - - TheSame2 : Array1OfInteger from TColStd; - ---Purpose: 1 if the solution and the second argument are the same - -- (2 circles). - -- If R2 is the radius of the second argument and Rsol the radius - -- of the solution and dist the distance between the two centers, - -- we consider the two circles are identical if R2+dist-Rsol is - -- less than Tolerance. - -- 0 in the other cases. - - pnttg1sol : Array1OfPnt2d from TColgp; - ---Purpose: The tangency point between the solution and the first - -- argument on the solution. - - pnttg2sol : Array1OfPnt2d from TColgp; - ---Purpose: The tangency point between the solution and the second - -- argument on the solution. - - pntcen : Array1OfPnt2d from TColgp; - ---Purpose: The center point of the solution on the third argument. - - par1sol : Array1OfReal from TColStd; - ---Purpose: The parameter of the tangency point between the solution - -- and the first argument on the solution. - - par2sol : Array1OfReal from TColStd; - ---Purpose: The parameter of the tangency point between the solution - -- and the second argument on the solution. - - pararg1 : Array1OfReal from TColStd; - ---Purpose: The parameter of the tangency point between the solution - -- and the first argument on the first argument. - - pararg2 : Array1OfReal from TColStd; - ---Purpose: The parameter of the tangency point between the solution - -- and the second argument on the second argument. - - parcen3 : Array1OfReal from TColStd; - ---Purpose: The parameter of the center point of the solution on the - -- second argument. - -end Circ2d2TanOn; diff --git a/src/GccGeo/GccGeo_Circ2d2TanOn.gxx b/src/GccGeo/GccGeo_Circ2d2TanOn.gxx deleted file mode 100644 index 322f66cf69..0000000000 --- a/src/GccGeo/GccGeo_Circ2d2TanOn.gxx +++ /dev/null @@ -1,1077 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -GccGeo_Circ2d2TanOn:: - GccGeo_Circ2d2TanOn (const GccEnt_QualifiedCirc& Qualified1 , - const GccEnt_QualifiedCirc& Qualified2 , - const TheCurve& OnCurv , - const Standard_Real Tolerance ): - cirsol(1,8) , - qualifier1(1,8), - qualifier2(1,8), - TheSame1(1,8) , - TheSame2(1,8) , - pnttg1sol(1,8) , - pnttg2sol(1,8) , - pntcen(1,8) , - par1sol(1,8) , - par2sol(1,8) , - pararg1(1,8) , - pararg2(1,8) , - parcen3(1,8) -{ - - WellDone = Standard_False; - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - Standard_Real Tol = Abs(Tolerance); - NbrSol = 0; - TColStd_Array1OfReal Rbid(1,2); - TColStd_Array1OfReal RBid(1,2); - TColStd_Array1OfReal Radius(1,2); - 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(); - gp_Circ2d C2 = Qualified2.Qualified(); - Standard_Real R1 = C1.Radius(); - Standard_Real R2 = C2.Radius(); - gp_Dir2d dirx(1.,0.); - gp_Pnt2d center1(C1.Location()); - gp_Pnt2d center2(C2.Location()); - GccAna_Circ2dBisec Bis(C1,C2); - if (Bis.IsDone()) { - TheIntConicCurve Intp; - Standard_Integer nbsolution = Bis.NbSolutions(); - Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(OnCurv); - TheParGenCurve Cu2(HCu2,0.); - firstparam = Max(TheCurvePGTool::FirstParameter(Cu2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(Cu2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(Cu2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(Cu2,lastparam),lastparam,Tol); - Standard_Real Tol1 = Abs(Tolerance); - Standard_Real Tol2 = Tol1; - for (Standard_Integer i = 1 ; i <= nbsolution; i++) { - Handle(GccInt_Bisec) Sol = Bis.ThisSolution(i); - GccInt_IType type = Sol->ArcType(); - switch (type) { - case GccInt_Cir: - { - gp_Circ2d Circ(Sol->Circle()); - IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol1, - ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol2); - D1.SetEquivalentParameters(0.,2.*M_PI); - Intp.Perform(Circ,D1,Cu2,D2,Tol1,Tol2); - } - break; - case GccInt_Ell: - { - gp_Elips2d Elips(Sol->Ellipse()); - IntRes2d_Domain D1(ElCLib::Value(0.,Elips), 0.,Tol1, - ElCLib::Value(2.*M_PI,Elips),2.*M_PI,Tol2); - D1.SetEquivalentParameters(0.,2.*M_PI); - Intp.Perform(Elips,D1,Cu2,D2,Tol1,Tol2); - } - break; - case GccInt_Hpr: - { - gp_Hypr2d Hypr(Sol->Hyperbola()); - IntRes2d_Domain D1(ElCLib::Value(-4.,Hypr),-4.,Tol1, - ElCLib::Value(4.,Hypr),4.,Tol2); - Intp.Perform(Hypr,D1,Cu2,D2,Tol1,Tol2); - } - break; - case GccInt_Lin: - { - gp_Lin2d Line(Sol->Line()); - IntRes2d_Domain D1; - Intp.Perform(Line,D1,Cu2,D2,Tol1,Tol2); - } - break; - default: - { - Standard_ConstructionError::Raise(); - } - } - if (Intp.IsDone()) { - if ((!Intp.IsEmpty())) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { - gp_Pnt2d Center(Intp.Point(j).Value()); - Standard_Real dist1 = Center.Distance(C1.Location()); - Standard_Real dist2 = Center.Distance(C2.Location()); - Standard_Integer nbsol = 0; - Standard_Integer nnsol = 0; - R1 = C1.Radius(); - R2 = C2.Radius(); - if (Qualified1.IsEnclosed()) { - if (dist1-R1 < Tol) { - nbsol = 1; - Rbid(1) = Abs(R1-dist1); - } - } - else if (Qualified1.IsOutside()) { - if (R1-dist1 < Tol) { - nbsol = 1; - Rbid(1) = Abs(dist1-R1); - } - } - else if (Qualified1.IsEnclosing()) { - nbsol = 1; - Rbid(1) = dist1+R1; - } - else if (Qualified1.IsUnqualified()) { - nbsol = 2; - Rbid(1) = dist1+R1; - Rbid(1) = Abs(dist1-R1); - } - if (Qualified2.IsEnclosed() && nbsol != 0) { - if (dist2-R2 < Tol) { - RBid(1) = Abs(R2-dist2); - } - } - else if (Qualified2.IsOutside() && nbsol != 0) { - if (R2-dist2 < Tol) { - RBid(1) = Abs(R2-dist2); - } - } - else if (Qualified2.IsEnclosing() && nbsol != 0) { - RBid(1) = dist2+R2; - } - else if (Qualified2.IsUnqualified() && nbsol != 0) { - RBid(1) = dist2+R2; - RBid(2) = Abs(R2-dist2); - } - for (Standard_Integer isol = 1; isol <= nbsol ; isol++) { - for (Standard_Integer jsol = 1; jsol <= nbsol ; jsol++) { - if (Abs(Rbid(isol)-RBid(jsol)) <= Tol) { - nnsol++; - Radius(nnsol) = (RBid(jsol)+Rbid(isol))/2.; - } - } - } - if (nnsol > 0) { - for (Standard_Integer k = 1 ; k <= nnsol ; k++) { - NbrSol++; - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius(k)); -// ========================================================== - Standard_Real distcc1 = Center.Distance(center1); - Standard_Real distcc2 = Center.Distance(center2); - if (!Qualified1.IsUnqualified()) { - qualifier1(NbrSol) = Qualified1.Qualifier(); - } - else if (Abs(distcc1+Radius(i)-R1) < Tol) { - qualifier1(NbrSol) = GccEnt_enclosed; - } - else if (Abs(distcc1-R1-Radius(i)) < Tol) { - qualifier1(NbrSol) = GccEnt_outside; - } - else { qualifier1(NbrSol) = GccEnt_enclosing; } - if (!Qualified2.IsUnqualified()) { - qualifier2(NbrSol) = Qualified2.Qualifier(); - } - else if (Abs(distcc2+Radius(i)-R2) < Tol) { - qualifier2(NbrSol) = GccEnt_enclosed; - } - else if (Abs(distcc2-R2-Radius(i)) < Tol) { - qualifier2(NbrSol) = GccEnt_outside; - } - else { qualifier2(NbrSol) = GccEnt_enclosing; } - if (dist1 <= Tol && Abs(Radius(k)-C1.Radius()) <= Tol) { - TheSame1(NbrSol) = 1; - } - else { - TheSame1(NbrSol) = 0; - gp_Dir2d dc1(C1.Location().XY()-Center.XY()); - pnttg1sol(NbrSol)=gp_Pnt2d(Center.XY()+Radius(k)*dc1.XY()); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pararg1(NbrSol)=ElCLib::Parameter(C1,pnttg1sol(NbrSol)); - } - if (dist2 <= Tol && Abs(Radius(k)-C2.Radius()) <= Tol) { - TheSame2(NbrSol) = 1; - } - else { - TheSame2(NbrSol) = 0; - gp_Dir2d dc2(C2.Location().XY()-Center.XY()); - pnttg2sol(NbrSol)=gp_Pnt2d(Center.XY()+Radius(k)*dc2.XY()); - par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg2sol(NbrSol)); - pararg2(NbrSol)=ElCLib::Parameter(C2,pnttg2sol(NbrSol)); - } - pntcen(NbrSol) = Center; - parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); - } - WellDone = Standard_True; - } - } - } - } - } - } -} - -//========================================================================= -// Creation d un cercle tangent a un Cercle C1 et a une Droite L2. + -// centre sur une courbe OnCurv. + -// Nous calculons les bissectrices a C1 et L2 qui nous donnent + -// l ensemble des lieux possibles des centres de tous les cercles + -// tangents a C1 et L2. + -// Nous intersectons ces bissectrices avec la courbe OnCurv ce qui nous + -// donne les points parmis lesquels nous allons choisir les solutions. + -// Les choix s effectuent a partir des Qualifieurs qualifiant C1 et L2. + -//========================================================================= - -GccGeo_Circ2d2TanOn:: - GccGeo_Circ2d2TanOn (const GccEnt_QualifiedCirc& Qualified1 , - const GccEnt_QualifiedLin& Qualified2 , - const TheCurve& OnCurv , - const Standard_Real Tolerance ): - cirsol(1,8) , - qualifier1(1,8), - qualifier2(1,8), - TheSame1(1,8) , - TheSame2(1,8) , - pnttg1sol(1,8) , - pnttg2sol(1,8) , - pntcen(1,8) , - par1sol(1,8) , - par2sol(1,8) , - pararg1(1,8) , - pararg2(1,8) , - parcen3(1,8) -{ - - WellDone = Standard_False; - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - NbrSol = 0; - Standard_Real Tol = Abs(Tolerance); - Standard_Real Radius; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Dir2d dirx(1.,0.); - gp_Circ2d C1 = Qualified1.Qualified(); - gp_Lin2d L2 = Qualified2.Qualified(); - Standard_Real R1 = C1.Radius(); - gp_Pnt2d center1(C1.Location()); - gp_Pnt2d origin2(L2.Location()); - gp_Dir2d dir2(L2.Direction()); - gp_Dir2d normL2(-dir2.Y(),dir2.X()); - - GccAna_CircLin2dBisec Bis(C1,L2); - if (Bis.IsDone()) { - Standard_Real Tol1 = Abs(Tolerance); - Standard_Real Tol2 = Tol1; - TheIntConicCurve Intp; - Standard_Integer nbsolution = Bis.NbSolutions(); - Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(OnCurv); - TheParGenCurve C2(HCu2,0.); - firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); - for (Standard_Integer i = 1 ; i <= nbsolution; i++) { - Handle(GccInt_Bisec) Sol = Bis.ThisSolution(i); - GccInt_IType type = Sol->ArcType(); - switch (type) { - case GccInt_Lin: - { - gp_Lin2d Line(Sol->Line()); - IntRes2d_Domain D1; - Intp.Perform(Line,D1,C2,D2,Tol1,Tol2); - } - break; - case GccInt_Par: - { - gp_Parab2d Parab(Sol->Parabola()); - IntRes2d_Domain D1(ElCLib::Value(-40,Parab),-40,Tol1, - ElCLib::Value(40,Parab),40,Tol1); - Intp.Perform(Parab,D1,C2,D2,Tol1,Tol2); - } - break; - default: - { - Standard_ConstructionError::Raise(); - } - } - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { - gp_Pnt2d Center(Intp.Point(j).Value()); - Standard_Real dist1 = Center.Distance(center1); -// Standard_Integer nbsol = 1; - Standard_Boolean ok = Standard_False; - if (Qualified1.IsEnclosed()) { - if (dist1-R1 < Tol) { ok = Standard_True; } - } - else if (Qualified1.IsOutside()) { - if (R1-dist1 < Tol) { ok = Standard_True; } - } - else if (Qualified1.IsEnclosing() || Qualified1.IsUnqualified()) { - ok = Standard_True; - } - Radius = L2.Distance(Center); - if (Qualified2.IsEnclosed() && ok) { - ok = Standard_False; - if ((((origin2.X()-Center.X())*(-dir2.Y()))+ - ((origin2.Y()-Center.Y())*(dir2.X())))<=0){ - ok = Standard_True; - } - } - else if (Qualified2.IsOutside() && ok) { - ok = Standard_False; - if ((((origin2.X()-Center.X())*(-dir2.Y()))+ - ((origin2.Y()-Center.Y())*(dir2.X())))>=0){ - ok = Standard_True; - } - } - if (Qualified1.IsEnclosing()&&dist1>Radius) { ok=Standard_False; } - if (ok) { - NbrSol++; - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= -#ifdef DEB - gp_Dir2d dc1(center1.XY()-Center.XY()); -#endif - gp_Dir2d dc2(origin2.XY()-Center.XY()); - Standard_Real distcc1 = Center.Distance(center1); - if (!Qualified1.IsUnqualified()) { - qualifier1(NbrSol) = Qualified1.Qualifier(); - } - else if (Abs(distcc1+Radius-R1) < Tol) { - qualifier1(NbrSol) = GccEnt_enclosed; - } - else if (Abs(distcc1-R1-Radius) < Tol) { - qualifier1(NbrSol) = GccEnt_outside; - } - else { qualifier1(NbrSol) = GccEnt_enclosing; } - if (!Qualified2.IsUnqualified()) { - qualifier2(NbrSol) = Qualified2.Qualifier(); - } - else if (dc2.Dot(normL2) > 0.0) { - qualifier2(NbrSol) = GccEnt_outside; - } - else { qualifier2(NbrSol) = GccEnt_enclosed; } - if (dist1 <= Tol && Abs(Radius-C1.Radius()) <= Tol) { - TheSame1(NbrSol) = 1; - } - else { - TheSame1(NbrSol) = 0; - gp_Dir2d dc1(center1.XY()-Center.XY()); - pnttg1sol(NbrSol)=gp_Pnt2d(Center.XY()+Radius*dc1.XY()); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pararg1(NbrSol)=ElCLib::Parameter(C1,pnttg1sol(NbrSol)); - } - TheSame2(NbrSol) = 0; - Standard_Real sign = dc2.Dot(gp_Dir2d(-dir2.Y(),dir2.X())); - dc2 = gp_Dir2d(sign*gp_XY(-dir2.Y(),dir2.X())); - pnttg2sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc2.XY()); - par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg2sol(NbrSol)); - pararg2(NbrSol)=ElCLib::Parameter(L2,pnttg2sol(NbrSol)); - pntcen(NbrSol) = Center; - parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); - } - } - } - WellDone = Standard_True; - } - } - } -} - -//========================================================================= -// Creation d un cercle tant a deux Droites L1 et L2. + -// centre sur une courbe OnCurv. + -// Nous calculons les bissectrices a L1 et L2 qui nous donnent + -// l ensemble des lieux possibles des centres de tous les cercles + -// tants a L1 et L2. + -// Nous intersectons ces bissectrices avec la courbe OnCurv ce qui nous + -// donne les points parmis lesquels nous allons choisir les solutions. + -// Les choix s effectuent a partir des Qualifieurs qualifiant L1 et L2. + -//========================================================================= - -GccGeo_Circ2d2TanOn:: - GccGeo_Circ2d2TanOn (const GccEnt_QualifiedLin& Qualified1 , - const GccEnt_QualifiedLin& Qualified2 , - const TheCurve& OnCurv , - const Standard_Real Tolerance ): - cirsol(1,8) , - qualifier1(1,8), - qualifier2(1,8), - TheSame1(1,8) , - TheSame2(1,8) , - pnttg1sol(1,8) , - pnttg2sol(1,8) , - pntcen(1,8) , - par1sol(1,8) , - par2sol(1,8) , - pararg1(1,8) , - pararg2(1,8) , - parcen3(1,8) -{ - - WellDone = Standard_False; - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - NbrSol = 0; - if (!(Qualified1.IsEnclosed() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - Standard_Real Radius=0; - gp_Dir2d dirx(1.,0.); - gp_Lin2d L1 = Qualified1.Qualified(); - gp_Lin2d L2 = Qualified2.Qualified(); - gp_Dir2d dir1(L1.Direction()); - gp_Dir2d dir2(L2.Direction()); - gp_Dir2d Dnor1(-dir1.Y(),dir1.X()); - gp_Dir2d Dnor2(-dir2.Y(),dir2.X()); - gp_Pnt2d origin1(L1.Location()); - gp_Pnt2d origin2(L2.Location()); - GccAna_Lin2dBisec Bis(L1,L2); - if (Bis.IsDone()) { - Standard_Real Tol1 = Abs(Tolerance); - Standard_Real Tol2 = Tol1; - TheIntConicCurve Intp; - Standard_Integer nbsolution = Bis.NbSolutions(); - Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(OnCurv); - TheParGenCurve C2(HCu2,0.); - firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); - IntRes2d_Domain D1; - for (Standard_Integer i = 1 ; i <= nbsolution; i++) { - Intp.Perform(Bis.ThisSolution(i),D1,C2,D2,Tol1,Tol2); - if (Intp.IsDone()) { - if ((!Intp.IsEmpty())) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { - gp_Pnt2d Center(Intp.Point(j).Value()); - Standard_Real dist1 = L1.Distance(Center); - Standard_Real dist2 = L2.Distance(Center); -// Standard_Integer nbsol = 1; - Standard_Boolean ok = Standard_False; - if (Qualified1.IsEnclosed()) { - if ((((origin1.X()-Center.X())*(-dir1.Y()))+ - ((origin1.Y()-Center.Y())*(dir1.X())))<=0){ - ok = Standard_True; - } - } - else if (Qualified1.IsOutside()) { - if ((((origin1.X()-Center.X())*(-dir1.Y()))+ - ((origin1.Y()-Center.Y())*(dir1.X())))>=0){ - ok = Standard_True; - } - } - else if (Qualified1.IsUnqualified()) { ok = Standard_True; } - if (Qualified2.IsEnclosed() && ok) { - ok = Standard_False; - if ((((origin2.X()-Center.X())*(-dir2.Y()))+ - ((origin2.Y()-Center.Y())*(dir2.X())))<=0){ - ok = Standard_True; - Radius = (dist1+dist2)/2.; - } - } - else if (Qualified2.IsOutside() && ok) { - ok = Standard_False; - if ((((origin2.X()-Center.X())*(-dir2.Y()))+ - ((origin2.Y()-Center.Y())*(dir2.X())))>=0){ - ok = Standard_True; - Radius = (dist1+dist2)/2.; - } - } - else if (Qualified2.IsUnqualified() && ok) { - Radius = (dist1+dist2)/2.; - } - if (ok) { - NbrSol++; - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= - gp_Dir2d dc1(origin1.XY()-Center.XY()); - gp_Dir2d dc2(origin2.XY()-Center.XY()); - if (!Qualified1.IsUnqualified()) { - qualifier1(NbrSol) = Qualified1.Qualifier(); - } - else if (dc1.Dot(Dnor1) > 0.0) { - qualifier1(NbrSol) = GccEnt_outside; - } - else { qualifier1(NbrSol) = GccEnt_enclosed; } - if (!Qualified2.IsUnqualified()) { - qualifier2(NbrSol) = Qualified2.Qualifier(); - } - else if (dc2.Dot(Dnor2) > 0.0) { - qualifier2(NbrSol) = GccEnt_outside; - } - else { qualifier2(NbrSol) = GccEnt_enclosed; } - TheSame1(NbrSol) = 0; - TheSame2(NbrSol) = 0; - Standard_Real sign = dc1.Dot(Dnor1); - dc1 = gp_Dir2d(sign*gp_XY(-dir1.Y(),dir1.X())); - pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc1.XY()); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pararg1(NbrSol)=ElCLib::Parameter(L1,pnttg1sol(NbrSol)); - sign = dc2.Dot(gp_Dir2d(-dir2.Y(),dir2.X())); - dc2 = gp_Dir2d(sign*gp_XY(-dir2.Y(),dir2.X())); - pnttg2sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc2.XY()); - par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg2sol(NbrSol)); - pararg2(NbrSol)=ElCLib::Parameter(L2,pnttg2sol(NbrSol)); - pntcen(NbrSol) = Center; - parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); - } - } - } - WellDone = Standard_True; - } - } - } -} - -//========================================================================= -// Creation d un cercle tant a un Cercle C1, passant par un point P2 + -// centre sur une courbe OnCurv. + -// Nous calculons les bissectrices a C1 et Point2 qui nous donnent + -// l ensemble des lieux possibles des centres de tous les cercles + -// tants a C1 et Point2. + -// Nous intersectons ces bissectrices avec la courbe OnCurv ce qui nous + -// donne les points parmis lesquels nous allons choisir les solutions. + -// Les choix s effectuent a partir des Qualifieurs qualifiant C1. + -//========================================================================= - -GccGeo_Circ2d2TanOn:: - GccGeo_Circ2d2TanOn (const GccEnt_QualifiedCirc& Qualified1 , - const gp_Pnt2d& Point2 , - const TheCurve& OnCurv , - const Standard_Real Tolerance ): - cirsol(1,8) , - qualifier1(1,8), - qualifier2(1,8), - TheSame1(1,8) , - TheSame2(1,8) , - pnttg1sol(1,8) , - pnttg2sol(1,8) , - pntcen(1,8) , - par1sol(1,8) , - par2sol(1,8) , - pararg1(1,8) , - pararg2(1,8) , - parcen3(1,8) -{ - - WellDone = Standard_False; - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - NbrSol = 0; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Real Tol = Abs(Tolerance); - Standard_Real Radius; - gp_Dir2d dirx(1.,0.); - gp_Circ2d C1 = Qualified1.Qualified(); - Standard_Real R1 = C1.Radius(); - gp_Pnt2d center1(C1.Location()); - GccAna_CircPnt2dBisec Bis(C1,Point2); - if (Bis.IsDone()) { - Standard_Real Tol1 = Abs(Tolerance); - Standard_Real Tol2 = Tol1; - TheIntConicCurve Intp; - Standard_Integer nbsolution = Bis.NbSolutions(); - Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(OnCurv); - TheParGenCurve C2(HCu2,0.); - firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); - for (Standard_Integer i = 1 ; i <= nbsolution; i++) { - Handle(GccInt_Bisec) Sol = Bis.ThisSolution(i); - GccInt_IType type = Sol->ArcType(); - switch (type) { - case GccInt_Cir: - { - gp_Circ2d Circ(Sol->Circle()); - IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol1, - ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol2); - D1.SetEquivalentParameters(0.,2.*M_PI); - Intp.Perform(Circ,D1,C2,D2,Tol1,Tol2); - } - break; - case GccInt_Lin: - { - gp_Lin2d Line(Sol->Line()); - IntRes2d_Domain D1; - Intp.Perform(Line,D1,C2,D2,Tol1,Tol2); - } - break; - case GccInt_Ell: - { - gp_Elips2d Elips(Sol->Ellipse()); - IntRes2d_Domain D1(ElCLib::Value(0.,Elips), 0.,Tol1, - ElCLib::Value(2.*M_PI,Elips),2.*M_PI,Tol2); - D1.SetEquivalentParameters(0.,2.*M_PI); - Intp.Perform(Elips,D1,C2,D2,Tol1,Tol2); - } - break; - case GccInt_Hpr: - { - gp_Hypr2d Hypr(Sol->Hyperbola()); - IntRes2d_Domain D1(ElCLib::Value(-4.,Hypr),-4.,Tol1, - ElCLib::Value(4.,Hypr),4.,Tol2); - Intp.Perform(Hypr,D1,C2,D2,Tol1,Tol2); - } - break; - default: - { - Standard_ConstructionError::Raise(); - } - } - if (Intp.IsDone()) { - if ((!Intp.IsEmpty())) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { - gp_Pnt2d Center(Intp.Point(j).Value()); - Radius = Center.Distance(Point2); - Standard_Real dist1 = center1.Distance(Center); -// Standard_Integer nbsol = 1; - Standard_Boolean ok = Standard_False; - if (Qualified1.IsEnclosed()) { - if (dist1-R1 <= Tol) { ok = Standard_True; } - } - else if (Qualified1.IsOutside()) { - if (R1-dist1 <= Tol) { ok = Standard_True; } - } - else if (Qualified1.IsEnclosing()) { ok = Standard_True; } - else if (Qualified1.IsUnqualified()) { ok = Standard_True; } - if (ok) { - NbrSol++; - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= - Standard_Real distcc1 = Center.Distance(center1); - if (!Qualified1.IsUnqualified()) { - qualifier1(NbrSol) = Qualified1.Qualifier(); - } - else if (Abs(distcc1+Radius-R1) < Tol) { - qualifier1(NbrSol) = GccEnt_enclosed; - } - else if (Abs(distcc1-R1-Radius) < Tol) { - qualifier1(NbrSol) = GccEnt_outside; - } - else { qualifier1(NbrSol) = GccEnt_enclosing; } - qualifier2(NbrSol) = GccEnt_noqualifier; - if (dist1 <= Tol && Abs(Radius-R1) <= Tol) { - TheSame1(NbrSol) = 1; - } - else { - TheSame1(NbrSol) = 0; - gp_Dir2d dc1(center1.XY()-Center.XY()); - pnttg1sol(NbrSol)=gp_Pnt2d(Center.XY()+Radius*dc1.XY()); - par1sol(NbrSol) = 0.; - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pararg1(NbrSol)=ElCLib::Parameter(C1,pnttg1sol(NbrSol)); - } - TheSame2(NbrSol) = 0; - pnttg2sol(NbrSol) = Point2; - pntcen(NbrSol) = Center; - parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); - pararg2(NbrSol) = 0.; - par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg2sol(NbrSol)); - } - } - } - WellDone = Standard_True; - } - } - } -} - -//========================================================================= -// Creation d un cercle tant a une ligne L1, passant par un point P2 + -// centre sur une courbe OnCurv. + -// Nous calculons les bissectrices a L1 et Point2 qui nous donnent + -// l ensemble des lieux possibles des centres de tous les cercles + -// tants a L1 et passant par Point2. + -// Nous intersectons ces bissectrices avec la courbe OnCurv ce qui nous + -// donne les points parmis lesquels nous allons choisir les solutions. + -// Les choix s effectuent a partir des Qualifieurs qualifiant L1. + -//========================================================================= - -GccGeo_Circ2d2TanOn:: - GccGeo_Circ2d2TanOn (const GccEnt_QualifiedLin& Qualified1 , - const gp_Pnt2d& Point2 , - const TheCurve& OnCurv , - const Standard_Real Tolerance ): - cirsol(1,8) , - qualifier1(1,8), - qualifier2(1,8), - TheSame1(1,8) , - TheSame2(1,8) , - pnttg1sol(1,8) , - pnttg2sol(1,8) , - pntcen(1,8) , - par1sol(1,8) , - par2sol(1,8) , - pararg1(1,8) , - pararg2(1,8) , - parcen3(1,8) -{ - - WellDone = Standard_False; - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - Standard_Real Tol = Abs(Tolerance); - NbrSol = 0; - if (!(Qualified1.IsEnclosed() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - gp_Dir2d dirx(1.,0.); - gp_Lin2d L1 = Qualified1.Qualified(); - gp_Pnt2d origin1(L1.Location()); - gp_Dir2d dir1(L1.Direction()); - gp_Dir2d normal(-dir1.Y(),dir1.X()); - GccAna_LinPnt2dBisec Bis(L1,Point2); - if (Bis.IsDone()) { - Standard_Real Tol1 = Abs(Tolerance); - Standard_Real Tol2 = Tol1; - TheIntConicCurve Intp; - Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(OnCurv); - TheParGenCurve C2(HCu2,0.); - firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); - Handle(GccInt_Bisec) Sol = Bis.ThisSolution(); - GccInt_IType type = Sol->ArcType(); - switch (type) { - case GccInt_Lin: - { - gp_Lin2d Line(Sol->Line()); - IntRes2d_Domain D1; - Intp.Perform(Line,D1,C2,D2,Tol1,Tol2); - } - break; - case GccInt_Par: - { - gp_Parab2d Parab(Sol->Parabola()); - IntRes2d_Domain D1(ElCLib::Value(-40,Parab),-40,Tol1, - ElCLib::Value(40,Parab),40,Tol1); - Intp.Perform(Parab,D1,C2,D2,Tol1,Tol2); - } - break; - default: - { - Standard_ConstructionError::Raise(); - } - } - if (Intp.IsDone()) { - if ((!Intp.IsEmpty())) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { - gp_Pnt2d Center(Intp.Point(j).Value()); - Standard_Real Radius = L1.Distance(Center); -// Standard_Integer nbsol = 1; - Standard_Boolean ok = Standard_False; - if (Qualified1.IsEnclosed()) { - if ((((origin1.X()-Center.X())*(-dir1.Y()))+ - ((origin1.Y()-Center.Y())*(dir1.X())))<=0){ - ok = Standard_True; - } - } - else if (Qualified1.IsOutside()) { - if ((((origin1.X()-Center.X())*(-dir1.Y()))+ - ((origin1.Y()-Center.Y())*(dir1.X())))>=0){ - ok = Standard_True; - } - } - else if (Qualified1.IsUnqualified()) { ok = Standard_True; } - if (ok) { - NbrSol++; - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= - qualifier2(NbrSol) = GccEnt_noqualifier; - gp_Dir2d dc2(origin1.XY()-Center.XY()); - if (!Qualified1.IsUnqualified()) { - qualifier1(NbrSol) = Qualified1.Qualifier(); - } - else if (dc2.Dot(normal) > 0.0) { - qualifier1(NbrSol) = GccEnt_outside; - } - else { qualifier1(NbrSol) = GccEnt_enclosed; } - TheSame1(NbrSol) = 0; - TheSame2(NbrSol) = 0; - gp_Dir2d dc1(origin1.XY()-Center.XY()); - Standard_Real sign = dc1.Dot(gp_Dir2d(-dir1.Y(),dir1.X())); - dc1=gp_Dir2d(sign*gp_XY(-dir1.Y(),dir1.X())); - pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc1.XY()); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pararg1(NbrSol)=ElCLib::Parameter(L1,pnttg1sol(NbrSol)); - pnttg2sol(NbrSol) = Point2; - par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg2sol(NbrSol)); - pararg2(NbrSol) = 0.; - pntcen(NbrSol) = Center; - parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); - } - } - } - WellDone = Standard_True; - } - } -} - -//========================================================================= -// Creation d un cercle passant par deux point Point1 et Point2 + -// centre sur une courbe OnCurv. + -// Nous calculons les bissectrices a Point1 et Point2 qui nous donnent + -// l ensemble des lieux possibles des centres de tous les cercles + -// passant par Point1 et Point2. + -// Nous intersectons ces bissectrices avec la courbe OnCurv ce qui nous + -// donne les points parmis lesquels nous allons choisir les solutions. + -//========================================================================= - -GccGeo_Circ2d2TanOn:: - GccGeo_Circ2d2TanOn (const gp_Pnt2d& Point1 , - const gp_Pnt2d& Point2 , - const TheCurve& OnCurv , - const Standard_Real Tolerance ): - cirsol(1,8) , - qualifier1(1,8), - qualifier2(1,8), - TheSame1(1,8) , - TheSame2(1,8) , - pnttg1sol(1,8) , - pnttg2sol(1,8) , - pntcen(1,8) , - par1sol(1,8) , - par2sol(1,8) , - pararg1(1,8) , - pararg2(1,8) , - parcen3(1,8) -{ - - WellDone = Standard_False; - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - Standard_Real Tol = Abs(Tolerance); - NbrSol = 0; - gp_Dir2d dirx(1.,0.); - GccAna_Pnt2dBisec Bis(Point1,Point2); - if (Bis.IsDone()) { - Standard_Real Tol1 = Abs(Tolerance); - Standard_Real Tol2 = Tol1; - TheIntConicCurve Intp; - Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(OnCurv); - TheParGenCurve Cu2(HCu2,0.); - firstparam = Max(TheCurvePGTool::FirstParameter(Cu2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(Cu2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(Cu2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(Cu2,lastparam),lastparam,Tol); - IntRes2d_Domain D1; - if (Bis.HasSolution()) { - Intp.Perform(Bis.ThisSolution(),D1,Cu2,D2,Tol1,Tol2); - if (Intp.IsDone()) { - if ((!Intp.IsEmpty())) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { - gp_Pnt2d Center(Intp.Point(j).Value()); - Standard_Real Radius = Point2.Distance(Center); - NbrSol++; - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= - qualifier1(NbrSol) = GccEnt_noqualifier; - qualifier2(NbrSol) = GccEnt_noqualifier; - TheSame1(NbrSol) = 0; - TheSame2(NbrSol) = 0; - pntcen(NbrSol) = Center; - pnttg1sol(NbrSol) = Point1; - pnttg2sol(NbrSol) = Point2; - pararg1(NbrSol) = 0.; - pararg2(NbrSol) = 0.; - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg2sol(NbrSol)); - parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); - } - } - WellDone = Standard_True; - } - } - } - } - -Standard_Boolean GccGeo_Circ2d2TanOn:: - IsDone () const { return WellDone; } - -Standard_Integer GccGeo_Circ2d2TanOn:: - NbSolutions () const{ return NbrSol; } - -gp_Circ2d GccGeo_Circ2d2TanOn:: - ThisSolution (const Standard_Integer Index) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - - return cirsol(Index); -} - -void GccGeo_Circ2d2TanOn:: - WhichQualifier(const Standard_Integer Index , - GccEnt_Position& Qualif1 , - GccEnt_Position& Qualif2 ) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - else { - Qualif1 = qualifier1(Index); - Qualif2 = qualifier2(Index); - } -} - -void GccGeo_Circ2d2TanOn:: - Tangency1 (const Standard_Integer Index , - Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& PntSol ) const{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - else { - if (TheSame1(Index) == 0) { - ParSol = par1sol(Index); - ParArg = pararg1(Index); - PntSol = gp_Pnt2d(pnttg1sol(Index)); - } - else { StdFail_NotDone::Raise(); } - } - } - -void GccGeo_Circ2d2TanOn:: - Tangency2 (const Standard_Integer Index , - Standard_Real& ParSol , - Standard_Real& ParArg , - gp_Pnt2d& PntSol ) const{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - else { - if (TheSame2(Index) == 0) { - ParSol = par2sol(Index); - ParArg = pararg2(Index); - PntSol = gp_Pnt2d(pnttg2sol(Index)); - } - else { StdFail_NotDone::Raise(); } - } - } - -void GccGeo_Circ2d2TanOn:: - CenterOn3 (const Standard_Integer Index , - Standard_Real& ParArg , - gp_Pnt2d& PntSol ) const{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - else { - ParArg = parcen3(Index); - PntSol = gp_Pnt2d(pntcen(Index)); - } - } - -Standard_Boolean GccGeo_Circ2d2TanOn:: - IsTheSame1 (const Standard_Integer Index) const -{ - if (!WellDone) StdFail_NotDone::Raise(); - if (Index <= 0 ||Index > NbrSol) Standard_OutOfRange::Raise(); - - if (TheSame1(Index) == 0) - return Standard_False; - - return Standard_True; -} - - -Standard_Boolean GccGeo_Circ2d2TanOn:: - IsTheSame2 (const Standard_Integer Index) const -{ - if (!WellDone) StdFail_NotDone::Raise(); - if (Index <= 0 ||Index > NbrSol) Standard_OutOfRange::Raise(); - - if (TheSame2(Index) == 0) - return Standard_False; - - return Standard_True; -} diff --git a/src/GccGeo/GccGeo_Circ2d2TanRad.cdl b/src/GccGeo/GccGeo_Circ2d2TanRad.cdl deleted file mode 100644 index e535a2399b..0000000000 --- a/src/GccGeo/GccGeo_Circ2d2TanRad.cdl +++ /dev/null @@ -1,268 +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 Circ2d2TanRad from GccGeo ( - TheCurve as any; - TheTool as any; - TheQCurve as any; -- as QualifiedCurve from GccEnt - -- (TheCurve) - TheParGenCurve as any; -- as ParGenCurve from GccGeo - -- (TheCurve) - TheHParGenCurve as Transient; - TheCurvePGTool as any; -- as CurvePGTool from GccGeo - -- (Thecurve, - -- TheTool, - -- TheParGenCurve) - TheIntConicCurve as any; -- as IntConicCurveOfGOffsetInter - TheIntCurveCurve as any) -- as GOffsetInter from Geom2dInt - -- (TheParGenCurve, - -- TheCurvePGTool) - - ---Purpose: This class implements the algorithms used to - -- create 2d circles tangent to one curve and a - -- point/line/circle/curv and with a given radius. - -- For each construction methods arguments are: - -- - Two Qualified elements for tangency constrains. - -- (for example EnclosedCirc if we want the - -- solution inside the argument EnclosedCirc). - -- - Two Reals. One (Radius) for the radius and the - -- other (Tolerance) for the tolerance. - -- Tolerance is only used for the limit cases. - -- For example : - -- We want to create a circle inside a circle C1 and - -- inside a curve Cu2 with a radius Radius and a - -- tolerance Tolerance. - -- If we did not used Tolerance it is impossible to - -- find a solution in the following case : Cu2 is - -- inside C1 and there is no intersection point - -- between the two elements. - -- With Tolerance we will get a solution if the - -- lowest distance between C1 and Cu2 is lower than or - -- equal Tolerance. - --- inherits Entity from Standard - -uses Pnt2d from gp, - Circ2d from gp, - Array1OfCirc2d from TColgp, - Array1OfPnt2d from TColgp, - QualifiedCirc from GccEnt, - QualifiedLin from GccEnt, - Array1OfReal from TColStd, - Array1OfInteger from TColStd, - Position from GccEnt, - Array1OfPosition from GccEnt - -raises OutOfRange from Standard, - BadQualifier from GccEnt, - NotDone from StdFail, - NegativeValue from Standard - -is - -Create(Qualified1 : QualifiedCirc from GccEnt ; - Qualified2 : TheQCurve ; - Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2d2TanRad - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d circle and a curve - -- with a radius of Radius. -raises NegativeValue, BadQualifier; - ---Purpose: It raises NegativeValue if Radius is lower than zero. - -Create(Qualified1 : QualifiedLin from GccEnt ; - Qualified2 : TheQCurve ; - Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2d2TanRad - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a 2d line and a curve - -- with a radius of Radius. -raises NegativeValue, BadQualifier; - ---Purpose: It raises NegativeValue if Radius is lower than zero. - -Create(Qualified1 : TheQCurve ; - Qualified2 : TheQCurve ; - Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2d2TanRad - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to two curves with - -- a radius of Radius. -raises NegativeValue, BadQualifier; - ---Purpose: It raises NegativeValue if Radius is lower than zero. - -Create(Qualified1 : TheQCurve ; - Point2 : Pnt2d from gp ; - Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2d2TanRad - ---Purpose: This method implements the algorithms used to - -- create 2d circles TANgent to a curve and a point - -- with a radius of Radius. -raises NegativeValue, BadQualifier; - ---Purpose: It raises NegativeValue if Radius is lower than zero. - --- -- .................................................................... - -IsDone(me) returns Boolean from Standard -is static; - ---Purpose: This method returns True if the algorithm succeeded. - -NbSolutions(me) returns Integer from Standard - ---Purpose: This method returns the number of solutions. -raises NotDone -is static; - ---Purpose: It raises NotDone if the algorithm failed. - -ThisSolution(me ; - Index : Integer from Standard) returns Circ2d from gp - ---Purpose: Returns the solution number Index. - -- Be careful: the Index is only a way to get all the - -- solutions, but is not associated to those outside the context - -- of the algorithm-object. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises OutOfRange exception if Index is greater - -- than the number of solutions. - -- It raises NotDone if the construction algorithm did not - -- succeed. - -WhichQualifier(me ; - Index : Integer from Standard; - Qualif1 : out Position from GccEnt ; - Qualif2 : out Position from GccEnt ) -raises OutOfRange, NotDone -is static; - ---Purpose: It returns the information 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 ; - Index : Integer from Standard; - ParSol,ParArg : out Real from Standard; - PntSol : out Pnt2d from gp ) - ---Purpose: Returns information about the tangency point between the - -- result number Index and the first argument. - -- ParSol is the intrinsic parameter of the point PntSol on the solution. - -- ParArg is the intrinsic parameter of the point PntSol on the first - -- argument. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises OutOfRange if Index is greater than the number - -- of solutions. - -- It raises NotDone if the construction algorithm did not - -- succeed. - -Tangency2(me ; - Index : Integer from Standard; - ParSol,ParArg : out Real from Standard; - PntSol : out Pnt2d from gp ) - ---Purpose: Returns information about the tangency point between the - -- result number Index and the second argument. - -- ParSol is the intrinsic parameter of the point PntSol on - -- the solution. - -- ParArg is the intrinsic parameter of the point PntArg on - -- the second argument. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises OutOfRange if Index is greater than the number - -- of solutions. - -- It raises NotDone if the construction algorithm did not - -- succeed. - -IsTheSame1(me ; - Index : Integer from Standard) returns Boolean from Standard - ---Purpose: Returns True if the solution number Index is equal to - -- the first argument. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises OutOfRange if Index is greater than the number - -- of solutions. - -- It raises NotDone if the construction algorithm did not - -- succeed. - -IsTheSame2(me ; - Index : Integer from Standard) returns Boolean from Standard - ---Purpose: Returns True if the solution number Index is equal to - -- the second argument. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises OutOfRange if Index is greater than the number - -- of solutions. - -- It raises NotDone if the construction algorithm did not - -- succeed. - -fields - - WellDone : Boolean from Standard; - ---Purpose: True if the algorithm succeeded. - - NbrSol : Integer from Standard; - ---Purpose: The number of possible solutions. We have to decide about - -- the status of the multiple solutions... - - cirsol : Array1OfCirc2d from TColgp; - -- The solutions. - - qualifier1 : Array1OfPosition from GccEnt; - -- The qualifiers of the first argument. - - qualifier2 : Array1OfPosition from GccEnt; - -- The qualifiers of the second argument. - - TheSame1 : Array1OfInteger from TColStd; - ---Purpose: 1 if the solution and the first argument are the same - -- (2 circles). - -- If R1 is the radius of the first argument and Rsol the radius - -- of the solution and dist the distance between the two centers, - -- we consider the two circles are identical if R1+dist-Rsol is - -- less than Tolerance. - -- 0 in the other cases. - - TheSame2 : Array1OfInteger from TColStd; - ---Purpose: 1 if the solution and the second argument are the same - -- (2 circles). - -- If R2 is the radius of the second argument and Rsol the radius - -- of the solution and dist the distance between the two centers, - -- we consider the two circles are identical if R2+dist-Rsol is - -- less than Tolerance. - -- 0 in the other cases. - - pnttg1sol : Array1OfPnt2d from TColgp; - ---Purpose: The tangency point between the solution and the first - -- argument on the solution. - - pnttg2sol : Array1OfPnt2d from TColgp; - ---Purpose: The tangency point between the solution and the second - -- argument on the solution. - - par1sol : Array1OfReal from TColStd; - ---Purpose: The parameter of the tangency point between the solution - -- and the first argument on the solution. - - par2sol : Array1OfReal from TColStd; - ---Purpose: The parameter of the tangency point between the solution - -- and the second argument on the solution. - - pararg1 : Array1OfReal from TColStd; - ---Purpose: The parameter of the tangency point between the solution - -- and the first argument on the first argument. - - pararg2 : Array1OfReal from TColStd; - ---Purpose: The parameter of the tangency point between the solution - -- and the second argument on the second argument. - -end Circ2d2TanRad; diff --git a/src/GccGeo/GccGeo_Circ2d2TanRad.gxx b/src/GccGeo/GccGeo_Circ2d2TanRad.gxx deleted file mode 100644 index c03b3e9d8c..0000000000 --- a/src/GccGeo/GccGeo_Circ2d2TanRad.gxx +++ /dev/null @@ -1,1017 +0,0 @@ -// Copyright (c) 1995-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 -#include -#include -#include -#include -#include - -// circulaire tant a une courbe et une droite ,de rayon donne -//============================================================== - -//======================================================================== -// On initialise WellDone a false. + -// On recupere la courbe Cu2 et la droite L1. + -// On sort en erreur dans les cas ou la construction est impossible. + -// On fait la parallele a Cu2 dans le bon sens. + -// On fait la parallele a L1 dans le bon sens. + -// On intersecte les paralleles ==> point de centre de la solution. + -// On cree la solution qu on ajoute aux solutions deja trouvees. + -// On remplit les champs. + -//======================================================================== - -GccGeo_Circ2d2TanRad:: -GccGeo_Circ2d2TanRad (const GccEnt_QualifiedLin& Qualified1, - const TheQCurve& Qualified2, - const Standard_Real Radius , - const Standard_Real Tolerance ): - -//======================================================================== -// initialisation des champs. + -//======================================================================== - -cirsol(1,16) , -qualifier1(1,16), -qualifier2(1,16), -TheSame1(1,16) , -TheSame2(1,16) , -pnttg1sol(1,16), -pnttg2sol(1,16), -par1sol(1,16) , -par2sol(1,16) , -pararg1(1,16) , -pararg2(1,16) -{ - - //======================================================================== - // Traitement. + - //======================================================================== - - Standard_Real Tol = Abs(Tolerance); - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - gp_Dir2d dirx(1.,0.); - TColStd_Array1OfReal cote1(1,2); - TColStd_Array1OfReal cote2(1,2); - Standard_Integer nbrcote1=0; - Standard_Integer nbrcote2=0; - WellDone = Standard_False; - NbrSol = 0; - if (!(Qualified1.IsEnclosed() || - Qualified1.IsOutside() || Qualified1.IsUnqualified()) || - !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || - Qualified2.IsOutside() || Qualified2.IsUnqualified())) { - - GccEnt_BadQualifier::Raise(); - return; - } - gp_Lin2d L1 = Qualified1.Qualified(); - Standard_Real x1dir = (L1.Direction()).X(); - Standard_Real y1dir = (L1.Direction()).Y(); - Standard_Real lxloc = (L1.Location()).X(); - Standard_Real lyloc = (L1.Location()).Y(); - gp_Pnt2d origin1(lxloc,lyloc); - gp_Dir2d normL1(-y1dir,x1dir); - TheCurve Cu2= Qualified2.Qualified(); - if (Radius < 0.0) { Standard_NegativeValue::Raise(); } - else { - if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { - // ======================================================= - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = Radius; - cote2(1) = Radius; - } - else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { - // ========================================================== - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = Radius; - cote2(1) = -Radius; - } - else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { - // =========================================================== - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = -Radius; - cote2(1) = Radius; - } - else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { - // ========================================================= - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = -Radius; - cote2(1) = -Radius; - } - if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { - // ========================================================= - nbrcote1 = 1; - nbrcote2 = 2; - cote1(1) = Radius; - cote2(1) = Radius; - cote2(2) = -Radius; - } - if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { - // ========================================================= - nbrcote1 = 2; - nbrcote2 = 1; - cote1(1) = Radius; - cote1(2) = -Radius; - cote2(1) = Radius; - } - else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { - // ============================================================= - nbrcote1 = 1; - nbrcote2 = 2; - cote1(1) = -Radius; - cote2(1) = Radius; - cote2(2) = -Radius; - } - if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { - // ======================================================== - nbrcote1 = 2; - nbrcote2 = 1; - cote1(1) = Radius; - cote1(2) = -Radius; - cote2(1) = -Radius; - } - else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { - // ================================================================= - nbrcote1 = 2; - nbrcote2 = 2; - cote1(1) = Radius; - cote1(2) = -Radius; - cote2(1) = Radius; - cote2(2) = -Radius; - } - gp_Dir2d Dir(-y1dir,x1dir); - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { - gp_Pnt2d Point(L1.Location().XY()+cote1(jcote1)*Dir.XY()); - gp_Lin2d Line(Point,L1.Direction()); // ligne avec deport. - IntRes2d_Domain D1; - for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { - Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(Cu2); - TheParGenCurve C2(HCu2,cote2(jcote2)); - firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); - TheIntConicCurve Intp(Line,D1,C2,D2,Tol,Tol); - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { - NbrSol++; - gp_Pnt2d Center(Intp.Point(i).Value()); - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); - // ======================================================= - gp_Dir2d dc1(origin1.XY()-Center.XY()); - qualifier2(NbrSol) = Qualified2.Qualifier(); - if (!Qualified1.IsUnqualified()) { - qualifier1(NbrSol) = Qualified1.Qualifier(); - } - else if (dc1.Dot(normL1) > 0.0) { - qualifier1(NbrSol) = GccEnt_outside; - } - else { qualifier1(NbrSol) = GccEnt_enclosed; } - TheSame1(NbrSol) = 0; - TheSame2(NbrSol) = 0; - pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); - pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); - pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),L1); - pnttg2sol(NbrSol) = TheTool::Value(Cu2,pararg2(NbrSol)); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg2sol(NbrSol)); - } - } - WellDone = Standard_True; - } - } - } - } -} - -// circulaire tant a une courbe et un cercle ,de rayon donne -//============================================================= - -//======================================================================== -// On initialise WellDone a false. + -// On recupere la courbe Cu2 et le cercle C1. + -// On sort en erreur dans les cas ou la construction est impossible. + -// On fait la parallele a Cu2 dans le bon sens. + -// On fait la parallele a C1 dans le bon sens. + -// On intersecte les paralleles ==> point de centre de la solution. + -// On cree la solution qu on ajoute aux solutions deja trouvees. + -// On remplit les champs. + -//======================================================================== - -GccGeo_Circ2d2TanRad:: -GccGeo_Circ2d2TanRad (const GccEnt_QualifiedCirc& Qualified1, - const TheQCurve& Qualified2, - const Standard_Real Radius , - const Standard_Real Tolerance ): - -//======================================================================== -// initialisation des champs. + -//======================================================================== - -cirsol(1,16) , -qualifier1(1,16), -qualifier2(1,16), -TheSame1(1,16) , -TheSame2(1,16) , -pnttg1sol(1,16), -pnttg2sol(1,16), -par1sol(1,16) , -par2sol(1,16) , -pararg1(1,16) , -pararg2(1,16) -{ - - //======================================================================== - // Traitement. + - //======================================================================== - - Standard_Real Tol = Abs(Tolerance); - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - gp_Dir2d dirx(1.,0.); - TColStd_Array1OfReal cote1(1,2); - TColStd_Array1OfReal cote2(1,2); - Standard_Integer nbrcote1=0; - Standard_Integer nbrcote2=0; - WellDone = Standard_False; - NbrSol = 0; - 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(); - gp_Pnt2d center1(C1.Location()); - TheCurve Cu2 = Qualified2.Qualified(); - if (Radius < 0.0) { Standard_NegativeValue::Raise(); } - else { - if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { - // ======================================================= - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = Radius; - cote2(1) = Radius; - } - else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { - // ========================================================== - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = Radius; - cote2(1) = -Radius; - } - else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { - // =========================================================== - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = -Radius; - cote2(1) = Radius; - } - else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { - // ========================================================= - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = -Radius; - cote2(1) = -Radius; - } - if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { - // ========================================================= - nbrcote1 = 1; - nbrcote2 = 2; - cote1(1) = Radius; - cote2(1) = Radius; - cote2(2) = -Radius; - } - if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { - // ========================================================= - nbrcote1 = 2; - nbrcote2 = 1; - cote1(1) = Radius; - cote1(2) = -Radius; - cote2(1) = Radius; - } - else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { - // ============================================================= - nbrcote1 = 1; - nbrcote2 = 2; - cote1(1) = -Radius; - cote2(1) = Radius; - cote2(2) = -Radius; - } - if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { - // ======================================================== - nbrcote1 = 2; - nbrcote2 = 1; - cote1(1) = Radius; - cote1(2) = -Radius; - cote2(1) = -Radius; - } - else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { - // ================================================================= - nbrcote1 = 2; - nbrcote2 = 2; - cote1(1) = Radius; - cote1(2) = -Radius; - cote2(1) = Radius; - cote2(2) = -Radius; - } - Standard_Real R1 = C1.Radius(); - TheIntConicCurve Intp; - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { - gp_Circ2d Circ(C1.XAxis(),R1+cote1(jcote1)); - IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, - ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol); - D1.SetEquivalentParameters(0.,2.*M_PI); - for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { - Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(Cu2); - TheParGenCurve C2(HCu2,cote2(jcote2)); - firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); - Intp.Perform(Circ,D1,C2,D2,Tol,Tol); - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { - NbrSol++; - gp_Pnt2d Center(Intp.Point(i).Value()); - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); - // ======================================================= -#ifdef DEB - gp_Dir2d dir1(Center.XY()-center1.XY()); -#else - Center.XY() ; - center1.XY() ; -#endif - Standard_Real distcc1 = Center.Distance(center1); - if (!Qualified1.IsUnqualified()) { - qualifier1(NbrSol) = Qualified1.Qualifier(); - } - else if (Abs(distcc1+Radius-R1) < Tol) { - qualifier1(NbrSol) = GccEnt_enclosed; - } - else if (Abs(distcc1-R1-Radius) < Tol) { - qualifier1(NbrSol) = GccEnt_outside; - } - else { qualifier1(NbrSol) = GccEnt_enclosing; } - qualifier2(NbrSol) = Qualified2.Qualifier(); - TheSame1(NbrSol) = 0; - TheSame2(NbrSol) = 0; - pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); - pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); - pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),C1); - pnttg2sol(NbrSol) = TheTool::Value(Cu2,pararg2(NbrSol)); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg2sol(NbrSol)); - } - } - WellDone = Standard_True; - } - } - } - } -} - -// circulaire tant a une courbe et un point ,de rayon donne -//============================================================ - -//======================================================================== -// On initialise WellDone a false. + -// On recupere la courbe Cu1 et le point P2. + -// On sort en erreur dans les cas ou la construction est impossible. + -// On fait la parallele a Cu1 dans le bon sens. + -// On fait la parallele a P2 dans le bon sens. + -// On intersecte les paralleles ==> point de centre de la solution. + -// On cree la solution qu on ajoute aux solutions deja trouvees. + -// On remplit les champs. + -//======================================================================== - -GccGeo_Circ2d2TanRad:: -GccGeo_Circ2d2TanRad (const TheQCurve& Qualified1, - const gp_Pnt2d& Point2 , - const Standard_Real Radius , - const Standard_Real Tolerance ): - -//======================================================================== -// initialisation des champs. + -//======================================================================== - -cirsol(1,16) , -qualifier1(1,16), -qualifier2(1,16), -TheSame1(1,16) , -TheSame2(1,16) , -pnttg1sol(1,16), -pnttg2sol(1,16), -par1sol(1,16) , -par2sol(1,16) , -pararg1(1,16) , -pararg2(1,16) -{ - - //======================================================================== - // Traitement. + - //======================================================================== - - Standard_Real Tol = Abs(Tolerance); - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - gp_Dir2d dirx(1.,0.); - TColStd_Array1OfReal cote1(1,2); - Standard_Integer nbrcote1=0; - WellDone = Standard_False; - NbrSol = 0; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - TheCurve Cu1 = Qualified1.Qualified(); - if (Radius < 0.0) { Standard_NegativeValue::Raise(); } - else { - if (Qualified1.IsEnclosed()) { - // =========================== - nbrcote1 = 1; - cote1(1) = Radius; - } - else if(Qualified1.IsOutside()) { - // =============================== - nbrcote1 = 1; - cote1(1) = -Radius; - } - else if(Qualified1.IsUnqualified()) { - // =================================== - nbrcote1 = 2; - cote1(1) = Radius; - cote1(2) = -Radius; - } - gp_Circ2d Circ(gp_Ax2d(Point2,gp_Dir2d(1.,0.)),Radius); - IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, - ElCLib::Value(M_PI+M_PI,Circ),M_PI+M_PI,Tol); - D1.SetEquivalentParameters(0.,M_PI+M_PI); - TheIntConicCurve Intp; - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { - Handle(TheHParGenCurve) HCu1 = new TheHParGenCurve(Cu1); - TheParGenCurve Cu2(HCu1,cote1(jcote1)); - firstparam = Max(TheCurvePGTool::FirstParameter(Cu2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(Cu2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(Cu2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(Cu2,lastparam),lastparam,Tol); - Intp.Perform(Circ,D1,Cu2,D2,Tol,Tol); - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { - NbrSol++; - gp_Pnt2d Center(Intp.Point(i).Value()); - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); - // ======================================================= - qualifier1(NbrSol) = Qualified1.Qualifier(); - qualifier2(NbrSol) = GccEnt_noqualifier; - TheSame1(NbrSol) = 0; - TheSame2(NbrSol) = 0; - pararg1(NbrSol) = Intp.Point(i).ParamOnSecond(); - pararg2(NbrSol) = 0.; - pnttg1sol(NbrSol) = TheTool::Value(Cu1,pararg1(NbrSol)); - pnttg2sol(NbrSol) = Point2; - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg2sol(NbrSol)); - } - } - WellDone = Standard_True; - } - } - } -} - -static void PrecRoot(const TheParGenCurve& theC1, - const TheParGenCurve& theC2, - const Standard_Real theU0, - const Standard_Real theV0, - const Standard_Real theUmin, - const Standard_Real theUmax, - const Standard_Real theVmin, - const Standard_Real theVmax, - Standard_Real& theUfinal, - Standard_Real& theVfinal) -{ - const Standard_Real aInitStepU = (theUmax - theUmin)/2.0, - aInitStepV = (theVmax - theVmin)/2.0; - - Standard_Real aStepU = aInitStepU, aStepV = aInitStepV; - - const Standard_Real aTol = Precision::PConfusion() * Precision::PConfusion(); - const Standard_Integer aNbIterMax = 100; - - gp_Pnt2d aP1, aP2; - gp_Vec2d aD1, aD2; - - TheCurvePGTool::D1(theC1, theU0, aP1, aD1); - TheCurvePGTool::D1(theC2, theV0, aP2, aD2); - - gp_Vec2d vP12(aP1.XY() - aP2.XY()); - - Standard_Real aU = theU0, aV = theV0; - theUfinal = theU0; - theVfinal = theV0; - - Standard_Real aSQDistPrev = aP1.SquareDistance(aP2); - - Standard_Integer aNbIter = 1; - - do - { - Standard_Real aDetH = aD1.Y()*aD2.X() - aD1.X()*aD2.Y(); - if(aDetH == 0.0) - break; - - aU += aStepU*(aD2.Y() * vP12.X() - aD2.X()*vP12.Y())/aDetH; - aV += aStepV*(aD1.Y() * vP12.X() - aD1.X()*vP12.Y())/aDetH; - - if(Abs(aU - theUmin) > 1000.0) - //method diverges - return; - - if(Abs(aU - theUmax) > 1000.0) - //method diverges - return; - - if(Abs(aV - theVmin) > 1000.0) - //method diverges - return; - - if(Abs(aV - theVmax) > 1000.0) - //method diverges - return; - - TheCurvePGTool::D1(theC1, aU, aP1, aD1); - TheCurvePGTool::D1(theC2, aV, aP2, aD2); - const Standard_Real aSQDist = aP1.SquareDistance(aP2); - - if(Precision::IsInfinite(aSQDist)) - //method diverges - return; - - vP12.SetXY(aP1.XY() - aP2.XY()); - - if(aSQDist < aSQDistPrev) - { - aSQDistPrev = aSQDist; - aStepU = aInitStepU; - aStepV = aInitStepV; - theUfinal = aU; - theVfinal = aV; - } - else - { - aStepU /= 2.0; - aStepV /= 2.0; - } - } - while((aNbIter++ < aNbIterMax) && ((aStepU > aTol) || (aStepV > aTol))); - - Standard_Boolean isInBound = Standard_True; - if(theUfinal < theUmin) - { - aU = theUfinal; - aV = theVfinal; - - theUfinal = theUmin; - isInBound = Standard_False; - } - - if(theUfinal > theUmax) - { - aU = theUfinal; - aV = theVfinal; - - theUfinal = theUmax; - isInBound = Standard_False; - } - - if(!isInBound) - { - TheCurvePGTool::D1(theC1, aU, aP1, aD1); - TheCurvePGTool::D1(theC2, aV, aP2, aD2); - Standard_Real aV1 = (aD2.X() == 0.0) ? aV :((theUfinal - aU)*aD1.X() + aV*aD2.X() + (aP1.X() - aP2.X()))/aD2.X(); - Standard_Real aV2 = (aD2.Y() == 0.0) ? aV :((theUfinal - aU)*aD1.Y() + aV*aD2.Y() + (aP1.Y() - aP2.Y()))/aD2.Y(); - - if(aV1 < theVmin) - aV1 = theVmin; - - if(aV1 > theVmax) - aV1 = theVmax; - - if(aV2 < theVmin) - aV2 = theVmin; - - if(aV2 > theVmax) - aV2 = theVmax; - - aP1 = TheCurvePGTool::Value(theC1,theUfinal); - aP2 = TheCurvePGTool::Value(theC2,aV1); - - Standard_Real aSQ1 = aP1.SquareDistance(aP2); - - aP2 = TheCurvePGTool::Value(theC2,aV2); - Standard_Real aSQ2 = aP1.SquareDistance(aP2); - - if(aSQ1 < aSQ2) - theVfinal = aV1; - else - theVfinal = aV2; - - return; - } - - if(theVfinal < theVmin) - { - aU = theUfinal; - aV = theVfinal; - - theVfinal = theVmin; - isInBound = Standard_False; - } - - if(theVfinal > theVmax) - { - aU = theUfinal; - aV = theVfinal; - - theVfinal = theVmax; - isInBound = Standard_False; - } - - if(isInBound) - return; - - TheCurvePGTool::D1(theC1, aU, aP1, aD1); - TheCurvePGTool::D1(theC2, aV, aP2, aD2); - Standard_Real aU1 = (aD1.X() == 0.0) ? aU :((theVfinal - aV)*aD2.X() + aU*aD1.X() + (aP2.X() - aP1.X()))/aD1.X(); - Standard_Real aU2 = (aD1.Y() == 0.0) ? aU :((theVfinal - aV)*aD2.Y() + aU*aD1.Y() + (aP2.Y() - aP1.Y()))/aD1.Y(); - - if(aU1 < theUmin) - aU1 = theUmin; - - if(aU1 > theUmax) - aU1 = theUmax; - - if(aU2 < theUmin) - aU2 = theUmin; - - if(aU2 > theUmax) - aU2 = theUmax; - - aP2 = TheCurvePGTool::Value(theC2,theVfinal); - aP1 = TheCurvePGTool::Value(theC1,aU1); - - Standard_Real aSQ1 = aP1.SquareDistance(aP2); - - aP1 = TheCurvePGTool::Value(theC1,aU2); - Standard_Real aSQ2 = aP1.SquareDistance(aP2); - - if(aSQ1 < aSQ2) - theUfinal = aU1; - else - theUfinal = aU2; -} - -// circulaire tant a deux courbes ,de rayon donne -//================================================== - -//======================================================================== -// On initialise WellDone a false. + -// On recupere les courbes Cu1 et Cu2. + -// On sort en erreur dans les cas ou la construction est impossible. + -// On fait la parallele a Cu1 dans le bon sens. + -// On fait la parallele a Cu2 dans le bon sens. + -// On intersecte les paralleles ==> point de centre de la solution. + -// On cree la solution qu on ajoute aux solutions deja trouvees. + -// On remplit les champs. + -//======================================================================== - -GccGeo_Circ2d2TanRad:: -GccGeo_Circ2d2TanRad (const TheQCurve& Qualified1, - const TheQCurve& Qualified2, - const Standard_Real Radius , - const Standard_Real Tolerance ): - -//======================================================================== -// initialisation des champs. + -//======================================================================== - -cirsol(1,16) , -qualifier1(1,16), -qualifier2(1,16), -TheSame1(1,16) , -TheSame2(1,16) , -pnttg1sol(1,16), -pnttg2sol(1,16), -par1sol(1,16) , -par2sol(1,16) , -pararg1(1,16) , -pararg2(1,16) -{ - - //======================================================================== - // Traitement. + - //======================================================================== - - Standard_Real Tol = Abs(Tolerance); - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - gp_Dir2d dirx(1.,0.); - TColStd_Array1OfReal cote1(1,2); - TColStd_Array1OfReal cote2(1,2); - Standard_Integer nbrcote1=0; - Standard_Integer nbrcote2=0; - WellDone = Standard_False; - NbrSol = 0; - 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(); - if (Radius < 0.0) { Standard_NegativeValue::Raise(); } - else { - if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { - // ======================================================= - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = Radius; - cote2(1) = Radius; - } - else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { - // ========================================================== - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = Radius; - cote2(1) = -Radius; - } - else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { - // =========================================================== - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = -Radius; - cote2(1) = Radius; - } - else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { - // ========================================================= - nbrcote1 = 1; - nbrcote2 = 1; - cote1(1) = -Radius; - cote2(1) = -Radius; - } - if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { - // ========================================================= - nbrcote1 = 1; - nbrcote2 = 2; - cote1(1) = Radius; - cote2(1) = Radius; - cote2(2) = -Radius; - } - if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { - // ========================================================= - nbrcote1 = 2; - nbrcote2 = 1; - cote1(1) = Radius; - cote1(2) = -Radius; - cote2(1) = Radius; - } - else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { - // ============================================================= - nbrcote1 = 1; - nbrcote2 = 2; - cote1(1) = -Radius; - cote2(1) = Radius; - cote2(2) = -Radius; - } - if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { - // ======================================================== - nbrcote1 = 2; - nbrcote2 = 1; - cote1(1) = Radius; - cote1(2) = -Radius; - cote2(1) = -Radius; - } - else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { - // ================================================================= - nbrcote1 = 2; - nbrcote2 = 2; - cote1(1) = Radius; - cote1(2) = -Radius; - cote2(1) = Radius; - cote2(2) = -Radius; - } - TheIntCurveCurve Intp; - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { - Handle(TheHParGenCurve) HCu1 = new TheHParGenCurve(Cu1); - TheParGenCurve C1(HCu1,cote1(jcote1)); - firstparam = Max(TheCurvePGTool::FirstParameter(C1),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C1),thelast); -#ifdef DEB - IntRes2d_Domain D2(TheCurvePGTool::Value(C1,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C1,lastparam),lastparam,Tol); -#else - TheCurvePGTool::Value(C1,firstparam); - TheCurvePGTool::Value(C1,lastparam); -#endif - for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { - Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(Cu2); - TheParGenCurve C2(HCu2,cote2(jcote2)); - firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); -#ifdef DEB - IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); -#else - TheCurvePGTool::Value(C2,firstparam); - TheCurvePGTool::Value(C2,lastparam); -#endif - Intp.Perform(C1,C2,Tol,Tol); - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) - { - Standard_Real aU0 = Intp.Point(i).ParamOnFirst(); - Standard_Real aV0 = Intp.Point(i).ParamOnSecond(); - - Standard_Real aU1 = aU0-Precision::PApproximation(); - Standard_Real aV1 = aV0-Precision::PApproximation(); - - Standard_Real aU2 = aU0+Precision::PApproximation(); - Standard_Real aV2 = aV0+Precision::PApproximation(); - - gp_Pnt2d P11 = TheCurvePGTool::Value(C1,aU1); - gp_Pnt2d P12 = TheCurvePGTool::Value(C2,aV1); - gp_Pnt2d P21 = TheCurvePGTool::Value(C1,aU2); - gp_Pnt2d P22 = TheCurvePGTool::Value(C2,aV2); - - Standard_Real aDist1112 = P11.Distance(P12); - Standard_Real aDist1122 = P11.Distance(P22); - - Standard_Real aDist1221 = P12.Distance(P21); - Standard_Real aDist2122 = P21.Distance(P22); - - if( Min(aDist1112, aDist1122) <= Precision::Approximation() && - Min(aDist1221, aDist2122) <= Precision::Approximation()) - { - PrecRoot(C1, C2, aU0, aV0, - Max(TheCurvePGTool::FirstParameter(C1), aU0 - 10.0), - Min(TheCurvePGTool::LastParameter(C1), aU0 + 10.0), - Max(TheCurvePGTool::FirstParameter(C2), aV0 - 10.0), - Min(TheCurvePGTool::LastParameter(C2), aV0 + 10.0), - aU0, aV0); - } - - NbrSol++; - gp_Pnt2d Center(TheCurvePGTool::Value(C1, aU0)); - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); - // ======================================================= - qualifier1(NbrSol) = Qualified1.Qualifier(); - qualifier1(NbrSol) = Qualified1.Qualifier(); - TheSame1(NbrSol) = 0; - TheSame2(NbrSol) = 0; - pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); - pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); - pnttg1sol(NbrSol) = TheTool::Value(Cu1,pararg1(NbrSol)); - pnttg2sol(NbrSol) = TheTool::Value(Cu2,pararg2(NbrSol)); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg2sol(NbrSol)); - } - } - - WellDone = Standard_True; - } - } - } - } -} - -//========================================================================= - -Standard_Boolean GccGeo_Circ2d2TanRad:: -IsDone () const { return WellDone; } - -Standard_Integer GccGeo_Circ2d2TanRad:: -NbSolutions () const { return NbrSol; } - -gp_Circ2d GccGeo_Circ2d2TanRad:: -ThisSolution (const Standard_Integer Index) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - return cirsol(Index); -} - -void GccGeo_Circ2d2TanRad:: -WhichQualifier(const Standard_Integer Index , - GccEnt_Position& Qualif1 , - GccEnt_Position& Qualif2 ) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - else { - Qualif1 = qualifier1(Index); - Qualif2 = qualifier2(Index); - } -} - -void GccGeo_Circ2d2TanRad:: -Tangency1 (const Standard_Integer Index, - Standard_Real& ParSol, - Standard_Real& ParArg, - gp_Pnt2d& PntSol) const{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - else { - if (TheSame1(Index) == 0) { - ParSol = par1sol(Index); - ParArg = pararg1(Index); - PntSol = gp_Pnt2d(pnttg1sol(Index)); - } - else { StdFail_NotDone::Raise(); } - } -} - -void GccGeo_Circ2d2TanRad:: -Tangency2 (const Standard_Integer Index, - Standard_Real& ParSol, - Standard_Real& ParArg, - gp_Pnt2d& PntSol) const{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - else { - if (TheSame2(Index) == 0) { - ParSol = par2sol(Index); - ParArg = pararg2(Index); - PntSol = gp_Pnt2d(pnttg2sol(Index)); - } - else { StdFail_NotDone::Raise(); } - } -} - -Standard_Boolean GccGeo_Circ2d2TanRad:: -IsTheSame1 (const Standard_Integer Index) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - - if (TheSame1(Index) == 0) { return Standard_False; } - return Standard_True; -} - -Standard_Boolean GccGeo_Circ2d2TanRad:: -IsTheSame2 (const Standard_Integer Index) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - - if (TheSame2(Index) == 0) { return Standard_False; } - return Standard_True; -} - diff --git a/src/GccGeo/GccGeo_Circ2dTanCen.cdl b/src/GccGeo/GccGeo_Circ2dTanCen.cdl deleted file mode 100644 index 63ac5b8651..0000000000 --- a/src/GccGeo/GccGeo_Circ2dTanCen.cdl +++ /dev/null @@ -1,151 +0,0 @@ --- Created on: 1991-03-28 --- 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 Circ2dTanCen from GccGeo - (TheCurve as any; -- - TheCurveTool as any; -- as CurveTool(TheCurve) from GccInt - TheExtPC as any; -- as ExtPC(TheCurve,TheCurveTool) from Extrema - TheQualifiedCurve as any) -- as QCurve from GccInt - -- (TheCurve) - - ---Purpose: This class implements the algorithms used to - -- create 2d circles tangent to a curve and - -- centered on a point. - -- The arguments of all construction methods are : - -- - The qualified element for the tangency constrains - -- (QualifiedCurv). - -- -The center point Pcenter. - -- - A real Tolerance. - -- Tolerance is only used in the limits cases. - -- For example : - -- We want to create a circle tangent to an EnclosedCurv C1 - -- with a tolerance Tolerance. - -- If we did not use Tolerance it is impossible to - -- find a solution in the following case : Pcenter is - -- outside C1. - -- With Tolerance we will give a solution if the distance - -- between C1 and Pcenter is lower than or equal Tolerance/2. - --- inherits Entity from Standard - -uses Pnt2d from gp, - Circ2d from gp, - Array1OfCirc2d from TColgp, - Array1OfPnt2d from TColgp, - Array1OfReal from TColStd, - Array1OfInteger from TColStd, - Position from GccEnt, - Array1OfPosition from GccEnt - -raises OutOfRange from Standard, - BadQualifier from GccEnt, - NotDone from StdFail - -is - -Create( Qualified1 : TheQualifiedCurve ; - Pcenter : Pnt2d from gp ; - Tolerance : Real from Standard) returns Circ2dTanCen - ---Purpose: This method implements the algorithms used to - -- create 2d circles tangent to a circle and - -- centered on a point. -raises BadQualifier; - --- -- .................................................................... - -IsDone(me) returns Boolean from Standard -is static; - ---Purpose: This method returns True if the construction - -- algorithm succeeded. - -NbSolutions(me) returns Integer from Standard - ---Purpose: Returns the number of solutions and raises NotDone - -- exception if the algorithm didn't succeed. -raises NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -ThisSolution(me ; - Index : Integer from Standard) returns Circ2d from gp - ---Purpose: Returns the solution number Index and raises OutOfRange - -- exception if Index is greater than the number of solutions. - -- Be carefull: the Index is only a way to get all the - -- solutions, but is not associated to theses outside the - -- context of the algorithm-object. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions or less than zero. - -WhichQualifier(me ; - Index : Integer from Standard; - Qualif1 : out Position from GccEnt ) -raises OutOfRange, NotDone -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 ; - Index : Integer from Standard; - ParSol,ParArg : out Real from Standard; - PntSol : out Pnt2d from gp ) - ---Purpose: Returns informations about the tangency point between the - -- result number Index 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 PntArg - -- on the argument curv. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions or less than zero. - -fields - - WellDone : Boolean from Standard; - -- True if the algorithm succeeded. - - NbrSol : Integer from Standard; - -- The number of possible solutions. We have to decide about the - -- status of the multiple solutions... - - cirsol : Array1OfCirc2d from TColgp; - ---Purpose : The solutions. - - qualifier1 : Array1OfPosition from GccEnt; - -- The qualifiers of the first argument. - - pnttg1sol : Array1OfPnt2d from TColgp; - -- The tangency point between the solution and the first argument on - -- the solution. - - par1sol : Array1OfReal from TColStd; - -- The parameter of the tangency point between the solution and the - -- first argument on the solution. - - pararg1 : Array1OfReal from TColStd; - -- The parameter of the tangency point between the solution and the first - -- argument on the first argument. - -end Circ2dTanCen; diff --git a/src/GccGeo/GccGeo_Circ2dTanCen.gxx b/src/GccGeo/GccGeo_Circ2dTanCen.gxx deleted file mode 100644 index 7dc0a9d4ed..0000000000 --- a/src/GccGeo/GccGeo_Circ2dTanCen.gxx +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (c) 1995-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 -#include -#include -#include - -//========================================================================= -// Creation d un cercle tangent a une courbe centre en un point. + -//========================================================================= - -GccGeo_Circ2dTanCen:: - GccGeo_Circ2dTanCen (const TheQualifiedCurve& Qualified1, - const gp_Pnt2d& Pcenter , - const Standard_Real Tolerance ): - -//======================================================================== -// Initialisation des champs. + -//======================================================================== - - cirsol(1,2) , - qualifier1(1,2), - pnttg1sol(1,2) , - par1sol(1,2) , - pararg1(1,2) -{ - - Standard_Real Tol = Abs(Tolerance); - TColgp_Array1OfPnt2d pTan(1,2); - TColStd_Array1OfInteger Index(1,2); - TColStd_Array1OfReal theDist2(1,2); - TColStd_Array1OfReal theParam(1,2); - theDist2(1) = RealLast(); - theDist2(2) = 0.; - Standard_Integer i = 1; - Standard_Integer nbsol = 0; - gp_Dir2d dirx(1.0,0.0); - Standard_Real thePar; - TheCurve curve = Qualified1.Qualified(); - TheExtPC distmin(Pcenter,curve,TheCurveTool::NbSamples(curve), - TheCurveTool::EpsX(curve,Tol),Tol); - if (!distmin.IsDone() ) { Standard_Failure::Raise(); } - Standard_Integer nbext = distmin.NbExt(); - if(nbext==0) { Standard_Failure::Raise(); } - while (i<=nbext) { - thePar = distmin.Point(i).Parameter(); - if (distmin.SquareDistance(i)=TheCurveTool::FirstParameter(curve) && - thePar <= TheCurveTool::LastParameter(curve)) { - theDist2(1) = distmin.SquareDistance(i); - theParam(1) = thePar; - pTan(1) = distmin.Point(i).Value(); - } - if (distmin.SquareDistance(i)>theDist2(2) && - thePar>=TheCurveTool::FirstParameter(curve) && - thePar <= TheCurveTool::LastParameter(curve)) { - theDist2(2) = distmin.SquareDistance(i); - theParam(2) = thePar; - pTan(2) = distmin.Point(i).Value(); - } - i++; - } - if (Index(1) == Index(2)) { nbsol = 1; } - else { nbsol = 2; } - for (i = 1 ; i <= nbsol; i++) { - gp_Pnt2d point1; - gp_Vec2d Tan1; - TheCurveTool::D1(curve,theParam(i),point1,Tan1); - Standard_Real normetan1 = Tan1.Magnitude(); - gp_Vec2d Vec1(point1,Pcenter); - Standard_Real normevec1 = Vec1.Magnitude(); - Standard_Real dot1; - if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { - dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); - } - else { dot1 = 0.; } - Tol = 1.e-12; - if (dot1 <= Tol) { - Standard_Real Angle1 = Vec1.Angle(Tan1); - if (Qualified1.IsUnqualified()|| - (Qualified1.IsEnclosing()&&Angle1<=0.)|| - (Qualified1.IsOutside() && Angle1 >= 0.) || - (Qualified1.IsEnclosed() && Angle1 <= 0.)) { - NbrSol++; - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Pcenter,dirx),sqrt (theDist2(i))); - qualifier1(NbrSol) = Qualified1.Qualifier(); - pararg1(NbrSol) = theParam(i); - par1sol(NbrSol) = 0.; - pnttg1sol(NbrSol) = pTan(i); - WellDone = Standard_True; - } - } - } -} - - - -//========================================================================= - - -Standard_Boolean GccGeo_Circ2dTanCen:: - IsDone () const { return WellDone; } - -Standard_Integer GccGeo_Circ2dTanCen:: - NbSolutions () const { return NbrSol; } - -gp_Circ2d GccGeo_Circ2dTanCen:: - ThisSolution (const Standard_Integer Index) const -{ - if (Index > NbrSol || Index <= 0) Standard_OutOfRange::Raise(); - - return cirsol(Index); -} - -void GccGeo_Circ2dTanCen:: - WhichQualifier(const Standard_Integer Index , - GccEnt_Position& Qualif1 ) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - else { - Qualif1 = qualifier1(Index); - } -} - -void GccGeo_Circ2dTanCen:: - Tangency1 (const Standard_Integer Index, - Standard_Real& ParSol, - Standard_Real& ParArg, - gp_Pnt2d& PntSol) const{ - if (!WellDone) { - StdFail_NotDone::Raise(); - } - else if (Index <= 0 ||Index > NbrSol) { - Standard_OutOfRange::Raise(); - } - else { - PntSol = gp_Pnt2d(pnttg1sol(Index)); - ParSol = par1sol(Index); - ParArg = pararg1(Index); - } - } - diff --git a/src/GccGeo/GccGeo_Circ2dTanOnRad.cdl b/src/GccGeo/GccGeo_Circ2dTanOnRad.cdl deleted file mode 100644 index 221be61829..0000000000 --- a/src/GccGeo/GccGeo_Circ2dTanOnRad.cdl +++ /dev/null @@ -1,273 +0,0 @@ --- Created on: 1991-04-03 --- 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 Circ2dTanOnRad from GccGeo ( - TheCurve as any; -- - TheTool as any; -- - TheQCurve as any; -- as QualifiedCurv from GccEnt (TheCurve) - TheParGenCurve as any; -- as ParGenCurve from GccGeo - -- (TheCurve) - TheHParGenCurve as Transient; - TheCurvePGTool as any; -- as CurvePGTool from GccGeo - -- (Thecurve, - -- TheTool, - -- TheParGenCurve) - TheIntConicCurve as any; -- as IntConicCurveOfGOffsetInter - TheIntCurveCurve as any) -- as GOffSetInter from Geom2dInt - -- (TheParGenCurve, - -- TheCurvePGTool) - - ---Purpose: This class implements the algorithms used to - -- create a 2d circle tangent to a 2d entity, - -- centered on a 2d entity and with a given radius. - -- More than one argument must be a curve. - -- The arguments of all construction methods are : - -- - The qualified element for the tangency constrains - -- (QualifiedCirc, QualifiedLin, QualifiedCurvPoints). - -- - The Center element (circle, line, curve). - -- - A real Tolerance. - -- Tolerance is only used in the limits cases. - -- For example : - -- We want to create a circle tangent to an OutsideCurv Cu1 - -- centered on a line OnLine with a radius Radius and with - -- a tolerance Tolerance. - -- If we did not use Tolerance it is impossible to - -- find a solution in the following case : OnLine is - -- outside Cu1. There is no intersection point between Cu1 - -- and OnLine. The distance between the line and the - -- circle is greater than Radius. - -- With Tolerance we will give a solution if the - -- distance between Cu1 and OnLine is lower than or - -- equal Tolerance. - --- inherits Entity from Standard - -uses Lin2d from gp, - Circ2d from gp, - Pnt2d from gp, - Array1OfCirc2d from TColgp, - Array1OfPnt2d from TColgp, - QualifiedCirc from GccEnt, - QualifiedLin from GccEnt, - Array1OfReal from TColStd, - Array1OfInteger from TColStd, - Position from GccEnt, - Array1OfPosition from GccEnt - -raises NegativeValue from Standard, - OutOfRange from Standard, - BadQualifier from GccEnt, - NotDone from StdFail - -is - --- On a line ............................................................. - -Create(Qualified1 : TheQCurve ; - OnLine : Lin2d from gp ; - Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad - ---Purpose: This methods implements the algorithms used to create - -- 2d Circles tangent to a curve and centered on a 2d Line - -- with a given radius. - -- Tolerance is used to find solution in every limit cases. -raises NegativeValue, BadQualifier; - ---Purpose: raises NegativeValue in case of NegativeRadius. - --- -- On a circle ........................................................... - -Create(Qualified1 : TheQCurve ; - OnCirc : Circ2d from gp ; - Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad - ---Purpose: This methods implements the algorithms used to create - -- 2d Circles tangent to a curve and centered on a 2d Circle - -- with a given radius. - -- Tolerance is used to find solution in every limit cases. -raises NegativeValue, BadQualifier; - ---Purpose: raises NegativeValue in case of NegativeRadius. - --- On a curve ............................................................ - -Create(Qualified1 : QualifiedCirc from GccEnt ; - OnCurv : TheCurve ; - Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad - ---Purpose: This methods implements the algorithms used to create - -- 2d Circles tangent to a circle and centered on a 2d curve - -- with a given radius. - -- Tolerance is used to find solution in every limit cases. -raises NegativeValue, BadQualifier; - ---Purpose: raises NegativeValue in case of NegativeRadius. - -Create(Qualified1 : QualifiedLin from GccEnt ; - OnCurv : TheCurve ; - Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad - ---Purpose: This methods implements the algorithms used to create - -- 2d Circles tangent to a 2d Line and centered on a 2d curve - -- with a given radius. - -- Tolerance is used to find solution in every limit cases. -raises NegativeValue, BadQualifier; - ---Purpose: raises NegativeValue in case of NegativeRadius. - -Create(Qualified1 : TheQCurve ; - OnCurv : TheCurve ; - Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad - ---Purpose: This methods implements the algorithms used to create - -- 2d Circles tangent to a 2d curve and centered on a 2d curve - -- with a given radius. - -- Tolerance is used to find solution in every limit cases. -raises NegativeValue, BadQualifier; - ---Purpose: raises NegativeValue in case of NegativeRadius. - -Create(Point1 : Pnt2d from gp ; - OnCurv : TheCurve ; - Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad - ---Purpose: This methods implements the algorithms used to create - -- 2d Circles passing through a 2d point and centered on a - -- 2d curve with a given radius. - -- Tolerance is used to find solution in every limit cases. -raises NegativeValue; - ---Purpose: raises NegativeValue in case of NegativeRadius. - --- -- .................................................................... - -IsDone(me) returns Boolean from Standard -is static; - ---Purpose: This method returns True if the construction - -- algorithm succeeded. - -NbSolutions(me) returns Integer from Standard - ---Purpose: This method returns the number of solutions. -raises NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -ThisSolution(me ; - Index : Integer from Standard) returns Circ2d from gp - ---Purpose: Returns the solution number Index and raises OutOfRange - -- exception if Index is greater than the number of solutions. - -- Be careful: the Index is only a way to get all the - -- solutions, but is not associated to theses outside the - -- context of the algorithm-object. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions. - -WhichQualifier(me ; - Index : Integer from Standard; - Qualif1 : out Position from GccEnt ) -raises OutOfRange, NotDone -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 ; - Index : Integer from Standard; - ParSol,ParArg : out Real from Standard; - PntSol : out Pnt2d from gp ) - ---Purpose: Returns informations about the tangency point between the - -- result number Index and the first argument. - -- ParSol is the intrinsic parameter of the point on the - -- solution curv. - -- ParArg is the intrinsic parameter of the point on the - -- argument curv. - -- PntSol is the tangency point on the solution curv. - -- PntArg is the tangency point on the argument curv. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions. - -CenterOn3 (me ; - Index : Integer from Standard; - ParArg : out Real from Standard; - PntSol : out Pnt2d from gp ) - ---Purpose: Returns informations about the center (on the curv) - -- of the result. - -- ParArg is the intrinsic parameter of the point on - -- the argument curv. - -- PntSol is the center point of the solution curv. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions. - -IsTheSame1(me ; - Index : Integer from Standard) returns Boolean from Standard - ---Purpose: Returns True if the solution number Index is equal to - -- the first argument and False in the other cases. -raises OutOfRange, NotDone -is static; - ---Purpose: It raises NotDone if the construction algorithm - -- didn't succeed. - -- It raises OutOfRange if Index is greater than the - -- number of solutions. - -fields - - WellDone : Boolean from Standard; - ---Purpose: True if the algorithm succeeded. - - NbrSol : Integer from Standard; - ---Purpose: The number of possible solutions. We have to decide about the - -- status of the multiple solutions... - - cirsol : Array1OfCirc2d from TColgp; - ---Purpose : The solutions. - - qualifier1 : Array1OfPosition from GccEnt; - -- The qualifiers of the first argument. - - TheSame1 : Array1OfInteger from TColStd; - ---Purpose: 1 if the solution and the first argument are the same in the - -- tolerance of Tolerance. - -- 0 in the other cases. - - pnttg1sol : Array1OfPnt2d from TColgp; - ---Purpose: The tangency point between the solution and the first - -- argument on the solution. - - pntcen3 : Array1OfPnt2d from TColgp; - ---Purpose: The center point of the solution on the first argument. - - par1sol : Array1OfReal from TColStd; - ---Purpose: The parameter of the tangency point between the solution - -- and the first argument on thesolution. - - pararg1 : Array1OfReal from TColStd; - ---Purpose: The parameter of the tangency point between the solution - -- and the first argument on the first argument. - - parcen3 : Array1OfReal from TColStd; - ---Purpose: The parameter of the center point of the solution on the - -- second argument. - -end Circ2dTanOnRad; diff --git a/src/GccGeo/GccGeo_Circ2dTanOnRad.gxx b/src/GccGeo/GccGeo_Circ2dTanOnRad.gxx deleted file mode 100644 index 24a5951a36..0000000000 --- a/src/GccGeo/GccGeo_Circ2dTanOnRad.gxx +++ /dev/null @@ -1,777 +0,0 @@ -// Copyright (c) 1995-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. - -//======================================================================== -// circulaire tangent a un element de type : - Cercle. + -// - Ligne. + -// - Point. + -// centre sur un deuxieme element de type : - Cercle. + -// - Ligne. + -// de rayon donne : Radius. + -//======================================================================== - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//========================================================================= -// Cercle tangent : a un cercle Qualified1 (C1). + -// centre : sur une droite OnLine. + -// de rayon : Radius. + -// + -// On initialise le tableau de solutions cirsol ainsi que tous les + -// champs. + -// On elimine en fonction du qualifieur les cas ne presentant pas de + -// solutions. + -// On resoud l equation du second degre indiquant que le point de centre + -// recherche (xc,yc) est a une distance Radius du cercle C1 et + -// sur la droite OnLine. + -// Les solutions sont representees par les cercles : + -// - de centre Pntcen(xc,yc) + -// - de rayon Radius. + -//========================================================================= - -GccGeo_Circ2dTanOnRad:: - GccGeo_Circ2dTanOnRad (const TheQCurve& Qualified1, - const gp_Lin2d& OnLine , - const Standard_Real Radius , - const Standard_Real Tolerance ): - -//========================================================================= -// Initialisation des champs. + -//========================================================================= - - cirsol(1,8) , - qualifier1(1,8) , - TheSame1(1,8) , - pnttg1sol(1,8) , - pntcen3(1,8) , - par1sol(1,8) , - pararg1(1,8) , - parcen3(1,8) -{ - -//========================================================================= -// Traitement. + -//========================================================================= - - gp_Dir2d dirx(1.0,0.0); - Standard_Real Tol = Abs(Tolerance); - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - WellDone = Standard_False; - NbrSol = 0; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Integer nbrcote1 = 0; - TColStd_Array1OfReal Coef(1,2); - TheCurve Cu1 = Qualified1.Qualified(); - - if (Radius < 0.0) { Standard_NegativeValue::Raise(); } - else { - if (Qualified1.IsEnclosed()) { -// =========================== - nbrcote1 = 1; - Coef(1) = Radius; - } - else if(Qualified1.IsOutside()) { -// =============================== - nbrcote1 = 1; - Coef(1) = -Radius; - } - else if(Qualified1.IsUnqualified()) { -// =================================== - nbrcote1 = 2; - Coef(1) = Radius; - Coef(2) = -Radius; - } - IntRes2d_Domain D1; - TheIntConicCurve Intp; - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { - Handle(TheHParGenCurve) HCu1 = new TheHParGenCurve(Cu1); - TheParGenCurve C2(HCu1,Coef(jcote1)); - firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); - Intp.Perform(OnLine,D1,C2,D2,Tol,Tol); - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { - NbrSol++; - gp_Pnt2d Center(Intp.Point(i).Value()); - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= - qualifier1(NbrSol) = Qualified1.Qualifier(); - TheSame1(NbrSol) = 0; - pararg1(NbrSol) = Intp.Point(i).ParamOnSecond(); - parcen3(NbrSol) = Intp.Point(i).ParamOnFirst(); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pnttg1sol(NbrSol) = gp_Pnt2d(TheTool::Value(Cu1,pararg1(NbrSol))); - pntcen3(NbrSol) = Center; - } - } - WellDone = Standard_True; - } - } - } - } - -//========================================================================= -// Cercle tangent : a un cercle Qualified1 (C1). + -// centre : sur une droite OnLine. + -// de rayon : Radius. + -// + -// On initialise le tableau de solutions cirsol ainsi que tous les + -// champs. + -// On elimine en fonction du qualifieur les cas ne presentant pas de + -// solutions. + -// On resoud l equation du second degre indiquant que le point de centre + -// recherche (xc,yc) est a une distance Radius du cercle C1 et + -// sur la droite OnLine. + -// Les solutions sont representees par les cercles : + -// - de centre Pntcen(xc,yc) + -// - de rayon Radius. + -//========================================================================= - -GccGeo_Circ2dTanOnRad:: - GccGeo_Circ2dTanOnRad (const TheQCurve& Qualified1, - const gp_Circ2d& OnCirc , - const Standard_Real Radius , - const Standard_Real Tolerance ): - -//========================================================================= -// Initialisation des champs. + -//========================================================================= - - cirsol(1,8) , - qualifier1(1,8) , - TheSame1(1,8) , - pnttg1sol(1,8) , - pntcen3(1,8) , - par1sol(1,8) , - pararg1(1,8) , - parcen3(1,8) -{ - -//========================================================================= -// Traitement. + -//========================================================================= - - gp_Dir2d dirx(1.0,0.0); - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - Standard_Real Tol = Abs(Tolerance); - Standard_Integer nbrcote1=0; - WellDone = Standard_False; - NbrSol = 0; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - TColStd_Array1OfReal cote1(1,2); - TheCurve Cu1 = Qualified1.Qualified(); - - if (Radius < 0.0) { - Standard_NegativeValue::Raise(); - } - else { - if (Qualified1.IsEnclosed()) { -// =========================== - nbrcote1 = 1; - cote1(1) = Radius; - } - else if(Qualified1.IsOutside()) { -// =============================== - nbrcote1 = 1; - cote1(1) = -Radius; - } - else if(Qualified1.IsUnqualified()) { -// =================================== - nbrcote1 = 2; - cote1(1) = Radius; - cote1(2) = -Radius; - } - IntRes2d_Domain D1(ElCLib::Value(0.,OnCirc), 0.,Tol, - ElCLib::Value(2.*M_PI,OnCirc),2.*M_PI,Tol); - D1.SetEquivalentParameters(0.,2.*M_PI); - TheIntConicCurve Intp; - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { - Handle(TheHParGenCurve) HCu1 = new TheHParGenCurve(Cu1); - TheParGenCurve C2(HCu1,cote1(jcote1)); - firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); - Intp.Perform(OnCirc,D1,C2,D2,Tol,Tol); - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { - NbrSol++; - gp_Pnt2d Center(Intp.Point(i).Value()); - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= - qualifier1(NbrSol) = Qualified1.Qualifier(); - TheSame1(NbrSol) = 0; - pararg1(NbrSol) = Intp.Point(i).ParamOnSecond(); - parcen3(NbrSol) = Intp.Point(i).ParamOnFirst(); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pnttg1sol(NbrSol) = gp_Pnt2d(TheTool::Value(Cu1,pararg1(NbrSol))); - pntcen3(NbrSol) = Center; - } - } - WellDone = Standard_True; - } - } - } - } - -//========================================================================= -// Cercle tangent : a un cercle Qualified1 (C1). + -// centre : sur une droite OnLine. + -// de rayon : Radius. + -// + -// On initialise le tableau de solutions cirsol ainsi que tous les + -// champs. + -// On elimine en fonction du qualifieur les cas ne presentant pas de + -// solutions. + -// On resoud l equation du second degre indiquant que le point de centre + -// recherche (xc,yc) est a une distance Radius du cercle C1 et + -// sur la droite OnLine. + -// Les solutions sont representees par les cercles : + -// - de centre Pntcen(xc,yc) + -// - de rayon Radius. + -//========================================================================= - -GccGeo_Circ2dTanOnRad:: - GccGeo_Circ2dTanOnRad (const GccEnt_QualifiedCirc& Qualified1, - const TheCurve& OnCurv , - const Standard_Real Radius , - const Standard_Real Tolerance ): - -//========================================================================= -// Initialisation des champs. + -//========================================================================= - - cirsol(1,8) , - qualifier1(1,8) , - TheSame1(1,8) , - pnttg1sol(1,8) , - pntcen3(1,8) , - par1sol(1,8) , - pararg1(1,8) , - parcen3(1,8) -{ - -//========================================================================= -// Traitement. + -//========================================================================= - - gp_Dir2d dirx(1.0,0.0); - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - Standard_Real Tol = Abs(Tolerance); - Standard_Integer nbrcote1=0; - WellDone = Standard_False; - NbrSol = 0; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - TColStd_Array1OfReal cote1(1,2); - gp_Circ2d C1 = Qualified1.Qualified(); - gp_Pnt2d center1(C1.Location()); - Standard_Real R1 = C1.Radius(); - - if (Radius < 0.0) { - Standard_NegativeValue::Raise(); - } - else { - if (Qualified1.IsEnclosed()) { -// =========================== - nbrcote1 = 1; - cote1(1) = Radius; - } - else if(Qualified1.IsOutside()) { -// =============================== - nbrcote1 = 1; - cote1(1) = -Radius; - } - else if(Qualified1.IsUnqualified()) { -// =================================== - nbrcote1 = 2; - cote1(1) = Radius; - cote1(2) = -Radius; - } - TheIntConicCurve Intp; - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { - gp_Circ2d Circ(C1.XAxis(),R1 + cote1(jcote1)); - IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, - ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol); - D1.SetEquivalentParameters(0.,2.*M_PI); - firstparam = Max(TheTool::FirstParameter(OnCurv),thefirst); - lastparam = Min(TheTool::LastParameter(OnCurv),thelast); - IntRes2d_Domain D2(TheTool::Value(OnCurv,firstparam),firstparam,Tol, - TheTool::Value(OnCurv,lastparam),lastparam,Tol); - Intp.Perform(Circ,D1,OnCurv,D2,Tol,Tol); - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { - NbrSol++; - gp_Pnt2d Center(Intp.Point(i).Value()); - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= - Standard_Real distcc1 = Center.Distance(center1); - if (!Qualified1.IsUnqualified()) { - qualifier1(NbrSol) = Qualified1.Qualifier(); - } - else if (Abs(distcc1+Radius-R1) < Tol) { - qualifier1(NbrSol) = GccEnt_enclosed; - } - else if (Abs(distcc1-R1-Radius) < Tol) { - qualifier1(NbrSol) = GccEnt_outside; - } - else { qualifier1(NbrSol) = GccEnt_enclosing; } - TheSame1(NbrSol) = 0; - pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); - parcen3(NbrSol) = Intp.Point(i).ParamOnSecond(); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),C1); - pntcen3(NbrSol) = Center; - } - } - WellDone = Standard_True; - } - } - } - } - -//========================================================================= -// Cercle tangent : a un cercle Qualified1 (C1). + -// centre : sur une droite OnLine. + -// de rayon : Radius. + -// + -// On initialise le tableau de solutions cirsol ainsi que tous les + -// champs. + -// On elimine en fonction du qualifieur les cas ne presentant pas de + -// solutions. + -// On resoud l equation du second degre indiquant que le point de centre + -// recherche (xc,yc) est a une distance Radius du cercle C1 et + -// sur la droite OnLine. + -// Les solutions sont representees par les cercles : + -// - de centre Pntcen(xc,yc) + -// - de rayon Radius. + -//========================================================================= - -GccGeo_Circ2dTanOnRad:: - GccGeo_Circ2dTanOnRad (const GccEnt_QualifiedLin& Qualified1, - const TheCurve& OnCurv , - const Standard_Real Radius , - const Standard_Real Tolerance ): - -//========================================================================= -// Initialisation des champs. + -//========================================================================= - - cirsol(1,8) , - qualifier1(1,8) , - TheSame1(1,8) , - pnttg1sol(1,8) , - pntcen3(1,8) , - par1sol(1,8) , - pararg1(1,8) , - parcen3(1,8) -{ - -//========================================================================= -// Traitement. + -//========================================================================= - - gp_Dir2d dirx(1.0,0.0); - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - NbrSol = 0; - if (!(Qualified1.IsEnclosed() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - Standard_Integer nbrcote1=0; - TColStd_Array1OfReal cote1(1,2); - gp_Lin2d L1 = Qualified1.Qualified(); - gp_Pnt2d origin1(L1.Location()); - gp_Dir2d dir1(L1.Direction()); - gp_Dir2d norm1(-dir1.Y(),dir1.X()); - - if (Radius < 0.0) { - Standard_NegativeValue::Raise(); - } - else { - if (Qualified1.IsEnclosed()) { -// =========================== - nbrcote1 = 1; - cote1(1) = Radius; - } - else if(Qualified1.IsOutside()) { -// =============================== - nbrcote1 = 1; - cote1(1) = -Radius; - } - else if(Qualified1.IsUnqualified()) { -// =================================== - nbrcote1 = 2; - cote1(1) = Radius; - cote1(2) = -Radius; - } - TheIntConicCurve Intp; - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { - gp_Pnt2d Point(dir1.XY()+cote1(jcote1)*norm1.XY()); - gp_Lin2d Line(Point,dir1); // ligne avec deport. - IntRes2d_Domain D1; - firstparam = Max(TheTool::FirstParameter(OnCurv),thefirst); - lastparam = Min(TheTool::LastParameter(OnCurv),thelast); - IntRes2d_Domain D2(TheTool::Value(OnCurv,firstparam),firstparam,Tol, - TheTool::Value(OnCurv,lastparam),lastparam,Tol); - Intp.Perform(Line,D1,OnCurv,D2,Tol,Tol); - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { - NbrSol++; - gp_Pnt2d Center(Intp.Point(i).Value()); - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= - gp_Dir2d dc1(origin1.XY()-Center.XY()); - if (!Qualified1.IsUnqualified()) { - qualifier1(NbrSol) = Qualified1.Qualifier(); - } - else if (dc1.Dot(norm1) > 0.0) { - qualifier1(NbrSol) = GccEnt_outside; - } - else { qualifier1(NbrSol) = GccEnt_enclosed; } - TheSame1(NbrSol) = 0; - pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); - parcen3(NbrSol) = Intp.Point(i).ParamOnSecond(); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),L1); - pntcen3(NbrSol) = Center; - } - } - WellDone = Standard_True; - } - } - } - } - -//========================================================================= -// Cercle tangent : a un cercle Qualified1 (C1). + -// centre : sur une droite OnLine. + -// de rayon : Radius. + -// + -// On initialise le tableau de solutions cirsol ainsi que tous les + -// champs. + -// On elimine en fonction du qualifieur les cas ne presentant pas de + -// solutions. + -// On resoud l equation du second degre indiquant que le point de centre + -// recherche (xc,yc) est a une distance Radius du cercle C1 et + -// sur la droite OnLine. + -// Les solutions sont representees par les cercles : + -// - de centre Pntcen(xc,yc) + -// - de rayon Radius. + -//========================================================================= - -GccGeo_Circ2dTanOnRad:: - GccGeo_Circ2dTanOnRad (const TheQCurve& Qualified1, - const TheCurve& OnCurv , - const Standard_Real Radius , - const Standard_Real Tolerance ): - -//========================================================================= -// Initialisation des champs. + -//========================================================================= - - cirsol(1,8) , - qualifier1(1,8) , - TheSame1(1,8) , - pnttg1sol(1,8) , - pntcen3(1,8) , - par1sol(1,8) , - pararg1(1,8) , - parcen3(1,8) -{ - -//========================================================================= -// Traitement. + -//========================================================================= - - gp_Dir2d dirx(1.0,0.0); - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - Standard_Real Tol = Abs(Tolerance); - Standard_Integer nbrcote1=0; - WellDone = Standard_False; - NbrSol = 0; - if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || - Qualified1.IsOutside() || Qualified1.IsUnqualified())) { - GccEnt_BadQualifier::Raise(); - return; - } - TColStd_Array1OfReal cote1(1,2); - TheCurve Cu1 = Qualified1.Qualified(); - - if (Radius < 0.0) { - Standard_NegativeValue::Raise(); - } - else { - if (Qualified1.IsEnclosed()) { -// =========================== - nbrcote1 = 1; - cote1(1) = Radius; - } - else if(Qualified1.IsOutside()) { -// =============================== - nbrcote1 = 1; - cote1(1) = -Radius; - } - else if(Qualified1.IsUnqualified()) { -// =================================== - nbrcote1 = 2; - cote1(1) = Radius; - cote1(2) = -Radius; - } - TheIntCurveCurve Intp; - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { - Handle(TheHParGenCurve) HCu1 = new TheHParGenCurve(Cu1); - TheParGenCurve C1(HCu1,cote1(jcote1)); - firstparam = Max(TheCurvePGTool::FirstParameter(C1),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C1),thelast); - IntRes2d_Domain D1(TheCurvePGTool::Value(C1,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C1,lastparam),lastparam,Tol); - Handle(TheHParGenCurve) HOnCurv = new TheHParGenCurve(OnCurv); - TheParGenCurve C2(HOnCurv); - firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); - lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); - IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); - Intp.Perform(C1,D1,C2,D2,Tol,Tol); - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { - NbrSol++; - gp_Pnt2d Center(Intp.Point(i).Value()); - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= - qualifier1(NbrSol) = Qualified1.Qualifier(); - TheSame1(NbrSol) = 0; - pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); - parcen3(NbrSol) = Intp.Point(i).ParamOnSecond(); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pnttg1sol(NbrSol) = gp_Pnt2d(TheTool::Value(Cu1,pararg1(NbrSol))); - pntcen3(NbrSol) = Center; - } - } - WellDone = Standard_True; - } - } - } - } - -//========================================================================= -// Cercle tangent : a un cercle Qualified1 (C1). + -// centre : sur une droite OnLine. + -// de rayon : Radius. + -// + -// On initialise le tableau de solutions cirsol ainsi que tous les + -// champs. + -// On elimine en fonction du qualifieur les cas ne presentant pas de + -// solutions. + -// On resoud l equation du second degre indiquant que le point de centre + -// recherche (xc,yc) est a une distance Radius du cercle C1 et + -// sur la droite OnLine. + -// Les solutions sont representees par les cercles : + -// - de centre Pntcen(xc,yc) + -// - de rayon Radius. + -//========================================================================= - -GccGeo_Circ2dTanOnRad:: - GccGeo_Circ2dTanOnRad (const gp_Pnt2d& Point1 , - const TheCurve& OnCurv , - const Standard_Real Radius , - const Standard_Real Tolerance ): - -//========================================================================= -// Initialisation des champs. + -//========================================================================= - - cirsol(1,8) , - qualifier1(1,8) , - TheSame1(1,8) , - pnttg1sol(1,8) , - pntcen3(1,8) , - par1sol(1,8) , - pararg1(1,8) , - parcen3(1,8) -{ - -//========================================================================= -// Traitement. + -//========================================================================= - - gp_Dir2d dirx(1.0,0.0); - Standard_Real thefirst = -100000.; - Standard_Real thelast = 100000.; - Standard_Real firstparam; - Standard_Real lastparam; - Standard_Real Tol = Abs(Tolerance); - WellDone = Standard_False; - NbrSol = 0; - - if (Radius < 0.0) { - Standard_NegativeValue::Raise(); - } - else { -// gp_Dir2d Dir(-y1dir,x1dir); - gp_Circ2d Circ(gp_Ax2d(Point1,gp_Dir2d(1.,0.)),Radius); - IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, - ElCLib::Value(2.*M_PI,Circ),2*M_PI,Tol); - D1.SetEquivalentParameters(0.,2.*M_PI); - firstparam = Max(TheTool::FirstParameter(OnCurv),thefirst); - lastparam = Min(TheTool::LastParameter(OnCurv),thelast); - IntRes2d_Domain D2(TheTool::Value(OnCurv,firstparam),firstparam,Tol, - TheTool::Value(OnCurv,lastparam),lastparam,Tol); - TheIntConicCurve Intp(Circ,D1,OnCurv,D2,Tol,Tol); - if (Intp.IsDone()) { - if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { - NbrSol++; - gp_Pnt2d Center(Intp.Point(i).Value()); - cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); -// ======================================================= - qualifier1(NbrSol) = GccEnt_noqualifier; - TheSame1(NbrSol) = 0; - pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); - parcen3(NbrSol) = Intp.Point(i).ParamOnSecond(); - par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), - pnttg1sol(NbrSol)); - pnttg1sol(NbrSol) = Point1; - pntcen3(NbrSol) = Center; - } - WellDone = Standard_True; - } - } - } - } - -//========================================================================= - -Standard_Boolean GccGeo_Circ2dTanOnRad:: - IsDone () const { return WellDone; } - -Standard_Integer GccGeo_Circ2dTanOnRad:: - NbSolutions () const { return NbrSol; } - -gp_Circ2d GccGeo_Circ2dTanOnRad:: - ThisSolution (const Standard_Integer Index) const -{ - - if (Index > NbrSol || Index <= 0) - Standard_OutOfRange::Raise(); - - return cirsol(Index); -} - -void GccGeo_Circ2dTanOnRad:: - WhichQualifier(const Standard_Integer Index , - GccEnt_Position& Qualif1 ) const -{ - if (!WellDone) { StdFail_NotDone::Raise(); } - else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } - else { - Qualif1 = qualifier1(Index); - } -} - -void GccGeo_Circ2dTanOnRad:: - Tangency1 (const Standard_Integer Index, - Standard_Real& ParSol, - Standard_Real& ParArg, - gp_Pnt2d& PntSol) const{ - if (!WellDone) { - StdFail_NotDone::Raise(); - } - else if (Index <= 0 ||Index > NbrSol) { - Standard_OutOfRange::Raise(); - } - else { - ParSol = par1sol(Index); - ParArg = pararg1(Index); - PntSol = gp_Pnt2d(pnttg1sol(Index)); - } - } - -void GccGeo_Circ2dTanOnRad:: - CenterOn3 (const Standard_Integer Index, - Standard_Real& ParArg, - gp_Pnt2d& PntSol) const { - if (!WellDone) { - StdFail_NotDone::Raise(); - } - else if (Index <= 0 ||Index > NbrSol) { - Standard_OutOfRange::Raise(); - } - else { - ParArg = parcen3(Index); - PntSol = pnttg1sol(Index); - } - } - -Standard_Boolean GccGeo_Circ2dTanOnRad:: - IsTheSame1 (const Standard_Integer Index) const -{ - if (!WellDone) StdFail_NotDone::Raise(); - if (Index <= 0 ||Index > NbrSol) Standard_OutOfRange::Raise(); - - if (TheSame1(Index) == 0) - return Standard_False; - - return Standard_True; -} diff --git a/src/GccGeo/GccGeo_CurvePGTool.cdl b/src/GccGeo/GccGeo_CurvePGTool.cdl deleted file mode 100644 index bb99d123e9..0000000000 --- a/src/GccGeo/GccGeo_CurvePGTool.cdl +++ /dev/null @@ -1,128 +0,0 @@ --- Created on: 1992-06-04 --- Created by: Jacques GOUSSARD --- 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 CurvePGTool from GccGeo ( - TheCurve as any; - TheCurveTool as any; -- as CurveTool(TheCurve) from GccInt - TheParGenCurve as any) -- as ParGenCurve(TheCurve) from GccGeo - ---Purpose: - -uses Pnt2d from gp, - Vec2d from gp, - Lin2d from gp, - Circ2d from gp, - Elips2d from gp, - Parab2d from gp, - Hypr2d from gp, - CurveType from GeomAbs, - Shape from GeomAbs - -is - - TheType(myclass; C: TheParGenCurve ) - returns CurveType from GeomAbs; - - Line(myclass; C: TheParGenCurve) - ---Purpose: Returns the Lin2d from gp corresponding to the curve C. - -- This method is called only when TheType returns - -- IntCurve_Lin. - returns Lin2d from gp; - - Circle(myclass; C: TheParGenCurve) - ---Purpose: Returns the Circ2d from gp corresponding to the curve C. - -- This method is called only when TheType returns - -- IntCurve_Cir. - returns Circ2d from gp; - - Ellipse(myclass; C: TheParGenCurve) - ---Purpose: Returns the Elips2d from gp corresponding to the curve C. - -- This method is called only when TheType returns - -- IntCurve_Eli. - returns Elips2d from gp; - - Parabola(myclass; C: TheParGenCurve) - ---Purpose: Returns the Parab2d from gp corresponding to the curve C. - -- This method is called only when TheType returns - -- IntCurve_Prb. - returns Parab2d from gp; - - Hyperbola(myclass; C: TheParGenCurve) - ---Purpose: Returns the Hypr2d from gp corresponding to the curve C. - -- This method is called only when TheType returns - -- IntCurve_Hpr. - returns Hypr2d from gp; - --- The following method are used only when TheType returns IntCurve_Other. - - FirstParameter(myclass;C: TheParGenCurve) - returns Real; - - LastParameter(myclass;C: TheParGenCurve) - returns Real; - - EpsX (myclass ; - C : TheParGenCurve ; - Tol : Real from Standard) - returns Real; - - NbSamples(myclass ; - C : TheParGenCurve) - returns Integer; - - Value (myclass ; - C : TheParGenCurve; - X : Real ) - returns Pnt2d from gp; - - D1 (myclass; C : TheParGenCurve ; - U : Real ; - P : out Pnt2d ; - T : out Vec2d ); - - D2 (myclass; C : TheParGenCurve ; - U : Real ; - P : out Pnt2d ; - T,N : out Vec2d ); - - IsComposite(myclass; C:TheParGenCurve) - - returns Boolean from Standard; - --- The following methods are used only when IsComposite returns True. - - - GetIntervals(myclass ; C:TheParGenCurve) returns Integer from Standard; - ---Purpose : Outputs the number of interval of continuity C1 of - -- the curve - -- used if Type == Composite. - - GetInterval (myclass; C : TheParGenCurve - ; Index : Integer from Standard - ; U1, U2 : out Real from Standard); - ---Purpose : Outputs the bounds of interval of index - -- used if Type == Composite. - - SetCurrentInterval (myclass; C: in out TheParGenCurve - ; Index : Integer from Standard); - ---Purpose : Set the current valid interval of index - -- inside which the computations will be done - -- (used if Type == Composite). - -end CurvePGTool; - - - - diff --git a/src/GccGeo/GccGeo_CurvePGTool.gxx b/src/GccGeo/GccGeo_CurvePGTool.gxx deleted file mode 100644 index 5c556a3ede..0000000000 --- a/src/GccGeo/GccGeo_CurvePGTool.gxx +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) 1995-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 -#include -#include -#include -#include - - -#include -#include - - -GeomAbs_CurveType GccGeo_CurvePGTool:: - TheType(const TheParGenCurve& ) { - return GeomAbs_OtherCurve; -} - -gp_Lin2d GccGeo_CurvePGTool:: - Line (const TheParGenCurve& ) { - cout << "Not implemented" << endl; - return gp_Lin2d(); -} - -gp_Circ2d GccGeo_CurvePGTool:: - Circle (const TheParGenCurve& ) { - cout << "Not implemented" << endl; - return gp_Circ2d(); -} - -gp_Elips2d GccGeo_CurvePGTool:: - Ellipse (const TheParGenCurve& ) { - cout << "Not implemented" << endl; - return gp_Elips2d(); -} - -gp_Parab2d GccGeo_CurvePGTool:: - Parabola (const TheParGenCurve& ) { - cout << "Not implemented" << endl; - return gp_Parab2d(); -} - -gp_Hypr2d GccGeo_CurvePGTool:: - Hyperbola (const TheParGenCurve& ) { - cout << "Not implemented" << endl; - return gp_Hypr2d(); -} - -Standard_Real - GccGeo_CurvePGTool::EpsX (const TheParGenCurve& /*C*/, - const Standard_Real Tol) { - return Tol; -} - -Standard_Integer - GccGeo_CurvePGTool::NbSamples (const TheParGenCurve& C) { - GeomAbs_CurveType typC = C.GetType(); - Standard_Integer nbs = 20; - if(typC == GeomAbs_Line) - nbs = 2; - else if(typC == GeomAbs_BezierCurve) - nbs = 3 + C.Bezier()->NbPoles(); - else if(typC == GeomAbs_BSplineCurve) { - Handle(Geom2d_BSplineCurve) BSC = C.BSpline(); - nbs = BSC->NbKnots(); - nbs*= BSC->Degree(); - if(nbs < 2) nbs=2; - } - return(nbs); -} - -Standard_Real - GccGeo_CurvePGTool::FirstParameter (const TheParGenCurve& C) { - return C.FirstParameter(); -} - -Standard_Real - GccGeo_CurvePGTool::LastParameter (const TheParGenCurve& C) { - return C.LastParameter(); -} - -gp_Pnt2d - GccGeo_CurvePGTool::Value (const TheParGenCurve& C, - const Standard_Real U) { - - return C.Value(U); -} - -void GccGeo_CurvePGTool::D1(const TheParGenCurve& C, - const Standard_Real U, - gp_Pnt2d& P, - gp_Vec2d& T) { - C.D1(U,P,T); -} - -void GccGeo_CurvePGTool::D2(const TheParGenCurve& C, - const Standard_Real U, - gp_Pnt2d& P, - gp_Vec2d& T, - gp_Vec2d& N) { - C.D2(U,P,T,N); -} - -Standard_Boolean GccGeo_CurvePGTool:: - IsComposite (const TheParGenCurve& ) { - return Standard_False; -} - -Standard_Integer GccGeo_CurvePGTool:: - GetIntervals (const TheParGenCurve& ) { - cout << "Not implemented" << endl; - return 0; -} - -void GccGeo_CurvePGTool:: - GetInterval (const TheParGenCurve& , - const Standard_Integer , - Standard_Real& , - Standard_Real& ) { - cout << "Not implemented" << endl; -} - -void GccGeo_CurvePGTool:: - SetCurrentInterval ( TheParGenCurve& , - const Standard_Integer ) { - cout << "Not implemented" << endl; -} - - - - diff --git a/src/GccGeo/GccGeo_ParGenCurve.cdl b/src/GccGeo/GccGeo_ParGenCurve.cdl deleted file mode 100644 index 15c0a36e9c..0000000000 --- a/src/GccGeo/GccGeo_ParGenCurve.cdl +++ /dev/null @@ -1,58 +0,0 @@ --- Created on: 1991-11-18 --- 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 ParGenCurve from GccGeo (TheCurve as any) - - ---Purpose: Definition of a virtual curve. - -uses Pnt2d from gp, - Vec2d from gp - -is - -Create returns ParGenCurve; - -Create(C : TheCurve) returns ParGenCurve; - -Create(C : TheCurve ; - D : Real from Standard ) returns ParGenCurve; - -Value(me; U : Real)returns Pnt2d; - --- Purpose : Computes the point of parameter U on the curve - -D1 (me; U : Real; P : out Pnt2d from gp ; V : out Vec2d from gp); - --- Purpose : Computes the point of parameter U on the curve with its - -- first derivative. - -D2 (me; U : Real; P : out Pnt2d from gp ; V1,V2 : out Vec2d from gp); - --- Purpose : Computes the point of parameter U on the curve with its - -- first derivative and second derivative. - - -FirstParameter(me) returns Real; - -LastParameter(me) returns Real; - -GetResolution(me) returns Real; - -GetIntervals(me) returns Integer; - -fields - -Cu : TheCurve ; -Dep : Real from Standard; - -end ParGenCurve; diff --git a/src/GccGeo/GccGeo_ParGenCurve.gxx b/src/GccGeo/GccGeo_ParGenCurve.gxx deleted file mode 100644 index 46936c6672..0000000000 --- a/src/GccGeo/GccGeo_ParGenCurve.gxx +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 1995-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 - -GccGeo_ParGenCurve:: - GccGeo_ParGenCurve () { - Dep = 0.; -} - -GccGeo_ParGenCurve:: - GccGeo_ParGenCurve (const TheCurve& C , - const Standard_Real D ) { - Cu = C; - Dep = D; - } - - -Standard_Real GccGeo_ParGenCurve::GetResolution() { - return Cu.GetResolution(); -} - -Standard_Integer GccGeo_ParGenCurve::GetIntervals() { - return Cu.GetIntervals(); -} - -gp_Pnt2d -GccGeo_ParGenCurve::Value (const Standard_Real U) { - - gp_Pnt2d P; - gp_Vec2d V; - Standard_Real NorTan; - if (deport!=0.) { - Cu.D1(U,P,V); - NorTan= V.Magnitude(); - V.SetCoord(V.Y(),-V.X()); - if (NorTan >= gp::Resolution()) { - return gp_Pnt2d(P.XY()+deport*V.XY()/NorTan); - } - else { - gp_VectorWithNullMagnitude::Raise(); - } - } - else { - return Cu.Value(U); - } -} - -void GccGeo_ParGenCurve::D1(const Standard_Real U, - gp_Pnt2d& P, - gp_Vec2d& T) { - gp_Vec2d V1,V2,V3; - gp_Pnt2d PP; - Standard_Real Nor1,Alfa; - Standard_Integer Index,firstKnot,lastKnot; - if (deport != 0.) { - Cu.D2(U,PP,V1,V2); - Nor1= V1.Magnitude(); - V3.SetCoord(V1.Y(),-V1.X()); - V2.SetCoord(V2.Y(),-V2.X()); - if (Nor1 >= gp::Resolution()) { - P = gp_Pnt2d(PP.XY()+deport*V3.XY()/Nor1); - Alfa = V1.XY()/Nor1*V2.XY()/Nor1; - T = gp_Vec2d( V1.XY() + (deport/Nor1)*(V2.XY()-Alfa*V3.XY())); - } - else { - gp_VectorWithNullMagnitude::Raise(); - } - } - else { - Cu.D1(U,P,T); - } -} - -void GccGeo_ParGenCurve::D2(const Standard_Real U, - gp_Pnt2d& P, - gp_Vec2d& T, - gp_Vec2d& N) { - gp_Pnt2d PP; - gp_Vec2d V11,V22,V1t,V2t,V33; - Standard_Real Nor1,Alfa,Dalfa; - Standard_Integer Index,firstKnot,lastKnot; - if (deport!=0.) { - Cu.D3(U,PP,V11,V22,V33); - Nor1= V1.Magnitude(); - V1t.SetCoord(V11.Y(),-V11.X()); - V2t.SetCoord(V22.Y(),-V22.X()); - V33.SetCoord(V33.Y(),-V33.X()); - if (Nor1 >= gp::Resolution()) { - P = gp_Pnt2d(PP.XY()+deport*V1t.XY()/Nor1); - Alfa = V1t.XY()/Nor1*V2t.XY()/Nor1; - Dalfa= (V2t.XY()/Nor1*V2t.XY()/Nor1)+ - (V1t.XY()/Nor1*V33.XY()/Nor1)- - 2.*Alfa*Alfa; - T = gp_Vec2d( V11.XY() + (deport/Nor1)*(V2t.XY()-Alfa*V1t.XY())); - N = gp_Vec2d( V22.XY() + (deport/Nor1)*(V33.XY()-2.*Alfa*V2t.XY()- - (Dalfa-Alfa*Alfa)*V1t.XY())); - } - else { - gp_VectorWithNullMagnitude::Raise(); - } - } - else { - Cu.D2(U,P,T,N); - } -} - diff --git a/src/Geom2dGcc/Geom2dGcc.cdl b/src/Geom2dGcc/Geom2dGcc.cdl index be1eb831ec..b8dae287a9 100644 --- a/src/Geom2dGcc/Geom2dGcc.cdl +++ b/src/Geom2dGcc/Geom2dGcc.cdl @@ -32,12 +32,12 @@ package Geom2dGcc uses GccEnt, - GccGeo, GccAna, GccIter, StdFail, Geom2dInt, Geom2d, + GeomAbs, TColStd, Standard, Geom2dAdaptor, @@ -69,62 +69,32 @@ class Lin2dTanObl; class QCurve; -class MyCurveTool instantiates CurvePGTool from GccGeo - (Curve from Geom2dAdaptor, - CurveTool from Geom2dGcc, - OffsetCurve from Adaptor3d); - -class MyCirc2d2TanOn instantiates Circ2d2TanOn from GccGeo - (Curve from Geom2dAdaptor, - CurveTool from Geom2dGcc, - QCurve from Geom2dGcc, - OffsetCurve from Adaptor3d, - HCurve from Geom2dAdaptor, - MyCurveTool from Geom2dGcc, - TheIntConicCurveOfGInter from Geom2dInt); - -class MyCirc2d2TanRad instantiates Circ2d2TanRad from GccGeo - (Curve from Geom2dAdaptor, - CurveTool from Geom2dGcc, - QCurve from Geom2dGcc, - OffsetCurve from Adaptor3d, - HCurve from Geom2dAdaptor, - MyCurveTool from Geom2dGcc, - TheIntConicCurveOfGInter from Geom2dInt, - GInter from Geom2dInt); - -class MyCirc2dTanOnRad instantiates Circ2dTanOnRad from GccGeo - (Curve from Geom2dAdaptor , - CurveTool from Geom2dGcc, - QCurve from Geom2dGcc, - OffsetCurve from Adaptor3d, - HCurve from Geom2dAdaptor, - MyCurveTool from Geom2dGcc, - TheIntConicCurveOfGInter from Geom2dInt, - GInter from Geom2dInt); +class CurveToolGeo; -class MyC2d3Tan instantiates Circ2d3Tan from GccIter - (Curve from Geom2dAdaptor, - CurveTool from Geom2dGcc, - QCurve from Geom2dGcc); - -class MyCirc2dTanCen instantiates Circ2dTanCen from GccGeo - (Curve from Geom2dAdaptor, - CurveTool from Geom2dGcc, - ExtPC2d from Extrema, - QCurve from Geom2dGcc); +class Circ2d2TanOnGeo; + +class Circ2d2TanRadGeo; + +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); + (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 MyL2d2Tan instantiates Lin2d2Tan from GccIter (Curve from Geom2dAdaptor, CurveTool from Geom2dGcc, QCurve from Geom2dGcc); diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cdl index 1d52a69211..e2778ff887 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cdl @@ -42,7 +42,7 @@ uses Curve from Geom2dAdaptor, Point from Geom2d, Circ2d from gp, Circ2d2TanOn from GccAna, - MyCirc2d2TanOn from Geom2dGcc, + Circ2d2TanOnGeo from Geom2dGcc, MyC2d2TanOn from Geom2dGcc, Position from GccEnt, Array1OfPosition from GccEnt @@ -100,7 +100,7 @@ Results(me : in out ; is static; Results(me : in out ; - Circ : MyCirc2d2TanOn from Geom2dGcc) + Circ : Circ2d2TanOnGeo from Geom2dGcc) is static; IsDone(me) returns Boolean @@ -284,7 +284,7 @@ fields Invert : Boolean from Standard; -- CircAna : Circ2d2TanOn from GccAna; --- CircGeo : MyCirc2d2TanOn from Geom2dGcc; +-- CircGeo : Circ2d2TanOnGeo from Geom2dGcc; -- CircIter : MyC2d2TanOn from Geom2dGcc; -- TypeAna : Boolean; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cxx index 6ae5cdcdf4..54e6bdf35e 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cxx @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -210,7 +210,7 @@ Geom2dGcc_Circ2d2TanOn:: gp_Circ2d c2(CCC2->Circ2d()); GccEnt_QualifiedCirc Qc2 = GccEnt_QualifiedCirc(c2,Qualified2.Qualifier()); - Geom2dGcc_MyCirc2d2TanOn CircGeo(Qc1,Qc2,OnCurve,Tolerance); + Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc1,Qc2,OnCurve,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -223,7 +223,7 @@ Geom2dGcc_Circ2d2TanOn:: gp_Lin2d l2(LL2->Lin2d()); GccEnt_QualifiedLin Ql2 = GccEnt_QualifiedLin(l2,Qualified2.Qualifier()); - Geom2dGcc_MyCirc2d2TanOn CircGeo(Qc1,Ql2,OnCurve,Tolerance); + Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc1,Ql2,OnCurve,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -242,7 +242,7 @@ Geom2dGcc_Circ2d2TanOn:: gp_Circ2d c2(CCC2->Circ2d()); GccEnt_QualifiedCirc Qc2 = GccEnt_QualifiedCirc(c2,Qualified2.Qualifier()); - Geom2dGcc_MyCirc2d2TanOn CircGeo(Qc2,Ql1,OnCurve,Tolerance); + Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc2,Ql1,OnCurve,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -256,7 +256,7 @@ Geom2dGcc_Circ2d2TanOn:: gp_Lin2d l2(LL2->Lin2d()); GccEnt_QualifiedLin Ql2 = GccEnt_QualifiedLin(l2,Qualified2.Qualifier()); - Geom2dGcc_MyCirc2d2TanOn CircGeo(Ql1,Ql2,OnCurve,Tolerance); + Geom2dGcc_Circ2d2TanOnGeo CircGeo(Ql1,Ql2,OnCurve,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -417,7 +417,7 @@ Geom2dGcc_Circ2d2TanOn:: Handle(Geom2d_Circle) CCC1 = Handle(Geom2d_Circle)::DownCast(CC1); gp_Circ2d c1(CCC1->Circ2d()); GccEnt_QualifiedCirc Qc1(c1,Qualified1.Qualifier()); - Geom2dGcc_MyCirc2d2TanOn CircGeo(Qc1,Point->Pnt2d(),OnCurve,Tolerance); + Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc1,Point->Pnt2d(),OnCurve,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -429,7 +429,7 @@ Geom2dGcc_Circ2d2TanOn:: Handle(Geom2d_Line) LLL1 = Handle(Geom2d_Line)::DownCast(CC1); gp_Lin2d l1(LLL1->Lin2d()); GccEnt_QualifiedLin Ql1(l1,Qualified1.Qualifier()); - Geom2dGcc_MyCirc2d2TanOn CircGeo(Ql1,Point->Pnt2d(),OnCurve,Tolerance); + Geom2dGcc_Circ2d2TanOnGeo CircGeo(Ql1,Point->Pnt2d(),OnCurve,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -550,7 +550,7 @@ Geom2dGcc_Circ2d2TanOn:: //============================================================================= else { - Geom2dGcc_MyCirc2d2TanOn CircGeo(Point1->Pnt2d(),Point2->Pnt2d(), + Geom2dGcc_Circ2d2TanOnGeo CircGeo(Point1->Pnt2d(),Point2->Pnt2d(), OnCurve,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); @@ -576,7 +576,7 @@ void Geom2dGcc_Circ2d2TanOn::Results(const GccAna_Circ2d2TanOn& Circ) } } -void Geom2dGcc_Circ2d2TanOn::Results(const Geom2dGcc_MyCirc2d2TanOn& Circ) +void Geom2dGcc_Circ2d2TanOn::Results(const Geom2dGcc_Circ2d2TanOnGeo& Circ) { for (Standard_Integer j = 1; j <= NbrSol; j++) { cirsol(j) = Circ.ThisSolution(j); diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cdl new file mode 100644 index 0000000000..6e8209525e --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cdl @@ -0,0 +1,293 @@ +-- 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 Circ2d2TanOnGeo from Geom2dGcc + + ---Purpose: This class implements the algorithms used to + -- create 2d circles TANgent to 2 entities and + -- having the center ON a curve. + -- The order of the tangency argument is always + -- QualifiedCirc, QualifiedLin, QualifiedCurv, Pnt2d. + -- the arguments are : + -- - The two tangency arguments (lines, circles or points). + -- - The center line (a curve). + -- - 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, + Array1OfCirc2d from TColgp, + Array1OfPnt2d from TColgp, + Array1OfInteger from TColStd, + Array1OfReal from TColStd, + Position from GccEnt, + Array1OfPosition from GccEnt, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + QCurve from Geom2dGcc, + OffsetCurve from Adaptor3d, + HCurve from Geom2dAdaptor, + CurveToolGeo from Geom2dGcc, + TheIntConicCurveOfGInter from Geom2dInt + +raises NotDone from StdFail, + BadQualifier from GccEnt, + OutOfRange from Standard + +is + +Create(Qualified1 : QualifiedCirc from GccEnt ; + Qualified2 : QualifiedCirc from GccEnt ; + OnCurv : Curve from Geom2dAdaptor ; + Tolerance : Real from Standard) returns Circ2d2TanOnGeo + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to two 2d circles and + -- having the center ON a curve. +raises BadQualifier from GccEnt; + +Create(Qualified1 : QualifiedCirc from GccEnt ; + Qualified2 : QualifiedLin from GccEnt ; + OnCurv : Curve from Geom2dAdaptor ; + Tolerance : Real from Standard) returns Circ2d2TanOnGeo + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d circle and a 2d line + -- having the center ON a curve. +raises BadQualifier from GccEnt; + +Create(Qualified1 : QualifiedCirc from GccEnt ; + Point2 : Pnt2d from gp ; + OnCurv : Curve from Geom2dAdaptor ; + Tolerance : Real from Standard) returns Circ2d2TanOnGeo + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d circle and a point + -- having the center ON a curve. +raises BadQualifier from GccEnt; + +Create(Qualified1 : QualifiedLin from GccEnt ; + Qualified2 : QualifiedLin from GccEnt ; + OnCurv : Curve from Geom2dAdaptor ; + Tolerance : Real from Standard) returns Circ2d2TanOnGeo + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to two 2d lines + -- having the center ON a curve. +raises BadQualifier from GccEnt; + +Create(Qualified1 : QualifiedLin from GccEnt ; + Qualified2 : Pnt2d from gp ; + OnCurv : Curve from Geom2dAdaptor ; + Tolerance : Real from Standard) returns Circ2d2TanOnGeo + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d line and a point + -- having the center ON a 2d line. +raises BadQualifier from GccEnt; + +Create(Point1 : Pnt2d from gp ; + Point2 : Pnt2d from gp ; + OnCurv : Curve from Geom2dAdaptor ; + Tolerance : Real from Standard) returns Circ2d2TanOnGeo ; + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to two points + -- having the center ON a 2d line. + +-- .................................................................... + +IsDone(me) returns Boolean from Standard +is static; + ---Purpose: This method returns True if the construction + -- algorithm succeeded. + +NbSolutions(me) returns Integer from Standard + ---Purpose: This method returns the number of solutions. +raises NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +ThisSolution(me ; Index : Integer) returns Circ2d from gp + ---Purpose: Returns the solution number Index and raises OutOfRange + -- exception if Index is greater than the number of solutions. + -- Be careful: the Index is only a way to get all the + -- solutions, but is not associated to those outside the + -- context of the algorithm-object. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions. + +WhichQualifier(me ; + Index : Integer from Standard; + Qualif1 : out Position from GccEnt ; + Qualif2 : out Position from GccEnt ) +raises OutOfRange, NotDone +is static; + ---Purpose: 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 ; + Index : Integer from Standard; + ParSol,ParArg : out Real from Standard; + PntSol : out Pnt2d from gp ) + ---Purpose: Returns informations about the tangency point between the + -- result number Index and the first argument. + -- ParSol is the intrinsic parameter of the point on the + -- solution curv. + -- ParArg is the intrinsic parameter of the point on the + -- argument curv. + -- PntSol is the tangency point on the solution curv. + -- PntArg is the tangency point on the argument curv. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions. + +Tangency2(me ; + Index : Integer from Standard; + ParSol,ParArg : out Real from Standard; + PntSol : out Pnt2d from gp ) + ---Purpose: Returns informations about the tangency point between the + -- result number Index and the second argument. + -- ParSol is the intrinsic parameter of the point on the + -- solution curv. + -- ParArg is the intrinsic parameter of the point on the + -- argument curv. + -- PntSol is the tangency point on the solution curv. + -- PntArg is the tangency point on the argument curv. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions. + +CenterOn3 (me ; + Index : Integer from Standard; + ParArg : out Real from Standard; + PntSol : out Pnt2d from gp ) + ---Purpose: Returns informations about the center (on the curv) + -- of the result. + -- ParArg is the intrinsic parameter of the point on + -- the argument curv. + -- PntSol is the center point of the solution curv. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions. + +IsTheSame1(me ; + Index : Integer from Standard) returns Boolean from Standard + ---Purpose: Returns True if the solution number Index is equal to + -- the first argument and False in the other cases. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions. + +IsTheSame2(me ; + Index : Integer from Standard) returns Boolean from Standard + ---Purpose: Returns True if the solution number Index is equal to + -- the second argument and False in the other cases. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions. + +fields + + WellDone : Boolean from Standard; + ---Purpose: True if the algorithm succeeded. + + NbrSol : Integer from Standard; + ---Purpose: Number of solutions. + + cirsol : Array1OfCirc2d from TColgp; + ---Purpose: The solutions. + + qualifier1 : Array1OfPosition from GccEnt; + ---Purpose: The qualifiers of the first argument. + + qualifier2 : Array1OfPosition from GccEnt; + ---Purpose: The qualifiers of the second argument. + + TheSame1 : Array1OfInteger from TColStd; + ---Purpose: 1 if the solution and the first argument are the same + -- (2 circles). + -- If R1 is the radius of the first argument and Rsol the radius + -- of the solution and dist the distance between the two centers, + -- we consider the two circles are identical if R1+dist-Rsol is + -- less than Tolerance. + -- 0 in the other cases. + + TheSame2 : Array1OfInteger from TColStd; + ---Purpose: 1 if the solution and the second argument are the same + -- (2 circles). + -- If R2 is the radius of the second argument and Rsol the radius + -- of the solution and dist the distance between the two centers, + -- we consider the two circles are identical if R2+dist-Rsol is + -- less than Tolerance. + -- 0 in the other cases. + + pnttg1sol : Array1OfPnt2d from TColgp; + ---Purpose: The tangency point between the solution and the first + -- argument on the solution. + + pnttg2sol : Array1OfPnt2d from TColgp; + ---Purpose: The tangency point between the solution and the second + -- argument on the solution. + + pntcen : Array1OfPnt2d from TColgp; + ---Purpose: The center point of the solution on the third argument. + + par1sol : Array1OfReal from TColStd; + ---Purpose: The parameter of the tangency point between the solution + -- and the first argument on the solution. + + par2sol : Array1OfReal from TColStd; + ---Purpose: The parameter of the tangency point between the solution + -- and the second argument on the solution. + + pararg1 : Array1OfReal from TColStd; + ---Purpose: The parameter of the tangency point between the solution + -- and the first argument on the first argument. + + pararg2 : Array1OfReal from TColStd; + ---Purpose: The parameter of the tangency point between the solution + -- and the second argument on the second argument. + + parcen3 : Array1OfReal from TColStd; + ---Purpose: The parameter of the center point of the solution on the + -- second argument. + +end Circ2d2TanOnGeo; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx new file mode 100644 index 0000000000..902abd3416 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx @@ -0,0 +1,1074 @@ +// 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 + +#include +#include +#include +#include + +Geom2dGcc_Circ2d2TanOnGeo:: +Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedCirc& Qualified1 , + const GccEnt_QualifiedCirc& Qualified2 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Tolerance ): + cirsol(1,8) , + qualifier1(1,8), + qualifier2(1,8), + TheSame1(1,8) , + TheSame2(1,8) , + pnttg1sol(1,8) , + pnttg2sol(1,8) , + pntcen(1,8) , + par1sol(1,8) , + par2sol(1,8) , + pararg1(1,8) , + pararg2(1,8) , + parcen3(1,8) +{ + WellDone = Standard_False; + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + Standard_Real Tol = Abs(Tolerance); + NbrSol = 0; + TColStd_Array1OfReal Rbid(1,2); + TColStd_Array1OfReal RBid(1,2); + TColStd_Array1OfReal Radius(1,2); + 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(); + gp_Circ2d C2 = Qualified2.Qualified(); + Standard_Real R1 = C1.Radius(); + Standard_Real R2 = C2.Radius(); + gp_Dir2d dirx(1.,0.); + gp_Pnt2d center1(C1.Location()); + gp_Pnt2d center2(C2.Location()); + GccAna_Circ2dBisec Bis(C1,C2); + if (Bis.IsDone()) { + Geom2dInt_TheIntConicCurveOfGInter Intp; + Standard_Integer nbsolution = Bis.NbSolutions(); + Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(OnCurv); + Adaptor3d_OffsetCurve Cu2(HCu2,0.); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(Cu2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(Cu2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(Cu2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(Cu2,lastparam),lastparam,Tol); + Standard_Real Tol1 = Abs(Tolerance); + Standard_Real Tol2 = Tol1; + for (Standard_Integer i = 1 ; i <= nbsolution; i++) { + Handle(GccInt_Bisec) Sol = Bis.ThisSolution(i); + GccInt_IType type = Sol->ArcType(); + switch (type) { + case GccInt_Cir: + { + gp_Circ2d Circ(Sol->Circle()); + IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol1, + ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol2); + D1.SetEquivalentParameters(0.,2.*M_PI); + Intp.Perform(Circ,D1,Cu2,D2,Tol1,Tol2); + } + break; + case GccInt_Ell: + { + gp_Elips2d Elips(Sol->Ellipse()); + IntRes2d_Domain D1(ElCLib::Value(0.,Elips), 0.,Tol1, + ElCLib::Value(2.*M_PI,Elips),2.*M_PI,Tol2); + D1.SetEquivalentParameters(0.,2.*M_PI); + Intp.Perform(Elips,D1,Cu2,D2,Tol1,Tol2); + } + break; + case GccInt_Hpr: + { + gp_Hypr2d Hypr(Sol->Hyperbola()); + IntRes2d_Domain D1(ElCLib::Value(-4.,Hypr),-4.,Tol1, + ElCLib::Value(4.,Hypr),4.,Tol2); + Intp.Perform(Hypr,D1,Cu2,D2,Tol1,Tol2); + } + break; + case GccInt_Lin: + { + gp_Lin2d Line(Sol->Line()); + IntRes2d_Domain D1; + Intp.Perform(Line,D1,Cu2,D2,Tol1,Tol2); + } + break; + default: + { + Standard_ConstructionError::Raise(); + } + } + if (Intp.IsDone()) { + if ((!Intp.IsEmpty())) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + gp_Pnt2d Center(Intp.Point(j).Value()); + Standard_Real dist1 = Center.Distance(C1.Location()); + Standard_Real dist2 = Center.Distance(C2.Location()); + Standard_Integer nbsol = 0; + Standard_Integer nnsol = 0; + R1 = C1.Radius(); + R2 = C2.Radius(); + if (Qualified1.IsEnclosed()) { + if (dist1-R1 < Tol) { + nbsol = 1; + Rbid(1) = Abs(R1-dist1); + } + } + else if (Qualified1.IsOutside()) { + if (R1-dist1 < Tol) { + nbsol = 1; + Rbid(1) = Abs(dist1-R1); + } + } + else if (Qualified1.IsEnclosing()) { + nbsol = 1; + Rbid(1) = dist1+R1; + } + else if (Qualified1.IsUnqualified()) { + nbsol = 2; + Rbid(1) = dist1+R1; + Rbid(1) = Abs(dist1-R1); + } + if (Qualified2.IsEnclosed() && nbsol != 0) { + if (dist2-R2 < Tol) { + RBid(1) = Abs(R2-dist2); + } + } + else if (Qualified2.IsOutside() && nbsol != 0) { + if (R2-dist2 < Tol) { + RBid(1) = Abs(R2-dist2); + } + } + else if (Qualified2.IsEnclosing() && nbsol != 0) { + RBid(1) = dist2+R2; + } + else if (Qualified2.IsUnqualified() && nbsol != 0) { + RBid(1) = dist2+R2; + RBid(2) = Abs(R2-dist2); + } + for (Standard_Integer isol = 1; isol <= nbsol ; isol++) { + for (Standard_Integer jsol = 1; jsol <= nbsol ; jsol++) { + if (Abs(Rbid(isol)-RBid(jsol)) <= Tol) { + nnsol++; + Radius(nnsol) = (RBid(jsol)+Rbid(isol))/2.; + } + } + } + if (nnsol > 0) { + for (Standard_Integer k = 1 ; k <= nnsol ; k++) { + NbrSol++; + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius(k)); + // ========================================================== + Standard_Real distcc1 = Center.Distance(center1); + Standard_Real distcc2 = Center.Distance(center2); + if (!Qualified1.IsUnqualified()) { + qualifier1(NbrSol) = Qualified1.Qualifier(); + } + else if (Abs(distcc1+Radius(i)-R1) < Tol) { + qualifier1(NbrSol) = GccEnt_enclosed; + } + else if (Abs(distcc1-R1-Radius(i)) < Tol) { + qualifier1(NbrSol) = GccEnt_outside; + } + else { qualifier1(NbrSol) = GccEnt_enclosing; } + if (!Qualified2.IsUnqualified()) { + qualifier2(NbrSol) = Qualified2.Qualifier(); + } + else if (Abs(distcc2+Radius(i)-R2) < Tol) { + qualifier2(NbrSol) = GccEnt_enclosed; + } + else if (Abs(distcc2-R2-Radius(i)) < Tol) { + qualifier2(NbrSol) = GccEnt_outside; + } + else { qualifier2(NbrSol) = GccEnt_enclosing; } + if (dist1 <= Tol && Abs(Radius(k)-C1.Radius()) <= Tol) { + TheSame1(NbrSol) = 1; + } + else { + TheSame1(NbrSol) = 0; + gp_Dir2d dc1(C1.Location().XY()-Center.XY()); + pnttg1sol(NbrSol)=gp_Pnt2d(Center.XY()+Radius(k)*dc1.XY()); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pararg1(NbrSol)=ElCLib::Parameter(C1,pnttg1sol(NbrSol)); + } + if (dist2 <= Tol && Abs(Radius(k)-C2.Radius()) <= Tol) { + TheSame2(NbrSol) = 1; + } + else { + TheSame2(NbrSol) = 0; + gp_Dir2d dc2(C2.Location().XY()-Center.XY()); + pnttg2sol(NbrSol)=gp_Pnt2d(Center.XY()+Radius(k)*dc2.XY()); + par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg2sol(NbrSol)); + pararg2(NbrSol)=ElCLib::Parameter(C2,pnttg2sol(NbrSol)); + } + pntcen(NbrSol) = Center; + parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); + } + WellDone = Standard_True; + } + } + } + } + } + } +} + +//========================================================================= +// Creation d un cercle tangent a un Cercle C1 et a une Droite L2. + +// centre sur une courbe OnCurv. + +// Nous calculons les bissectrices a C1 et L2 qui nous donnent + +// l ensemble des lieux possibles des centres de tous les cercles + +// tangents a C1 et L2. + +// Nous intersectons ces bissectrices avec la courbe OnCurv ce qui nous + +// donne les points parmis lesquels nous allons choisir les solutions. + +// Les choix s effectuent a partir des Qualifieurs qualifiant C1 et L2. + +//========================================================================= + +Geom2dGcc_Circ2d2TanOnGeo:: +Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedCirc& Qualified1 , + const GccEnt_QualifiedLin& Qualified2 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Tolerance ): +cirsol(1,8) , +qualifier1(1,8), +qualifier2(1,8), +TheSame1(1,8) , +TheSame2(1,8) , +pnttg1sol(1,8) , +pnttg2sol(1,8) , +pntcen(1,8) , +par1sol(1,8) , +par2sol(1,8) , +pararg1(1,8) , +pararg2(1,8) , +parcen3(1,8) +{ + + WellDone = Standard_False; + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + NbrSol = 0; + Standard_Real Tol = Abs(Tolerance); + Standard_Real Radius; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Dir2d dirx(1.,0.); + gp_Circ2d C1 = Qualified1.Qualified(); + gp_Lin2d L2 = Qualified2.Qualified(); + Standard_Real R1 = C1.Radius(); + gp_Pnt2d center1(C1.Location()); + gp_Pnt2d origin2(L2.Location()); + gp_Dir2d dir2(L2.Direction()); + gp_Dir2d normL2(-dir2.Y(),dir2.X()); + + GccAna_CircLin2dBisec Bis(C1,L2); + if (Bis.IsDone()) { + Standard_Real Tol1 = Abs(Tolerance); + Standard_Real Tol2 = Tol1; + Geom2dInt_TheIntConicCurveOfGInter Intp; + Standard_Integer nbsolution = Bis.NbSolutions(); + Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(OnCurv); + Adaptor3d_OffsetCurve C2(HCu2,0.); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); + for (Standard_Integer i = 1 ; i <= nbsolution; i++) { + Handle(GccInt_Bisec) Sol = Bis.ThisSolution(i); + GccInt_IType type = Sol->ArcType(); + switch (type) { + case GccInt_Lin: + { + gp_Lin2d Line(Sol->Line()); + IntRes2d_Domain D1; + Intp.Perform(Line,D1,C2,D2,Tol1,Tol2); + } + break; + case GccInt_Par: + { + gp_Parab2d Parab(Sol->Parabola()); + IntRes2d_Domain D1(ElCLib::Value(-40,Parab),-40,Tol1, + ElCLib::Value(40,Parab),40,Tol1); + Intp.Perform(Parab,D1,C2,D2,Tol1,Tol2); + } + break; + default: + { + Standard_ConstructionError::Raise(); + } + } + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + gp_Pnt2d Center(Intp.Point(j).Value()); + Standard_Real dist1 = Center.Distance(center1); + // Standard_Integer nbsol = 1; + Standard_Boolean ok = Standard_False; + if (Qualified1.IsEnclosed()) { + if (dist1-R1 < Tol) { ok = Standard_True; } + } + else if (Qualified1.IsOutside()) { + if (R1-dist1 < Tol) { ok = Standard_True; } + } + else if (Qualified1.IsEnclosing() || Qualified1.IsUnqualified()) { + ok = Standard_True; + } + Radius = L2.Distance(Center); + if (Qualified2.IsEnclosed() && ok) { + ok = Standard_False; + if ((((origin2.X()-Center.X())*(-dir2.Y()))+ + ((origin2.Y()-Center.Y())*(dir2.X())))<=0){ + ok = Standard_True; + } + } + else if (Qualified2.IsOutside() && ok) { + ok = Standard_False; + if ((((origin2.X()-Center.X())*(-dir2.Y()))+ + ((origin2.Y()-Center.Y())*(dir2.X())))>=0){ + ok = Standard_True; + } + } + if (Qualified1.IsEnclosing()&&dist1>Radius) { ok=Standard_False; } + if (ok) { + NbrSol++; + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= +#ifdef DEB + gp_Dir2d dc1(center1.XY()-Center.XY()); +#endif + gp_Dir2d dc2(origin2.XY()-Center.XY()); + Standard_Real distcc1 = Center.Distance(center1); + if (!Qualified1.IsUnqualified()) { + qualifier1(NbrSol) = Qualified1.Qualifier(); + } + else if (Abs(distcc1+Radius-R1) < Tol) { + qualifier1(NbrSol) = GccEnt_enclosed; + } + else if (Abs(distcc1-R1-Radius) < Tol) { + qualifier1(NbrSol) = GccEnt_outside; + } + else { qualifier1(NbrSol) = GccEnt_enclosing; } + if (!Qualified2.IsUnqualified()) { + qualifier2(NbrSol) = Qualified2.Qualifier(); + } + else if (dc2.Dot(normL2) > 0.0) { + qualifier2(NbrSol) = GccEnt_outside; + } + else { qualifier2(NbrSol) = GccEnt_enclosed; } + if (dist1 <= Tol && Abs(Radius-C1.Radius()) <= Tol) { + TheSame1(NbrSol) = 1; + } + else { + TheSame1(NbrSol) = 0; + gp_Dir2d dc1(center1.XY()-Center.XY()); + pnttg1sol(NbrSol)=gp_Pnt2d(Center.XY()+Radius*dc1.XY()); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pararg1(NbrSol)=ElCLib::Parameter(C1,pnttg1sol(NbrSol)); + } + TheSame2(NbrSol) = 0; + Standard_Real sign = dc2.Dot(gp_Dir2d(-dir2.Y(),dir2.X())); + dc2 = gp_Dir2d(sign*gp_XY(-dir2.Y(),dir2.X())); + pnttg2sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc2.XY()); + par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg2sol(NbrSol)); + pararg2(NbrSol)=ElCLib::Parameter(L2,pnttg2sol(NbrSol)); + pntcen(NbrSol) = Center; + parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); + } + } + } + WellDone = Standard_True; + } + } + } +} + +//========================================================================= +// Creation d un cercle tant a deux Droites L1 et L2. + +// centre sur une courbe OnCurv. + +// Nous calculons les bissectrices a L1 et L2 qui nous donnent + +// l ensemble des lieux possibles des centres de tous les cercles + +// tants a L1 et L2. + +// Nous intersectons ces bissectrices avec la courbe OnCurv ce qui nous + +// donne les points parmis lesquels nous allons choisir les solutions. + +// Les choix s effectuent a partir des Qualifieurs qualifiant L1 et L2. + +//========================================================================= + +Geom2dGcc_Circ2d2TanOnGeo:: +Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedLin& Qualified1 , + const GccEnt_QualifiedLin& Qualified2 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Tolerance ): +cirsol(1,8) , +qualifier1(1,8), +qualifier2(1,8), +TheSame1(1,8) , +TheSame2(1,8) , +pnttg1sol(1,8) , +pnttg2sol(1,8) , +pntcen(1,8) , +par1sol(1,8) , +par2sol(1,8) , +pararg1(1,8) , +pararg2(1,8) , +parcen3(1,8) +{ + + WellDone = Standard_False; + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + NbrSol = 0; + if (!(Qualified1.IsEnclosed() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + Standard_Real Radius=0; + gp_Dir2d dirx(1.,0.); + gp_Lin2d L1 = Qualified1.Qualified(); + gp_Lin2d L2 = Qualified2.Qualified(); + gp_Dir2d dir1(L1.Direction()); + gp_Dir2d dir2(L2.Direction()); + gp_Dir2d Dnor1(-dir1.Y(),dir1.X()); + gp_Dir2d Dnor2(-dir2.Y(),dir2.X()); + gp_Pnt2d origin1(L1.Location()); + gp_Pnt2d origin2(L2.Location()); + GccAna_Lin2dBisec Bis(L1,L2); + if (Bis.IsDone()) { + Standard_Real Tol1 = Abs(Tolerance); + Standard_Real Tol2 = Tol1; + Geom2dInt_TheIntConicCurveOfGInter Intp; + Standard_Integer nbsolution = Bis.NbSolutions(); + Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(OnCurv); + Adaptor3d_OffsetCurve C2(HCu2,0.); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); + IntRes2d_Domain D1; + for (Standard_Integer i = 1 ; i <= nbsolution; i++) { + Intp.Perform(Bis.ThisSolution(i),D1,C2,D2,Tol1,Tol2); + if (Intp.IsDone()) { + if ((!Intp.IsEmpty())) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + gp_Pnt2d Center(Intp.Point(j).Value()); + Standard_Real dist1 = L1.Distance(Center); + Standard_Real dist2 = L2.Distance(Center); + // Standard_Integer nbsol = 1; + Standard_Boolean ok = Standard_False; + if (Qualified1.IsEnclosed()) { + if ((((origin1.X()-Center.X())*(-dir1.Y()))+ + ((origin1.Y()-Center.Y())*(dir1.X())))<=0){ + ok = Standard_True; + } + } + else if (Qualified1.IsOutside()) { + if ((((origin1.X()-Center.X())*(-dir1.Y()))+ + ((origin1.Y()-Center.Y())*(dir1.X())))>=0){ + ok = Standard_True; + } + } + else if (Qualified1.IsUnqualified()) { ok = Standard_True; } + if (Qualified2.IsEnclosed() && ok) { + ok = Standard_False; + if ((((origin2.X()-Center.X())*(-dir2.Y()))+ + ((origin2.Y()-Center.Y())*(dir2.X())))<=0){ + ok = Standard_True; + Radius = (dist1+dist2)/2.; + } + } + else if (Qualified2.IsOutside() && ok) { + ok = Standard_False; + if ((((origin2.X()-Center.X())*(-dir2.Y()))+ + ((origin2.Y()-Center.Y())*(dir2.X())))>=0){ + ok = Standard_True; + Radius = (dist1+dist2)/2.; + } + } + else if (Qualified2.IsUnqualified() && ok) { + Radius = (dist1+dist2)/2.; + } + if (ok) { + NbrSol++; + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + gp_Dir2d dc1(origin1.XY()-Center.XY()); + gp_Dir2d dc2(origin2.XY()-Center.XY()); + if (!Qualified1.IsUnqualified()) { + qualifier1(NbrSol) = Qualified1.Qualifier(); + } + else if (dc1.Dot(Dnor1) > 0.0) { + qualifier1(NbrSol) = GccEnt_outside; + } + else { qualifier1(NbrSol) = GccEnt_enclosed; } + if (!Qualified2.IsUnqualified()) { + qualifier2(NbrSol) = Qualified2.Qualifier(); + } + else if (dc2.Dot(Dnor2) > 0.0) { + qualifier2(NbrSol) = GccEnt_outside; + } + else { qualifier2(NbrSol) = GccEnt_enclosed; } + TheSame1(NbrSol) = 0; + TheSame2(NbrSol) = 0; + Standard_Real sign = dc1.Dot(Dnor1); + dc1 = gp_Dir2d(sign*gp_XY(-dir1.Y(),dir1.X())); + pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc1.XY()); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pararg1(NbrSol)=ElCLib::Parameter(L1,pnttg1sol(NbrSol)); + sign = dc2.Dot(gp_Dir2d(-dir2.Y(),dir2.X())); + dc2 = gp_Dir2d(sign*gp_XY(-dir2.Y(),dir2.X())); + pnttg2sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc2.XY()); + par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg2sol(NbrSol)); + pararg2(NbrSol)=ElCLib::Parameter(L2,pnttg2sol(NbrSol)); + pntcen(NbrSol) = Center; + parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); + } + } + } + WellDone = Standard_True; + } + } + } +} + +//========================================================================= +// Creation d un cercle tant a un Cercle C1, passant par un point P2 + +// centre sur une courbe OnCurv. + +// Nous calculons les bissectrices a C1 et Point2 qui nous donnent + +// l ensemble des lieux possibles des centres de tous les cercles + +// tants a C1 et Point2. + +// Nous intersectons ces bissectrices avec la courbe OnCurv ce qui nous + +// donne les points parmis lesquels nous allons choisir les solutions. + +// Les choix s effectuent a partir des Qualifieurs qualifiant C1. + +//========================================================================= + +Geom2dGcc_Circ2d2TanOnGeo:: +Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedCirc& Qualified1 , + const gp_Pnt2d& Point2 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Tolerance ): +cirsol(1,8) , +qualifier1(1,8), +qualifier2(1,8), +TheSame1(1,8) , +TheSame2(1,8) , +pnttg1sol(1,8) , +pnttg2sol(1,8) , +pntcen(1,8) , +par1sol(1,8) , +par2sol(1,8) , +pararg1(1,8) , +pararg2(1,8) , +parcen3(1,8) +{ + + WellDone = Standard_False; + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + NbrSol = 0; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Real Tol = Abs(Tolerance); + Standard_Real Radius; + gp_Dir2d dirx(1.,0.); + gp_Circ2d C1 = Qualified1.Qualified(); + Standard_Real R1 = C1.Radius(); + gp_Pnt2d center1(C1.Location()); + GccAna_CircPnt2dBisec Bis(C1,Point2); + if (Bis.IsDone()) { + Standard_Real Tol1 = Abs(Tolerance); + Standard_Real Tol2 = Tol1; + Geom2dInt_TheIntConicCurveOfGInter Intp; + Standard_Integer nbsolution = Bis.NbSolutions(); + Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(OnCurv); + Adaptor3d_OffsetCurve C2(HCu2,0.); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); + for (Standard_Integer i = 1 ; i <= nbsolution; i++) { + Handle(GccInt_Bisec) Sol = Bis.ThisSolution(i); + GccInt_IType type = Sol->ArcType(); + switch (type) { + case GccInt_Cir: + { + gp_Circ2d Circ(Sol->Circle()); + IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol1, + ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol2); + D1.SetEquivalentParameters(0.,2.*M_PI); + Intp.Perform(Circ,D1,C2,D2,Tol1,Tol2); + } + break; + case GccInt_Lin: + { + gp_Lin2d Line(Sol->Line()); + IntRes2d_Domain D1; + Intp.Perform(Line,D1,C2,D2,Tol1,Tol2); + } + break; + case GccInt_Ell: + { + gp_Elips2d Elips(Sol->Ellipse()); + IntRes2d_Domain D1(ElCLib::Value(0.,Elips), 0.,Tol1, + ElCLib::Value(2.*M_PI,Elips),2.*M_PI,Tol2); + D1.SetEquivalentParameters(0.,2.*M_PI); + Intp.Perform(Elips,D1,C2,D2,Tol1,Tol2); + } + break; + case GccInt_Hpr: + { + gp_Hypr2d Hypr(Sol->Hyperbola()); + IntRes2d_Domain D1(ElCLib::Value(-4.,Hypr),-4.,Tol1, + ElCLib::Value(4.,Hypr),4.,Tol2); + Intp.Perform(Hypr,D1,C2,D2,Tol1,Tol2); + } + break; + default: + { + Standard_ConstructionError::Raise(); + } + } + if (Intp.IsDone()) { + if ((!Intp.IsEmpty())) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + gp_Pnt2d Center(Intp.Point(j).Value()); + Radius = Center.Distance(Point2); + Standard_Real dist1 = center1.Distance(Center); + // Standard_Integer nbsol = 1; + Standard_Boolean ok = Standard_False; + if (Qualified1.IsEnclosed()) { + if (dist1-R1 <= Tol) { ok = Standard_True; } + } + else if (Qualified1.IsOutside()) { + if (R1-dist1 <= Tol) { ok = Standard_True; } + } + else if (Qualified1.IsEnclosing()) { ok = Standard_True; } + else if (Qualified1.IsUnqualified()) { ok = Standard_True; } + if (ok) { + NbrSol++; + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + Standard_Real distcc1 = Center.Distance(center1); + if (!Qualified1.IsUnqualified()) { + qualifier1(NbrSol) = Qualified1.Qualifier(); + } + else if (Abs(distcc1+Radius-R1) < Tol) { + qualifier1(NbrSol) = GccEnt_enclosed; + } + else if (Abs(distcc1-R1-Radius) < Tol) { + qualifier1(NbrSol) = GccEnt_outside; + } + else { qualifier1(NbrSol) = GccEnt_enclosing; } + qualifier2(NbrSol) = GccEnt_noqualifier; + if (dist1 <= Tol && Abs(Radius-R1) <= Tol) { + TheSame1(NbrSol) = 1; + } + else { + TheSame1(NbrSol) = 0; + gp_Dir2d dc1(center1.XY()-Center.XY()); + pnttg1sol(NbrSol)=gp_Pnt2d(Center.XY()+Radius*dc1.XY()); + par1sol(NbrSol) = 0.; + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pararg1(NbrSol)=ElCLib::Parameter(C1,pnttg1sol(NbrSol)); + } + TheSame2(NbrSol) = 0; + pnttg2sol(NbrSol) = Point2; + pntcen(NbrSol) = Center; + parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); + pararg2(NbrSol) = 0.; + par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg2sol(NbrSol)); + } + } + } + WellDone = Standard_True; + } + } + } +} + +//========================================================================= +// Creation d un cercle tant a une ligne L1, passant par un point P2 + +// centre sur une courbe OnCurv. + +// Nous calculons les bissectrices a L1 et Point2 qui nous donnent + +// l ensemble des lieux possibles des centres de tous les cercles + +// tants a L1 et passant par Point2. + +// Nous intersectons ces bissectrices avec la courbe OnCurv ce qui nous + +// donne les points parmis lesquels nous allons choisir les solutions. + +// Les choix s effectuent a partir des Qualifieurs qualifiant L1. + +//========================================================================= + +Geom2dGcc_Circ2d2TanOnGeo:: +Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedLin& Qualified1 , + const gp_Pnt2d& Point2 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Tolerance ): +cirsol(1,8) , +qualifier1(1,8), +qualifier2(1,8), +TheSame1(1,8) , +TheSame2(1,8) , +pnttg1sol(1,8) , +pnttg2sol(1,8) , +pntcen(1,8) , +par1sol(1,8) , +par2sol(1,8) , +pararg1(1,8) , +pararg2(1,8) , +parcen3(1,8) +{ + + WellDone = Standard_False; + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + Standard_Real Tol = Abs(Tolerance); + NbrSol = 0; + if (!(Qualified1.IsEnclosed() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + gp_Dir2d dirx(1.,0.); + gp_Lin2d L1 = Qualified1.Qualified(); + gp_Pnt2d origin1(L1.Location()); + gp_Dir2d dir1(L1.Direction()); + gp_Dir2d normal(-dir1.Y(),dir1.X()); + GccAna_LinPnt2dBisec Bis(L1,Point2); + if (Bis.IsDone()) { + Standard_Real Tol1 = Abs(Tolerance); + Standard_Real Tol2 = Tol1; + Geom2dInt_TheIntConicCurveOfGInter Intp; + Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(OnCurv); + Adaptor3d_OffsetCurve C2(HCu2,0.); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); + Handle(GccInt_Bisec) Sol = Bis.ThisSolution(); + GccInt_IType type = Sol->ArcType(); + switch (type) { + case GccInt_Lin: + { + gp_Lin2d Line(Sol->Line()); + IntRes2d_Domain D1; + Intp.Perform(Line,D1,C2,D2,Tol1,Tol2); + } + break; + case GccInt_Par: + { + gp_Parab2d Parab(Sol->Parabola()); + IntRes2d_Domain D1(ElCLib::Value(-40,Parab),-40,Tol1, + ElCLib::Value(40,Parab),40,Tol1); + Intp.Perform(Parab,D1,C2,D2,Tol1,Tol2); + } + break; + default: + { + Standard_ConstructionError::Raise(); + } + } + if (Intp.IsDone()) { + if ((!Intp.IsEmpty())) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + gp_Pnt2d Center(Intp.Point(j).Value()); + Standard_Real Radius = L1.Distance(Center); + // Standard_Integer nbsol = 1; + Standard_Boolean ok = Standard_False; + if (Qualified1.IsEnclosed()) { + if ((((origin1.X()-Center.X())*(-dir1.Y()))+ + ((origin1.Y()-Center.Y())*(dir1.X())))<=0){ + ok = Standard_True; + } + } + else if (Qualified1.IsOutside()) { + if ((((origin1.X()-Center.X())*(-dir1.Y()))+ + ((origin1.Y()-Center.Y())*(dir1.X())))>=0){ + ok = Standard_True; + } + } + else if (Qualified1.IsUnqualified()) { ok = Standard_True; } + if (ok) { + NbrSol++; + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + qualifier2(NbrSol) = GccEnt_noqualifier; + gp_Dir2d dc2(origin1.XY()-Center.XY()); + if (!Qualified1.IsUnqualified()) { + qualifier1(NbrSol) = Qualified1.Qualifier(); + } + else if (dc2.Dot(normal) > 0.0) { + qualifier1(NbrSol) = GccEnt_outside; + } + else { qualifier1(NbrSol) = GccEnt_enclosed; } + TheSame1(NbrSol) = 0; + TheSame2(NbrSol) = 0; + gp_Dir2d dc1(origin1.XY()-Center.XY()); + Standard_Real sign = dc1.Dot(gp_Dir2d(-dir1.Y(),dir1.X())); + dc1=gp_Dir2d(sign*gp_XY(-dir1.Y(),dir1.X())); + pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc1.XY()); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pararg1(NbrSol)=ElCLib::Parameter(L1,pnttg1sol(NbrSol)); + pnttg2sol(NbrSol) = Point2; + par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg2sol(NbrSol)); + pararg2(NbrSol) = 0.; + pntcen(NbrSol) = Center; + parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); + } + } + } + WellDone = Standard_True; + } + } +} + +//========================================================================= +// Creation d un cercle passant par deux point Point1 et Point2 + +// centre sur une courbe OnCurv. + +// Nous calculons les bissectrices a Point1 et Point2 qui nous donnent + +// l ensemble des lieux possibles des centres de tous les cercles + +// passant par Point1 et Point2. + +// Nous intersectons ces bissectrices avec la courbe OnCurv ce qui nous + +// donne les points parmis lesquels nous allons choisir les solutions. + +//========================================================================= + +Geom2dGcc_Circ2d2TanOnGeo:: +Geom2dGcc_Circ2d2TanOnGeo (const gp_Pnt2d& Point1 , + const gp_Pnt2d& Point2 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Tolerance ): +cirsol(1,8) , +qualifier1(1,8), +qualifier2(1,8), +TheSame1(1,8) , +TheSame2(1,8) , +pnttg1sol(1,8) , +pnttg2sol(1,8) , +pntcen(1,8) , +par1sol(1,8) , +par2sol(1,8) , +pararg1(1,8) , +pararg2(1,8) , +parcen3(1,8) +{ + + WellDone = Standard_False; + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + Standard_Real Tol = Abs(Tolerance); + NbrSol = 0; + gp_Dir2d dirx(1.,0.); + GccAna_Pnt2dBisec Bis(Point1,Point2); + if (Bis.IsDone()) { + Standard_Real Tol1 = Abs(Tolerance); + Standard_Real Tol2 = Tol1; + Geom2dInt_TheIntConicCurveOfGInter Intp; + Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(OnCurv); + Adaptor3d_OffsetCurve Cu2(HCu2,0.); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(Cu2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(Cu2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(Cu2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(Cu2,lastparam),lastparam,Tol); + IntRes2d_Domain D1; + if (Bis.HasSolution()) { + Intp.Perform(Bis.ThisSolution(),D1,Cu2,D2,Tol1,Tol2); + if (Intp.IsDone()) { + if ((!Intp.IsEmpty())) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + gp_Pnt2d Center(Intp.Point(j).Value()); + Standard_Real Radius = Point2.Distance(Center); + NbrSol++; + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + qualifier1(NbrSol) = GccEnt_noqualifier; + qualifier2(NbrSol) = GccEnt_noqualifier; + TheSame1(NbrSol) = 0; + TheSame2(NbrSol) = 0; + pntcen(NbrSol) = Center; + pnttg1sol(NbrSol) = Point1; + pnttg2sol(NbrSol) = Point2; + pararg1(NbrSol) = 0.; + pararg2(NbrSol) = 0.; + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg2sol(NbrSol)); + parcen3(NbrSol) = Intp.Point(j).ParamOnSecond(); + } + } + WellDone = Standard_True; + } + } + } +} + +Standard_Boolean Geom2dGcc_Circ2d2TanOnGeo:: +IsDone () const { return WellDone; } + +Standard_Integer Geom2dGcc_Circ2d2TanOnGeo:: +NbSolutions () const{ return NbrSol; } + +gp_Circ2d Geom2dGcc_Circ2d2TanOnGeo:: +ThisSolution (const Standard_Integer Index) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + + return cirsol(Index); +} + +void Geom2dGcc_Circ2d2TanOnGeo:: +WhichQualifier(const Standard_Integer Index , + GccEnt_Position& Qualif1 , + GccEnt_Position& Qualif2 ) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + else { + Qualif1 = qualifier1(Index); + Qualif2 = qualifier2(Index); + } +} + +void Geom2dGcc_Circ2d2TanOnGeo:: +Tangency1 (const Standard_Integer Index , + Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& PntSol ) const{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + else { + if (TheSame1(Index) == 0) { + ParSol = par1sol(Index); + ParArg = pararg1(Index); + PntSol = gp_Pnt2d(pnttg1sol(Index)); + } + else { StdFail_NotDone::Raise(); } + } +} + +void Geom2dGcc_Circ2d2TanOnGeo:: +Tangency2 (const Standard_Integer Index , + Standard_Real& ParSol , + Standard_Real& ParArg , + gp_Pnt2d& PntSol ) const{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + else { + if (TheSame2(Index) == 0) { + ParSol = par2sol(Index); + ParArg = pararg2(Index); + PntSol = gp_Pnt2d(pnttg2sol(Index)); + } + else { StdFail_NotDone::Raise(); } + } +} + +void Geom2dGcc_Circ2d2TanOnGeo:: +CenterOn3 (const Standard_Integer Index , + Standard_Real& ParArg , + gp_Pnt2d& PntSol ) const{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + else { + ParArg = parcen3(Index); + PntSol = gp_Pnt2d(pntcen(Index)); + } +} + +Standard_Boolean Geom2dGcc_Circ2d2TanOnGeo:: +IsTheSame1 (const Standard_Integer Index) const +{ + if (!WellDone) StdFail_NotDone::Raise(); + if (Index <= 0 ||Index > NbrSol) Standard_OutOfRange::Raise(); + + if (TheSame1(Index) == 0) + return Standard_False; + + return Standard_True; +} + + +Standard_Boolean Geom2dGcc_Circ2d2TanOnGeo:: +IsTheSame2 (const Standard_Integer Index) const +{ + if (!WellDone) StdFail_NotDone::Raise(); + if (Index <= 0 ||Index > NbrSol) Standard_OutOfRange::Raise(); + + if (TheSame2(Index) == 0) + return Standard_False; + + return Standard_True; +} diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cdl index f42c77202a..f4093f66bf 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cdl @@ -51,7 +51,7 @@ uses QualifiedCurve from Geom2dGcc, Array1OfInteger from TColStd, Array1OfReal from TColStd, Circ2d2TanRad from GccAna, - MyCirc2d2TanRad from Geom2dGcc, + Circ2d2TanRadGeo from Geom2dGcc, Position from GccEnt, Array1OfPosition from GccEnt @@ -113,7 +113,7 @@ Results(me : in out ; is static; Results(me : in out ; - Circ : MyCirc2d2TanRad from Geom2dGcc) + Circ : Circ2d2TanRadGeo from Geom2dGcc) is static; IsDone(me) returns Boolean from Standard diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cxx index d8ba1e7905..f7e0cc9211 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cxx @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -178,7 +178,7 @@ Geom2dGcc_Circ2d2TanRad:: GccEnt_QualifiedLin Ql1 = GccEnt_QualifiedLin(l1, Qualified1.Qualifier()); Geom2dGcc_QCurve Qc2(C2,Qualified2.Qualifier()); - Geom2dGcc_MyCirc2d2TanRad CircGeo(Ql1,Qc2,Radius,Tolerance); + Geom2dGcc_Circ2d2TanRadGeo CircGeo(Ql1,Qc2,Radius,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -193,7 +193,7 @@ Geom2dGcc_Circ2d2TanRad:: GccEnt_QualifiedCirc Qc1 = GccEnt_QualifiedCirc(c1, Qualified1.Qualifier()); Geom2dGcc_QCurve Qc2(C2,Qualified2.Qualifier()); - Geom2dGcc_MyCirc2d2TanRad CircGeo(Qc1,Qc2,Radius,Tolerance); + Geom2dGcc_Circ2d2TanRadGeo CircGeo(Qc1,Qc2,Radius,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -213,7 +213,7 @@ Geom2dGcc_Circ2d2TanRad:: GccEnt_QualifiedLin Ql2 = GccEnt_QualifiedLin(l2, Qualified2.Qualifier()); Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); - Geom2dGcc_MyCirc2d2TanRad CircGeo(Ql2,Qc1,Radius,Tolerance); + Geom2dGcc_Circ2d2TanRadGeo CircGeo(Ql2,Qc1,Radius,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -229,7 +229,7 @@ Geom2dGcc_Circ2d2TanRad:: GccEnt_QualifiedCirc Qc2 = GccEnt_QualifiedCirc(c2, Qualified2.Qualifier()); Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); - Geom2dGcc_MyCirc2d2TanRad CircGeo(Qc2,Qc1,Radius,Tolerance); + Geom2dGcc_Circ2d2TanRadGeo CircGeo(Qc2,Qc1,Radius,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -240,7 +240,7 @@ Geom2dGcc_Circ2d2TanRad:: else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); Geom2dGcc_QCurve Qc2(C2,Qualified2.Qualifier()); - Geom2dGcc_MyCirc2d2TanRad CircGeo(Qc1,Qc2,Radius,Tolerance); + Geom2dGcc_Circ2d2TanRadGeo CircGeo(Qc1,Qc2,Radius,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -312,7 +312,7 @@ Geom2dGcc_Circ2d2TanRad:: //============================================================================= else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); - Geom2dGcc_MyCirc2d2TanRad CircGeo(Qc1,Point->Pnt2d(),Radius,Tolerance); + Geom2dGcc_Circ2d2TanRadGeo CircGeo(Qc1,Point->Pnt2d(),Radius,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); for(Standard_Integer i=1; i<=NbrSol; i++) { @@ -373,7 +373,7 @@ void Geom2dGcc_Circ2d2TanRad::Results(const GccAna_Circ2d2TanRad& Circ) } } -void Geom2dGcc_Circ2d2TanRad::Results(const Geom2dGcc_MyCirc2d2TanRad& Circ) +void Geom2dGcc_Circ2d2TanRad::Results(const Geom2dGcc_Circ2d2TanRadGeo& Circ) { for (Standard_Integer j = 1; j <= NbrSol; j++) { cirsol(j) = Circ.ThisSolution(j); diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cdl new file mode 100644 index 0000000000..91d1a188b5 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cdl @@ -0,0 +1,261 @@ +-- 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 Circ2d2TanRadGeo from Geom2dGcc + + ---Purpose: This class implements the algorithms used to + -- create 2d circles tangent to one curve and a + -- point/line/circle/curv and with a given radius. + -- For each construction methods arguments are: + -- - Two Qualified elements for tangency constrains. + -- (for example EnclosedCirc if we want the + -- solution inside the argument EnclosedCirc). + -- - Two Reals. One (Radius) for the radius and the + -- other (Tolerance) for the tolerance. + -- Tolerance is only used for the limit cases. + -- For example : + -- We want to create a circle inside a circle C1 and + -- inside a curve Cu2 with a radius Radius and a + -- tolerance Tolerance. + -- If we did not used Tolerance it is impossible to + -- find a solution in the following case : Cu2 is + -- inside C1 and there is no intersection point + -- between the two elements. + -- With Tolerance we will get a solution if the + -- lowest distance between C1 and Cu2 is lower than or + -- equal Tolerance. + +-- inherits Entity from Standard + +uses Pnt2d from gp, + Circ2d from gp, + Array1OfCirc2d from TColgp, + Array1OfPnt2d from TColgp, + QualifiedCirc from GccEnt, + QualifiedLin from GccEnt, + Array1OfReal from TColStd, + Array1OfInteger from TColStd, + Position from GccEnt, + Array1OfPosition from GccEnt, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + QCurve from Geom2dGcc, + OffsetCurve from Adaptor3d, + HCurve from Geom2dAdaptor, + CurveToolGeo from Geom2dGcc, + TheIntConicCurveOfGInter from Geom2dInt, + GInter from Geom2dInt + +raises OutOfRange from Standard, + BadQualifier from GccEnt, + NotDone from StdFail, + NegativeValue from Standard + +is + +Create(Qualified1 : QualifiedCirc from GccEnt; + Qualified2 : QCurve from Geom2dGcc; + Radius : Real from Standard; + Tolerance : Real from Standard) returns Circ2d2TanRadGeo + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d circle and a curve + -- with a radius of Radius. +raises NegativeValue, BadQualifier; + ---Purpose: It raises NegativeValue if Radius is lower than zero. + +Create(Qualified1 : QualifiedLin from GccEnt; + Qualified2 : QCurve from Geom2dGcc; + Radius : Real from Standard; + Tolerance : Real from Standard) returns Circ2d2TanRadGeo + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a 2d line and a curve + -- with a radius of Radius. +raises NegativeValue, BadQualifier; + ---Purpose: It raises NegativeValue if Radius is lower than zero. + +Create(Qualified1 : QCurve from Geom2dGcc; + Qualified2 : QCurve from Geom2dGcc; + Radius : Real from Standard; + Tolerance : Real from Standard) returns Circ2d2TanRadGeo + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to two curves with + -- a radius of Radius. +raises NegativeValue, BadQualifier; + ---Purpose: It raises NegativeValue if Radius is lower than zero. + +Create(Qualified1 : QCurve from Geom2dGcc; + Point2 : Pnt2d from gp ; + Radius : Real from Standard; + Tolerance : Real from Standard) returns Circ2d2TanRadGeo + ---Purpose: This method implements the algorithms used to + -- create 2d circles TANgent to a curve and a point + -- with a radius of Radius. +raises NegativeValue, BadQualifier; + ---Purpose: It raises NegativeValue if Radius is lower than zero. + +-- -- .................................................................... + +IsDone(me) returns Boolean from Standard +is static; + ---Purpose: This method returns True if the algorithm succeeded. + +NbSolutions(me) returns Integer from Standard + ---Purpose: This method returns the number of solutions. +raises NotDone +is static; + ---Purpose: It raises NotDone if the algorithm failed. + +ThisSolution(me ; + Index : Integer from Standard) returns Circ2d from gp + ---Purpose: Returns the solution number Index. + -- Be careful: the Index is only a way to get all the + -- solutions, but is not associated to those outside the context + -- of the algorithm-object. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises OutOfRange exception if Index is greater + -- than the number of solutions. + -- It raises NotDone if the construction algorithm did not + -- succeed. + +WhichQualifier(me ; + Index : Integer from Standard; + Qualif1 : out Position from GccEnt ; + Qualif2 : out Position from GccEnt ) +raises OutOfRange, NotDone +is static; + ---Purpose: It returns the information 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 ; + Index : Integer from Standard; + ParSol,ParArg : out Real from Standard; + PntSol : out Pnt2d from gp ) + ---Purpose: Returns information about the tangency point between the + -- result number Index and the first argument. + -- ParSol is the intrinsic parameter of the point PntSol on the solution. + -- ParArg is the intrinsic parameter of the point PntSol on the first + -- argument. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises OutOfRange if Index is greater than the number + -- of solutions. + -- It raises NotDone if the construction algorithm did not + -- succeed. + +Tangency2(me ; + Index : Integer from Standard; + ParSol,ParArg : out Real from Standard; + PntSol : out Pnt2d from gp ) + ---Purpose: Returns information about the tangency point between the + -- result number Index and the second argument. + -- ParSol is the intrinsic parameter of the point PntSol on + -- the solution. + -- ParArg is the intrinsic parameter of the point PntArg on + -- the second argument. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises OutOfRange if Index is greater than the number + -- of solutions. + -- It raises NotDone if the construction algorithm did not + -- succeed. + +IsTheSame1(me ; + Index : Integer from Standard) returns Boolean from Standard + ---Purpose: Returns True if the solution number Index is equal to + -- the first argument. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises OutOfRange if Index is greater than the number + -- of solutions. + -- It raises NotDone if the construction algorithm did not + -- succeed. + +IsTheSame2(me ; + Index : Integer from Standard) returns Boolean from Standard + ---Purpose: Returns True if the solution number Index is equal to + -- the second argument. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises OutOfRange if Index is greater than the number + -- of solutions. + -- It raises NotDone if the construction algorithm did not + -- succeed. + +fields + + WellDone : Boolean from Standard; + ---Purpose: True if the algorithm succeeded. + + NbrSol : Integer from Standard; + ---Purpose: The number of possible solutions. We have to decide about + -- the status of the multiple solutions... + + cirsol : Array1OfCirc2d from TColgp; + -- The solutions. + + qualifier1 : Array1OfPosition from GccEnt; + -- The qualifiers of the first argument. + + qualifier2 : Array1OfPosition from GccEnt; + -- The qualifiers of the second argument. + + TheSame1 : Array1OfInteger from TColStd; + ---Purpose: 1 if the solution and the first argument are the same + -- (2 circles). + -- If R1 is the radius of the first argument and Rsol the radius + -- of the solution and dist the distance between the two centers, + -- we consider the two circles are identical if R1+dist-Rsol is + -- less than Tolerance. + -- 0 in the other cases. + + TheSame2 : Array1OfInteger from TColStd; + ---Purpose: 1 if the solution and the second argument are the same + -- (2 circles). + -- If R2 is the radius of the second argument and Rsol the radius + -- of the solution and dist the distance between the two centers, + -- we consider the two circles are identical if R2+dist-Rsol is + -- less than Tolerance. + -- 0 in the other cases. + + pnttg1sol : Array1OfPnt2d from TColgp; + ---Purpose: The tangency point between the solution and the first + -- argument on the solution. + + pnttg2sol : Array1OfPnt2d from TColgp; + ---Purpose: The tangency point between the solution and the second + -- argument on the solution. + + par1sol : Array1OfReal from TColStd; + ---Purpose: The parameter of the tangency point between the solution + -- and the first argument on the solution. + + par2sol : Array1OfReal from TColStd; + ---Purpose: The parameter of the tangency point between the solution + -- and the second argument on the solution. + + pararg1 : Array1OfReal from TColStd; + ---Purpose: The parameter of the tangency point between the solution + -- and the first argument on the first argument. + + pararg2 : Array1OfReal from TColStd; + ---Purpose: The parameter of the tangency point between the solution + -- and the second argument on the second argument. + +end Circ2d2TanRadGeo; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx new file mode 100644 index 0000000000..c2b92c1366 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx @@ -0,0 +1,1025 @@ +// Copyright (c) 1995-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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +// circulaire tant a une courbe et une droite ,de rayon donne +//============================================================== + +//======================================================================== +// On initialise WellDone a false. + +// On recupere la courbe Cu2 et la droite L1. + +// On sort en erreur dans les cas ou la construction est impossible. + +// On fait la parallele a Cu2 dans le bon sens. + +// On fait la parallele a L1 dans le bon sens. + +// On intersecte les paralleles ==> point de centre de la solution. + +// On cree la solution qu on ajoute aux solutions deja trouvees. + +// On remplit les champs. + +//======================================================================== + +Geom2dGcc_Circ2d2TanRadGeo:: +Geom2dGcc_Circ2d2TanRadGeo (const GccEnt_QualifiedLin& Qualified1, + const Geom2dGcc_QCurve& Qualified2, + const Standard_Real Radius , + const Standard_Real Tolerance ): + +//======================================================================== +// initialisation des champs. + +//======================================================================== + +cirsol(1,16) , +qualifier1(1,16), +qualifier2(1,16), +TheSame1(1,16) , +TheSame2(1,16) , +pnttg1sol(1,16), +pnttg2sol(1,16), +par1sol(1,16) , +par2sol(1,16) , +pararg1(1,16) , +pararg2(1,16) +{ + + //======================================================================== + // Traitement. + + //======================================================================== + + Standard_Real Tol = Abs(Tolerance); + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + gp_Dir2d dirx(1.,0.); + TColStd_Array1OfReal cote1(1,2); + TColStd_Array1OfReal cote2(1,2); + Standard_Integer nbrcote1=0; + Standard_Integer nbrcote2=0; + WellDone = Standard_False; + NbrSol = 0; + if (!(Qualified1.IsEnclosed() || + Qualified1.IsOutside() || Qualified1.IsUnqualified()) || + !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || + Qualified2.IsOutside() || Qualified2.IsUnqualified())) { + + GccEnt_BadQualifier::Raise(); + return; + } + gp_Lin2d L1 = Qualified1.Qualified(); + Standard_Real x1dir = (L1.Direction()).X(); + Standard_Real y1dir = (L1.Direction()).Y(); + Standard_Real lxloc = (L1.Location()).X(); + Standard_Real lyloc = (L1.Location()).Y(); + gp_Pnt2d origin1(lxloc,lyloc); + gp_Dir2d normL1(-y1dir,x1dir); + Geom2dAdaptor_Curve Cu2= Qualified2.Qualified(); + if (Radius < 0.0) { Standard_NegativeValue::Raise(); } + else { + if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { + // ======================================================= + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = Radius; + cote2(1) = Radius; + } + else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { + // ========================================================== + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = Radius; + cote2(1) = -Radius; + } + else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { + // =========================================================== + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = -Radius; + cote2(1) = Radius; + } + else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { + // ========================================================= + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = -Radius; + cote2(1) = -Radius; + } + if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { + // ========================================================= + nbrcote1 = 1; + nbrcote2 = 2; + cote1(1) = Radius; + cote2(1) = Radius; + cote2(2) = -Radius; + } + if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { + // ========================================================= + nbrcote1 = 2; + nbrcote2 = 1; + cote1(1) = Radius; + cote1(2) = -Radius; + cote2(1) = Radius; + } + else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { + // ============================================================= + nbrcote1 = 1; + nbrcote2 = 2; + cote1(1) = -Radius; + cote2(1) = Radius; + cote2(2) = -Radius; + } + if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { + // ======================================================== + nbrcote1 = 2; + nbrcote2 = 1; + cote1(1) = Radius; + cote1(2) = -Radius; + cote2(1) = -Radius; + } + else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { + // ================================================================= + nbrcote1 = 2; + nbrcote2 = 2; + cote1(1) = Radius; + cote1(2) = -Radius; + cote2(1) = Radius; + cote2(2) = -Radius; + } + gp_Dir2d Dir(-y1dir,x1dir); + for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + gp_Pnt2d Point(L1.Location().XY()+cote1(jcote1)*Dir.XY()); + gp_Lin2d Line(Point,L1.Direction()); // ligne avec deport. + IntRes2d_Domain D1; + for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { + Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2); + Adaptor3d_OffsetCurve C2(HCu2,cote2(jcote2)); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); + Geom2dInt_TheIntConicCurveOfGInter Intp(Line,D1,C2,D2,Tol,Tol); + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + NbrSol++; + gp_Pnt2d Center(Intp.Point(i).Value()); + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + gp_Dir2d dc1(origin1.XY()-Center.XY()); + qualifier2(NbrSol) = Qualified2.Qualifier(); + if (!Qualified1.IsUnqualified()) { + qualifier1(NbrSol) = Qualified1.Qualifier(); + } + else if (dc1.Dot(normL1) > 0.0) { + qualifier1(NbrSol) = GccEnt_outside; + } + else { qualifier1(NbrSol) = GccEnt_enclosed; } + TheSame1(NbrSol) = 0; + TheSame2(NbrSol) = 0; + pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); + pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); + pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),L1); + pnttg2sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu2,pararg2(NbrSol)); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg2sol(NbrSol)); + } + } + WellDone = Standard_True; + } + } + } + } +} + +// circulaire tant a une courbe et un cercle ,de rayon donne +//============================================================= + +//======================================================================== +// On initialise WellDone a false. + +// On recupere la courbe Cu2 et le cercle C1. + +// On sort en erreur dans les cas ou la construction est impossible. + +// On fait la parallele a Cu2 dans le bon sens. + +// On fait la parallele a C1 dans le bon sens. + +// On intersecte les paralleles ==> point de centre de la solution. + +// On cree la solution qu on ajoute aux solutions deja trouvees. + +// On remplit les champs. + +//======================================================================== + +Geom2dGcc_Circ2d2TanRadGeo:: +Geom2dGcc_Circ2d2TanRadGeo (const GccEnt_QualifiedCirc& Qualified1, + const Geom2dGcc_QCurve& Qualified2, + const Standard_Real Radius , + const Standard_Real Tolerance ): + +//======================================================================== +// initialisation des champs. + +//======================================================================== + +cirsol(1,16) , +qualifier1(1,16), +qualifier2(1,16), +TheSame1(1,16) , +TheSame2(1,16) , +pnttg1sol(1,16), +pnttg2sol(1,16), +par1sol(1,16) , +par2sol(1,16) , +pararg1(1,16) , +pararg2(1,16) +{ + + //======================================================================== + // Traitement. + + //======================================================================== + + Standard_Real Tol = Abs(Tolerance); + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + gp_Dir2d dirx(1.,0.); + TColStd_Array1OfReal cote1(1,2); + TColStd_Array1OfReal cote2(1,2); + Standard_Integer nbrcote1=0; + Standard_Integer nbrcote2=0; + WellDone = Standard_False; + NbrSol = 0; + 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(); + gp_Pnt2d center1(C1.Location()); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); + if (Radius < 0.0) { Standard_NegativeValue::Raise(); } + else { + if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { + // ======================================================= + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = Radius; + cote2(1) = Radius; + } + else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { + // ========================================================== + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = Radius; + cote2(1) = -Radius; + } + else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { + // =========================================================== + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = -Radius; + cote2(1) = Radius; + } + else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { + // ========================================================= + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = -Radius; + cote2(1) = -Radius; + } + if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { + // ========================================================= + nbrcote1 = 1; + nbrcote2 = 2; + cote1(1) = Radius; + cote2(1) = Radius; + cote2(2) = -Radius; + } + if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { + // ========================================================= + nbrcote1 = 2; + nbrcote2 = 1; + cote1(1) = Radius; + cote1(2) = -Radius; + cote2(1) = Radius; + } + else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { + // ============================================================= + nbrcote1 = 1; + nbrcote2 = 2; + cote1(1) = -Radius; + cote2(1) = Radius; + cote2(2) = -Radius; + } + if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { + // ======================================================== + nbrcote1 = 2; + nbrcote2 = 1; + cote1(1) = Radius; + cote1(2) = -Radius; + cote2(1) = -Radius; + } + else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { + // ================================================================= + nbrcote1 = 2; + nbrcote2 = 2; + cote1(1) = Radius; + cote1(2) = -Radius; + cote2(1) = Radius; + cote2(2) = -Radius; + } + Standard_Real R1 = C1.Radius(); + Geom2dInt_TheIntConicCurveOfGInter Intp; + for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + gp_Circ2d Circ(C1.XAxis(),R1+cote1(jcote1)); + IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, + ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol); + D1.SetEquivalentParameters(0.,2.*M_PI); + for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { + Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2); + Adaptor3d_OffsetCurve C2(HCu2,cote2(jcote2)); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); + Intp.Perform(Circ,D1,C2,D2,Tol,Tol); + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + NbrSol++; + gp_Pnt2d Center(Intp.Point(i).Value()); + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= +#ifdef DEB + gp_Dir2d dir1(Center.XY()-center1.XY()); +#else + Center.XY() ; + center1.XY() ; +#endif + Standard_Real distcc1 = Center.Distance(center1); + if (!Qualified1.IsUnqualified()) { + qualifier1(NbrSol) = Qualified1.Qualifier(); + } + else if (Abs(distcc1+Radius-R1) < Tol) { + qualifier1(NbrSol) = GccEnt_enclosed; + } + else if (Abs(distcc1-R1-Radius) < Tol) { + qualifier1(NbrSol) = GccEnt_outside; + } + else { qualifier1(NbrSol) = GccEnt_enclosing; } + qualifier2(NbrSol) = Qualified2.Qualifier(); + TheSame1(NbrSol) = 0; + TheSame2(NbrSol) = 0; + pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); + pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); + pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),C1); + pnttg2sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu2,pararg2(NbrSol)); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg2sol(NbrSol)); + } + } + WellDone = Standard_True; + } + } + } + } +} + +// circulaire tant a une courbe et un point ,de rayon donne +//============================================================ + +//======================================================================== +// On initialise WellDone a false. + +// On recupere la courbe Cu1 et le point P2. + +// On sort en erreur dans les cas ou la construction est impossible. + +// On fait la parallele a Cu1 dans le bon sens. + +// On fait la parallele a P2 dans le bon sens. + +// On intersecte les paralleles ==> point de centre de la solution. + +// On cree la solution qu on ajoute aux solutions deja trouvees. + +// On remplit les champs. + +//======================================================================== + +Geom2dGcc_Circ2d2TanRadGeo:: +Geom2dGcc_Circ2d2TanRadGeo (const Geom2dGcc_QCurve& Qualified1, + const gp_Pnt2d& Point2 , + const Standard_Real Radius , + const Standard_Real Tolerance ): + +//======================================================================== +// initialisation des champs. + +//======================================================================== + +cirsol(1,16) , +qualifier1(1,16), +qualifier2(1,16), +TheSame1(1,16) , +TheSame2(1,16) , +pnttg1sol(1,16), +pnttg2sol(1,16), +par1sol(1,16) , +par2sol(1,16) , +pararg1(1,16) , +pararg2(1,16) +{ + + //======================================================================== + // Traitement. + + //======================================================================== + + Standard_Real Tol = Abs(Tolerance); + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + gp_Dir2d dirx(1.,0.); + TColStd_Array1OfReal cote1(1,2); + Standard_Integer nbrcote1=0; + WellDone = Standard_False; + NbrSol = 0; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + if (Radius < 0.0) { Standard_NegativeValue::Raise(); } + else { + if (Qualified1.IsEnclosed()) { + // =========================== + nbrcote1 = 1; + cote1(1) = Radius; + } + else if(Qualified1.IsOutside()) { + // =============================== + nbrcote1 = 1; + cote1(1) = -Radius; + } + else if(Qualified1.IsUnqualified()) { + // =================================== + nbrcote1 = 2; + cote1(1) = Radius; + cote1(2) = -Radius; + } + gp_Circ2d Circ(gp_Ax2d(Point2,gp_Dir2d(1.,0.)),Radius); + IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, + ElCLib::Value(M_PI+M_PI,Circ),M_PI+M_PI,Tol); + D1.SetEquivalentParameters(0.,M_PI+M_PI); + Geom2dInt_TheIntConicCurveOfGInter Intp; + for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1); + Adaptor3d_OffsetCurve Cu2(HCu1,cote1(jcote1)); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(Cu2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(Cu2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(Cu2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(Cu2,lastparam),lastparam,Tol); + Intp.Perform(Circ,D1,Cu2,D2,Tol,Tol); + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + NbrSol++; + gp_Pnt2d Center(Intp.Point(i).Value()); + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + qualifier1(NbrSol) = Qualified1.Qualifier(); + qualifier2(NbrSol) = GccEnt_noqualifier; + TheSame1(NbrSol) = 0; + TheSame2(NbrSol) = 0; + pararg1(NbrSol) = Intp.Point(i).ParamOnSecond(); + pararg2(NbrSol) = 0.; + pnttg1sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol)); + pnttg2sol(NbrSol) = Point2; + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg2sol(NbrSol)); + } + } + WellDone = Standard_True; + } + } + } +} + +static void PrecRoot(const Adaptor3d_OffsetCurve& theC1, + const Adaptor3d_OffsetCurve& theC2, + const Standard_Real theU0, + const Standard_Real theV0, + const Standard_Real theUmin, + const Standard_Real theUmax, + const Standard_Real theVmin, + const Standard_Real theVmax, + Standard_Real& theUfinal, + Standard_Real& theVfinal) +{ + const Standard_Real aInitStepU = (theUmax - theUmin)/2.0, + aInitStepV = (theVmax - theVmin)/2.0; + + Standard_Real aStepU = aInitStepU, aStepV = aInitStepV; + + const Standard_Real aTol = Precision::PConfusion() * Precision::PConfusion(); + const Standard_Integer aNbIterMax = 100; + + gp_Pnt2d aP1, aP2; + gp_Vec2d aD1, aD2; + + Geom2dGcc_CurveToolGeo::D1(theC1, theU0, aP1, aD1); + Geom2dGcc_CurveToolGeo::D1(theC2, theV0, aP2, aD2); + + gp_Vec2d vP12(aP1.XY() - aP2.XY()); + + Standard_Real aU = theU0, aV = theV0; + theUfinal = theU0; + theVfinal = theV0; + + Standard_Real aSQDistPrev = aP1.SquareDistance(aP2); + + Standard_Integer aNbIter = 1; + + do + { + Standard_Real aDetH = aD1.Y()*aD2.X() - aD1.X()*aD2.Y(); + if(aDetH == 0.0) + break; + + aU += aStepU*(aD2.Y() * vP12.X() - aD2.X()*vP12.Y())/aDetH; + aV += aStepV*(aD1.Y() * vP12.X() - aD1.X()*vP12.Y())/aDetH; + + if(Abs(aU - theUmin) > 1000.0) + //method diverges + return; + + if(Abs(aU - theUmax) > 1000.0) + //method diverges + return; + + if(Abs(aV - theVmin) > 1000.0) + //method diverges + return; + + if(Abs(aV - theVmax) > 1000.0) + //method diverges + return; + + Geom2dGcc_CurveToolGeo::D1(theC1, aU, aP1, aD1); + Geom2dGcc_CurveToolGeo::D1(theC2, aV, aP2, aD2); + const Standard_Real aSQDist = aP1.SquareDistance(aP2); + + if(Precision::IsInfinite(aSQDist)) + //method diverges + return; + + vP12.SetXY(aP1.XY() - aP2.XY()); + + if(aSQDist < aSQDistPrev) + { + aSQDistPrev = aSQDist; + aStepU = aInitStepU; + aStepV = aInitStepV; + theUfinal = aU; + theVfinal = aV; + } + else + { + aStepU /= 2.0; + aStepV /= 2.0; + } + } + while((aNbIter++ < aNbIterMax) && ((aStepU > aTol) || (aStepV > aTol))); + + Standard_Boolean isInBound = Standard_True; + if(theUfinal < theUmin) + { + aU = theUfinal; + aV = theVfinal; + + theUfinal = theUmin; + isInBound = Standard_False; + } + + if(theUfinal > theUmax) + { + aU = theUfinal; + aV = theVfinal; + + theUfinal = theUmax; + isInBound = Standard_False; + } + + if(!isInBound) + { + Geom2dGcc_CurveToolGeo::D1(theC1, aU, aP1, aD1); + Geom2dGcc_CurveToolGeo::D1(theC2, aV, aP2, aD2); + Standard_Real aV1 = (aD2.X() == 0.0) ? aV :((theUfinal - aU)*aD1.X() + aV*aD2.X() + (aP1.X() - aP2.X()))/aD2.X(); + Standard_Real aV2 = (aD2.Y() == 0.0) ? aV :((theUfinal - aU)*aD1.Y() + aV*aD2.Y() + (aP1.Y() - aP2.Y()))/aD2.Y(); + + if(aV1 < theVmin) + aV1 = theVmin; + + if(aV1 > theVmax) + aV1 = theVmax; + + if(aV2 < theVmin) + aV2 = theVmin; + + if(aV2 > theVmax) + aV2 = theVmax; + + aP1 = Geom2dGcc_CurveToolGeo::Value(theC1,theUfinal); + aP2 = Geom2dGcc_CurveToolGeo::Value(theC2,aV1); + + Standard_Real aSQ1 = aP1.SquareDistance(aP2); + + aP2 = Geom2dGcc_CurveToolGeo::Value(theC2,aV2); + Standard_Real aSQ2 = aP1.SquareDistance(aP2); + + if(aSQ1 < aSQ2) + theVfinal = aV1; + else + theVfinal = aV2; + + return; + } + + if(theVfinal < theVmin) + { + aU = theUfinal; + aV = theVfinal; + + theVfinal = theVmin; + isInBound = Standard_False; + } + + if(theVfinal > theVmax) + { + aU = theUfinal; + aV = theVfinal; + + theVfinal = theVmax; + isInBound = Standard_False; + } + + if(isInBound) + return; + + Geom2dGcc_CurveToolGeo::D1(theC1, aU, aP1, aD1); + Geom2dGcc_CurveToolGeo::D1(theC2, aV, aP2, aD2); + Standard_Real aU1 = (aD1.X() == 0.0) ? aU :((theVfinal - aV)*aD2.X() + aU*aD1.X() + (aP2.X() - aP1.X()))/aD1.X(); + Standard_Real aU2 = (aD1.Y() == 0.0) ? aU :((theVfinal - aV)*aD2.Y() + aU*aD1.Y() + (aP2.Y() - aP1.Y()))/aD1.Y(); + + if(aU1 < theUmin) + aU1 = theUmin; + + if(aU1 > theUmax) + aU1 = theUmax; + + if(aU2 < theUmin) + aU2 = theUmin; + + if(aU2 > theUmax) + aU2 = theUmax; + + aP2 = Geom2dGcc_CurveToolGeo::Value(theC2,theVfinal); + aP1 = Geom2dGcc_CurveToolGeo::Value(theC1,aU1); + + Standard_Real aSQ1 = aP1.SquareDistance(aP2); + + aP1 = Geom2dGcc_CurveToolGeo::Value(theC1,aU2); + Standard_Real aSQ2 = aP1.SquareDistance(aP2); + + if(aSQ1 < aSQ2) + theUfinal = aU1; + else + theUfinal = aU2; +} + +// circulaire tant a deux courbes ,de rayon donne +//================================================== + +//======================================================================== +// On initialise WellDone a false. + +// On recupere les courbes Cu1 et Cu2. + +// On sort en erreur dans les cas ou la construction est impossible. + +// On fait la parallele a Cu1 dans le bon sens. + +// On fait la parallele a Cu2 dans le bon sens. + +// On intersecte les paralleles ==> point de centre de la solution. + +// On cree la solution qu on ajoute aux solutions deja trouvees. + +// On remplit les champs. + +//======================================================================== + +Geom2dGcc_Circ2d2TanRadGeo:: +Geom2dGcc_Circ2d2TanRadGeo (const Geom2dGcc_QCurve& Qualified1, + const Geom2dGcc_QCurve& Qualified2, + const Standard_Real Radius , + const Standard_Real Tolerance ): + +//======================================================================== +// initialisation des champs. + +//======================================================================== + +cirsol(1,16) , +qualifier1(1,16), +qualifier2(1,16), +TheSame1(1,16) , +TheSame2(1,16) , +pnttg1sol(1,16), +pnttg2sol(1,16), +par1sol(1,16) , +par2sol(1,16) , +pararg1(1,16) , +pararg2(1,16) +{ + + //======================================================================== + // Traitement. + + //======================================================================== + + Standard_Real Tol = Abs(Tolerance); + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + gp_Dir2d dirx(1.,0.); + TColStd_Array1OfReal cote1(1,2); + TColStd_Array1OfReal cote2(1,2); + Standard_Integer nbrcote1=0; + Standard_Integer nbrcote2=0; + WellDone = Standard_False; + NbrSol = 0; + 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(); + if (Radius < 0.0) { Standard_NegativeValue::Raise(); } + else { + if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { + // ======================================================= + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = Radius; + cote2(1) = Radius; + } + else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { + // ========================================================== + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = Radius; + cote2(1) = -Radius; + } + else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { + // =========================================================== + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = -Radius; + cote2(1) = Radius; + } + else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { + // ========================================================= + nbrcote1 = 1; + nbrcote2 = 1; + cote1(1) = -Radius; + cote2(1) = -Radius; + } + if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { + // ========================================================= + nbrcote1 = 1; + nbrcote2 = 2; + cote1(1) = Radius; + cote2(1) = Radius; + cote2(2) = -Radius; + } + if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { + // ========================================================= + nbrcote1 = 2; + nbrcote2 = 1; + cote1(1) = Radius; + cote1(2) = -Radius; + cote2(1) = Radius; + } + else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { + // ============================================================= + nbrcote1 = 1; + nbrcote2 = 2; + cote1(1) = -Radius; + cote2(1) = Radius; + cote2(2) = -Radius; + } + if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { + // ======================================================== + nbrcote1 = 2; + nbrcote2 = 1; + cote1(1) = Radius; + cote1(2) = -Radius; + cote2(1) = -Radius; + } + else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { + // ================================================================= + nbrcote1 = 2; + nbrcote2 = 2; + cote1(1) = Radius; + cote1(2) = -Radius; + cote2(1) = Radius; + cote2(2) = -Radius; + } + Geom2dInt_GInter Intp; + for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1); + Adaptor3d_OffsetCurve C1(HCu1,cote1(jcote1)); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C1),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C1),thelast); +#ifdef DEB + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C1,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C1,lastparam),lastparam,Tol); +#else + Geom2dGcc_CurveToolGeo::Value(C1,firstparam); + Geom2dGcc_CurveToolGeo::Value(C1,lastparam); +#endif + for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { + Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2); + Adaptor3d_OffsetCurve C2(HCu2,cote2(jcote2)); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); +#ifdef DEB + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); +#else + Geom2dGcc_CurveToolGeo::Value(C2,firstparam); + Geom2dGcc_CurveToolGeo::Value(C2,lastparam); +#endif + Intp.Perform(C1,C2,Tol,Tol); + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) + { + Standard_Real aU0 = Intp.Point(i).ParamOnFirst(); + Standard_Real aV0 = Intp.Point(i).ParamOnSecond(); + + Standard_Real aU1 = aU0-Precision::PApproximation(); + Standard_Real aV1 = aV0-Precision::PApproximation(); + + Standard_Real aU2 = aU0+Precision::PApproximation(); + Standard_Real aV2 = aV0+Precision::PApproximation(); + + gp_Pnt2d P11 = Geom2dGcc_CurveToolGeo::Value(C1,aU1); + gp_Pnt2d P12 = Geom2dGcc_CurveToolGeo::Value(C2,aV1); + gp_Pnt2d P21 = Geom2dGcc_CurveToolGeo::Value(C1,aU2); + gp_Pnt2d P22 = Geom2dGcc_CurveToolGeo::Value(C2,aV2); + + Standard_Real aDist1112 = P11.Distance(P12); + Standard_Real aDist1122 = P11.Distance(P22); + + Standard_Real aDist1221 = P12.Distance(P21); + Standard_Real aDist2122 = P21.Distance(P22); + + if( Min(aDist1112, aDist1122) <= Precision::Approximation() && + Min(aDist1221, aDist2122) <= Precision::Approximation()) + { + PrecRoot(C1, C2, aU0, aV0, + Max(Geom2dGcc_CurveToolGeo::FirstParameter(C1), aU0 - 10.0), + Min(Geom2dGcc_CurveToolGeo::LastParameter(C1), aU0 + 10.0), + Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2), aV0 - 10.0), + Min(Geom2dGcc_CurveToolGeo::LastParameter(C2), aV0 + 10.0), + aU0, aV0); + } + + NbrSol++; + gp_Pnt2d Center(Geom2dGcc_CurveToolGeo::Value(C1, aU0)); + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + qualifier1(NbrSol) = Qualified1.Qualifier(); + qualifier1(NbrSol) = Qualified1.Qualifier(); + TheSame1(NbrSol) = 0; + TheSame2(NbrSol) = 0; + pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); + pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); + pnttg1sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol)); + pnttg2sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu2,pararg2(NbrSol)); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg2sol(NbrSol)); + } + } + + WellDone = Standard_True; + } + } + } + } +} + +//========================================================================= + +Standard_Boolean Geom2dGcc_Circ2d2TanRadGeo:: +IsDone () const { return WellDone; } + +Standard_Integer Geom2dGcc_Circ2d2TanRadGeo:: +NbSolutions () const { return NbrSol; } + +gp_Circ2d Geom2dGcc_Circ2d2TanRadGeo:: +ThisSolution (const Standard_Integer Index) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + return cirsol(Index); +} + +void Geom2dGcc_Circ2d2TanRadGeo:: +WhichQualifier(const Standard_Integer Index , + GccEnt_Position& Qualif1 , + GccEnt_Position& Qualif2 ) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + else { + Qualif1 = qualifier1(Index); + Qualif2 = qualifier2(Index); + } +} + +void Geom2dGcc_Circ2d2TanRadGeo:: +Tangency1 (const Standard_Integer Index, + Standard_Real& ParSol, + Standard_Real& ParArg, + gp_Pnt2d& PntSol) const{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + else { + if (TheSame1(Index) == 0) { + ParSol = par1sol(Index); + ParArg = pararg1(Index); + PntSol = gp_Pnt2d(pnttg1sol(Index)); + } + else { StdFail_NotDone::Raise(); } + } +} + +void Geom2dGcc_Circ2d2TanRadGeo:: +Tangency2 (const Standard_Integer Index, + Standard_Real& ParSol, + Standard_Real& ParArg, + gp_Pnt2d& PntSol) const{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + else { + if (TheSame2(Index) == 0) { + ParSol = par2sol(Index); + ParArg = pararg2(Index); + PntSol = gp_Pnt2d(pnttg2sol(Index)); + } + else { StdFail_NotDone::Raise(); } + } +} + +Standard_Boolean Geom2dGcc_Circ2d2TanRadGeo:: +IsTheSame1 (const Standard_Integer Index) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + + if (TheSame1(Index) == 0) { return Standard_False; } + return Standard_True; +} + +Standard_Boolean Geom2dGcc_Circ2d2TanRadGeo:: +IsTheSame2 (const Standard_Integer Index) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + + if (TheSame2(Index) == 0) { return Standard_False; } + return Standard_True; +} + diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2dTanCen.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2dTanCen.cxx index ceaec38c9e..5d9245b579 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2dTanCen.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanCen.cxx @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -85,7 +85,7 @@ Geom2dGcc_Circ2dTanCen:: else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); - Geom2dGcc_MyCirc2dTanCen Circ(Qc1,pcenter,Tolerance); + Geom2dGcc_Circ2dTanCenGeo Circ(Qc1,pcenter,Tolerance); WellDone = Circ.IsDone(); NbrSol = Circ.NbSolutions(); for (Standard_Integer j = 1; j <= NbrSol; j++) { diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cdl new file mode 100644 index 0000000000..cdaf5021c6 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cdl @@ -0,0 +1,150 @@ +-- Created on: 1991-03-28 +-- 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 Circ2dTanCenGeo from Geom2dGcc + + ---Purpose: This class implements the algorithms used to + -- create 2d circles tangent to a curve and + -- centered on a point. + -- The arguments of all construction methods are : + -- - The qualified element for the tangency constrains + -- (QualifiedCurv). + -- -The center point Pcenter. + -- - A real Tolerance. + -- Tolerance is only used in the limits cases. + -- For example : + -- We want to create a circle tangent to an EnclosedCurv C1 + -- with a tolerance Tolerance. + -- If we did not use Tolerance it is impossible to + -- find a solution in the following case : Pcenter is + -- outside C1. + -- With Tolerance we will give a solution if the distance + -- between C1 and Pcenter is lower than or equal Tolerance/2. + +-- inherits Entity from Standard + +uses Pnt2d from gp, + Circ2d from gp, + Array1OfCirc2d from TColgp, + Array1OfPnt2d from TColgp, + Array1OfReal from TColStd, + Array1OfInteger from TColStd, + Position from GccEnt, + Array1OfPosition from GccEnt, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + ExtPC2d from Extrema, + QCurve from Geom2dGcc + +raises OutOfRange from Standard, + BadQualifier from GccEnt, + NotDone from StdFail + +is + +Create( Qualified1 : QCurve from Geom2dGcc; + Pcenter : Pnt2d from gp; + Tolerance : Real from Standard) returns Circ2dTanCenGeo + ---Purpose: This method implements the algorithms used to + -- create 2d circles tangent to a circle and + -- centered on a point. +raises BadQualifier; + +-- -- .................................................................... + +IsDone(me) returns Boolean from Standard +is static; + ---Purpose: This method returns True if the construction + -- algorithm succeeded. + +NbSolutions(me) returns Integer from Standard + ---Purpose: Returns the number of solutions and raises NotDone + -- exception if the algorithm didn't succeed. +raises NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +ThisSolution(me ; + Index : Integer from Standard) returns Circ2d from gp + ---Purpose: Returns the solution number Index and raises OutOfRange + -- exception if Index is greater than the number of solutions. + -- Be carefull: the Index is only a way to get all the + -- solutions, but is not associated to theses outside the + -- context of the algorithm-object. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions or less than zero. + +WhichQualifier(me ; + Index : Integer from Standard; + Qualif1 : out Position from GccEnt ) +raises OutOfRange, NotDone +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 ; + Index : Integer from Standard; + ParSol,ParArg : out Real from Standard; + PntSol : out Pnt2d from gp ) + ---Purpose: Returns informations about the tangency point between the + -- result number Index 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 PntArg + -- on the argument curv. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions or less than zero. + +fields + + WellDone : Boolean from Standard; + -- True if the algorithm succeeded. + + NbrSol : Integer from Standard; + -- The number of possible solutions. We have to decide about the + -- status of the multiple solutions... + + cirsol : Array1OfCirc2d from TColgp; + ---Purpose : The solutions. + + qualifier1 : Array1OfPosition from GccEnt; + -- The qualifiers of the first argument. + + pnttg1sol : Array1OfPnt2d from TColgp; + -- The tangency point between the solution and the first argument on + -- the solution. + + par1sol : Array1OfReal from TColStd; + -- The parameter of the tangency point between the solution and the + -- first argument on the solution. + + pararg1 : Array1OfReal from TColStd; + -- The parameter of the tangency point between the solution and the first + -- argument on the first argument. + +end Circ2dTanCenGeo; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx new file mode 100644 index 0000000000..dd85c052f5 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx @@ -0,0 +1,164 @@ +// Copyright (c) 1995-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 +#include +#include +#include +#include + +#include +#include + +//========================================================================= +// Creation d un cercle tangent a une courbe centre en un point. + +//========================================================================= + +Geom2dGcc_Circ2dTanCenGeo:: +Geom2dGcc_Circ2dTanCenGeo (const Geom2dGcc_QCurve& Qualified1, + const gp_Pnt2d& Pcenter , + const Standard_Real Tolerance ): + +//======================================================================== +// Initialisation des champs. + +//======================================================================== + + cirsol(1,2) , + qualifier1(1,2), + pnttg1sol(1,2) , + par1sol(1,2) , + pararg1(1,2) +{ + Standard_Real Tol = Abs(Tolerance); + TColgp_Array1OfPnt2d pTan(1,2); + TColStd_Array1OfInteger Index(1,2); + TColStd_Array1OfReal theDist2(1,2); + TColStd_Array1OfReal theParam(1,2); + theDist2(1) = RealLast(); + theDist2(2) = 0.; + Standard_Integer i = 1; + Standard_Integer nbsol = 0; + gp_Dir2d dirx(1.0,0.0); + Standard_Real thePar; + Geom2dAdaptor_Curve curve = Qualified1.Qualified(); + Extrema_ExtPC2d distmin(Pcenter,curve,Geom2dGcc_CurveTool::NbSamples(curve), + Geom2dGcc_CurveTool::EpsX(curve,Tol),Tol); + if (!distmin.IsDone() ) { Standard_Failure::Raise(); } + Standard_Integer nbext = distmin.NbExt(); + if(nbext==0) { Standard_Failure::Raise(); } + while (i<=nbext) { + thePar = distmin.Point(i).Parameter(); + if (distmin.SquareDistance(i)=Geom2dGcc_CurveTool::FirstParameter(curve) && + thePar <= Geom2dGcc_CurveTool::LastParameter(curve)) { + theDist2(1) = distmin.SquareDistance(i); + theParam(1) = thePar; + pTan(1) = distmin.Point(i).Value(); + } + if (distmin.SquareDistance(i)>theDist2(2) && + thePar>=Geom2dGcc_CurveTool::FirstParameter(curve) && + thePar <= Geom2dGcc_CurveTool::LastParameter(curve)) { + theDist2(2) = distmin.SquareDistance(i); + theParam(2) = thePar; + pTan(2) = distmin.Point(i).Value(); + } + i++; + } + if (Index(1) == Index(2)) { nbsol = 1; } + else { nbsol = 2; } + for (i = 1 ; i <= nbsol; i++) { + gp_Pnt2d point1; + gp_Vec2d Tan1; + Geom2dGcc_CurveTool::D1(curve,theParam(i),point1,Tan1); + Standard_Real normetan1 = Tan1.Magnitude(); + gp_Vec2d Vec1(point1,Pcenter); + Standard_Real normevec1 = Vec1.Magnitude(); + Standard_Real dot1; + if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) { + dot1 = Vec1.Dot(Tan1)/(normevec1*normetan1); + } + else { dot1 = 0.; } + Tol = 1.e-12; + if (dot1 <= Tol) { + Standard_Real Angle1 = Vec1.Angle(Tan1); + if (Qualified1.IsUnqualified()|| + (Qualified1.IsEnclosing()&&Angle1<=0.)|| + (Qualified1.IsOutside() && Angle1 >= 0.) || + (Qualified1.IsEnclosed() && Angle1 <= 0.)) { + NbrSol++; + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Pcenter,dirx),sqrt (theDist2(i))); + qualifier1(NbrSol) = Qualified1.Qualifier(); + pararg1(NbrSol) = theParam(i); + par1sol(NbrSol) = 0.; + pnttg1sol(NbrSol) = pTan(i); + WellDone = Standard_True; + } + } + } +} + + + +//========================================================================= + + +Standard_Boolean Geom2dGcc_Circ2dTanCenGeo:: +IsDone () const { return WellDone; } + +Standard_Integer Geom2dGcc_Circ2dTanCenGeo:: +NbSolutions () const { return NbrSol; } + +gp_Circ2d Geom2dGcc_Circ2dTanCenGeo:: +ThisSolution (const Standard_Integer Index) const +{ + if (Index > NbrSol || Index <= 0) Standard_OutOfRange::Raise(); + + return cirsol(Index); +} + +void Geom2dGcc_Circ2dTanCenGeo:: +WhichQualifier(const Standard_Integer Index , + GccEnt_Position& Qualif1 ) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + else { + Qualif1 = qualifier1(Index); + } +} + +void Geom2dGcc_Circ2dTanCenGeo:: +Tangency1 (const Standard_Integer Index, + Standard_Real& ParSol, + Standard_Real& ParArg, + gp_Pnt2d& PntSol) const{ + if (!WellDone) { + StdFail_NotDone::Raise(); + } + else if (Index <= 0 ||Index > NbrSol) { + Standard_OutOfRange::Raise(); + } + else { + PntSol = gp_Pnt2d(pnttg1sol(Index)); + ParSol = par1sol(Index); + ParArg = pararg1(Index); + } +} + diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRad.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRad.cdl index bf76dd9ca3..3fbd3ff35e 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRad.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRad.cdl @@ -41,20 +41,20 @@ class Circ2dTanOnRad from Geom2dGcc -- inherits Entity from Standard -uses Lin2d from gp, - Circ2d from gp, - Pnt2d from gp, - Point from Geom2d, - Array1OfCirc2d from TColgp, - Array1OfPnt2d from TColgp, - Curve from Geom2dAdaptor, - QualifiedCurve from Geom2dGcc, - Array1OfReal from TColStd, - Array1OfInteger from TColStd, - Circ2dTanOnRad from GccAna, - MyCirc2dTanOnRad from Geom2dGcc, - Position from GccEnt, - Array1OfPosition from GccEnt +uses Lin2d from gp, + Circ2d from gp, + Pnt2d from gp, + Point from Geom2d, + Array1OfCirc2d from TColgp, + Array1OfPnt2d from TColgp, + Curve from Geom2dAdaptor, + QualifiedCurve from Geom2dGcc, + Array1OfReal from TColStd, + Array1OfInteger from TColStd, + Circ2dTanOnRad from GccAna, + Circ2dTanOnRadGeo from Geom2dGcc, + Position from GccEnt, + Array1OfPosition from GccEnt raises NegativeValue from Standard, OutOfRange from Standard, @@ -115,7 +115,7 @@ Results(me : in out ; is static; Results(me : in out ; - Circ : MyCirc2dTanOnRad from Geom2dGcc) + Circ : Circ2dTanOnRadGeo from Geom2dGcc) is static; IsDone(me) returns Boolean from Standard diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRad.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRad.cxx index 9ce33a8261..609b48c09c 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRad.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRad.cxx @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -114,7 +114,7 @@ Geom2dGcc_Circ2dTanOnRad:: gp_Circ2d c1(CCC1->Circ2d()); GccEnt_QualifiedCirc Qc1=GccEnt_QualifiedCirc(c1, Qualified1.Qualifier()); - Geom2dGcc_MyCirc2dTanOnRad CircGeo(Qc1,OnCurve,Radius,Tolerance); + Geom2dGcc_Circ2dTanOnRadGeo CircGeo(Qc1,OnCurve,Radius,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); Results(CircGeo); @@ -123,14 +123,14 @@ Geom2dGcc_Circ2dTanOnRad:: Handle(Geom2d_Line) LL1 = Handle(Geom2d_Line)::DownCast(CC1); gp_Lin2d l1(LL1->Lin2d()); GccEnt_QualifiedLin Ql1=GccEnt_QualifiedLin(l1,Qualified1.Qualifier()); - Geom2dGcc_MyCirc2dTanOnRad CircGeo(Ql1,OnCurve,Radius,Tolerance); + Geom2dGcc_Circ2dTanOnRadGeo CircGeo(Ql1,OnCurve,Radius,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); Results(CircGeo); } else { Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); - Geom2dGcc_MyCirc2dTanOnRad CircGeo(Qc1,OnCurve,Radius,Tolerance); + Geom2dGcc_Circ2dTanOnRadGeo CircGeo(Qc1,OnCurve,Radius,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); Results(CircGeo); @@ -190,7 +190,7 @@ Geom2dGcc_Circ2dTanOnRad:: //============================================================================= else { - Geom2dGcc_MyCirc2dTanOnRad CircGeo(point1,OnCurve,Radius,Tolerance); + Geom2dGcc_Circ2dTanOnRadGeo CircGeo(point1,OnCurve,Radius,Tolerance); WellDone = CircGeo.IsDone(); NbrSol = CircGeo.NbSolutions(); Results(CircGeo); @@ -210,7 +210,7 @@ void Geom2dGcc_Circ2dTanOnRad::Results(const GccAna_Circ2dTanOnRad& Circ) } } -void Geom2dGcc_Circ2dTanOnRad::Results(const Geom2dGcc_MyCirc2dTanOnRad& Circ) +void Geom2dGcc_Circ2dTanOnRad::Results(const Geom2dGcc_Circ2dTanOnRadGeo& Circ) { for (Standard_Integer j = 1; j <= NbrSol; j++) { cirsol(j) = Circ.ThisSolution(j); diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cdl new file mode 100644 index 0000000000..9640e86738 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cdl @@ -0,0 +1,267 @@ +-- Created on: 1991-04-03 +-- 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 Circ2dTanOnRadGeo from Geom2dGcc + + ---Purpose: This class implements the algorithms used to + -- create a 2d circle tangent to a 2d entity, + -- centered on a 2d entity and with a given radius. + -- More than one argument must be a curve. + -- The arguments of all construction methods are : + -- - The qualified element for the tangency constrains + -- (QualifiedCirc, QualifiedLin, QualifiedCurvPoints). + -- - The Center element (circle, line, curve). + -- - A real Tolerance. + -- Tolerance is only used in the limits cases. + -- For example : + -- We want to create a circle tangent to an OutsideCurv Cu1 + -- centered on a line OnLine with a radius Radius and with + -- a tolerance Tolerance. + -- If we did not use Tolerance it is impossible to + -- find a solution in the following case : OnLine is + -- outside Cu1. There is no intersection point between Cu1 + -- and OnLine. The distance between the line and the + -- circle is greater than Radius. + -- With Tolerance we will give a solution if the + -- distance between Cu1 and OnLine is lower than or + -- equal Tolerance. + +-- inherits Entity from Standard + +uses Lin2d from gp, + Circ2d from gp, + Pnt2d from gp, + Array1OfCirc2d from TColgp, + Array1OfPnt2d from TColgp, + QualifiedCirc from GccEnt, + QualifiedLin from GccEnt, + Array1OfReal from TColStd, + Array1OfInteger from TColStd, + Position from GccEnt, + Array1OfPosition from GccEnt, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + QCurve from Geom2dGcc, + OffsetCurve from Adaptor3d, + HCurve from Geom2dAdaptor, + CurveToolGeo from Geom2dGcc, + TheIntConicCurveOfGInter from Geom2dInt, + GInter from Geom2dInt + +raises NegativeValue from Standard, + OutOfRange from Standard, + BadQualifier from GccEnt, + NotDone from StdFail + +is + +-- On a line ............................................................. + +Create(Qualified1 : QCurve from Geom2dGcc; + OnLine : Lin2d from gp; + Radius : Real from Standard; + Tolerance : Real from Standard) returns Circ2dTanOnRadGeo + ---Purpose: This methods implements the algorithms used to create + -- 2d Circles tangent to a curve and centered on a 2d Line + -- with a given radius. + -- Tolerance is used to find solution in every limit cases. +raises NegativeValue, BadQualifier; + ---Purpose: raises NegativeValue in case of NegativeRadius. + +-- -- On a circle ........................................................... + +Create(Qualified1 : QCurve from Geom2dGcc; + OnCirc : Circ2d from gp; + Radius : Real from Standard; + Tolerance : Real from Standard) returns Circ2dTanOnRadGeo + ---Purpose: This methods implements the algorithms used to create + -- 2d Circles tangent to a curve and centered on a 2d Circle + -- with a given radius. + -- Tolerance is used to find solution in every limit cases. +raises NegativeValue, BadQualifier; + ---Purpose: raises NegativeValue in case of NegativeRadius. + +-- On a curve ............................................................ + +Create(Qualified1 : QualifiedCirc from GccEnt ; + OnCurv : Curve from Geom2dAdaptor ; + Radius : Real from Standard; + Tolerance : Real from Standard) returns Circ2dTanOnRadGeo + ---Purpose: This methods implements the algorithms used to create + -- 2d Circles tangent to a circle and centered on a 2d curve + -- with a given radius. + -- Tolerance is used to find solution in every limit cases. +raises NegativeValue, BadQualifier; + ---Purpose: raises NegativeValue in case of NegativeRadius. + +Create(Qualified1 : QualifiedLin from GccEnt ; + OnCurv : Curve from Geom2dAdaptor ; + Radius : Real from Standard; + Tolerance : Real from Standard) returns Circ2dTanOnRadGeo + ---Purpose: This methods implements the algorithms used to create + -- 2d Circles tangent to a 2d Line and centered on a 2d curve + -- with a given radius. + -- Tolerance is used to find solution in every limit cases. +raises NegativeValue, BadQualifier; + ---Purpose: raises NegativeValue in case of NegativeRadius. + +Create(Qualified1 : QCurve from Geom2dGcc; + OnCurv : Curve from Geom2dAdaptor; + Radius : Real from Standard; + Tolerance : Real from Standard) returns Circ2dTanOnRadGeo + ---Purpose: This methods implements the algorithms used to create + -- 2d Circles tangent to a 2d curve and centered on a 2d curve + -- with a given radius. + -- Tolerance is used to find solution in every limit cases. +raises NegativeValue, BadQualifier; + ---Purpose: raises NegativeValue in case of NegativeRadius. + +Create(Point1 : Pnt2d from gp ; + OnCurv : Curve from Geom2dAdaptor ; + Radius : Real from Standard; + Tolerance : Real from Standard) returns Circ2dTanOnRadGeo + ---Purpose: This methods implements the algorithms used to create + -- 2d Circles passing through a 2d point and centered on a + -- 2d curve with a given radius. + -- Tolerance is used to find solution in every limit cases. +raises NegativeValue; + ---Purpose: raises NegativeValue in case of NegativeRadius. + +-- -- .................................................................... + +IsDone(me) returns Boolean from Standard +is static; + ---Purpose: This method returns True if the construction + -- algorithm succeeded. + +NbSolutions(me) returns Integer from Standard + ---Purpose: This method returns the number of solutions. +raises NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + +ThisSolution(me ; + Index : Integer from Standard) returns Circ2d from gp + ---Purpose: Returns the solution number Index and raises OutOfRange + -- exception if Index is greater than the number of solutions. + -- Be careful: the Index is only a way to get all the + -- solutions, but is not associated to theses outside the + -- context of the algorithm-object. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions. + +WhichQualifier(me ; + Index : Integer from Standard; + Qualif1 : out Position from GccEnt ) +raises OutOfRange, NotDone +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 ; + Index : Integer from Standard; + ParSol,ParArg : out Real from Standard; + PntSol : out Pnt2d from gp ) + ---Purpose: Returns informations about the tangency point between the + -- result number Index and the first argument. + -- ParSol is the intrinsic parameter of the point on the + -- solution curv. + -- ParArg is the intrinsic parameter of the point on the + -- argument curv. + -- PntSol is the tangency point on the solution curv. + -- PntArg is the tangency point on the argument curv. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions. + +CenterOn3 (me ; + Index : Integer from Standard; + ParArg : out Real from Standard; + PntSol : out Pnt2d from gp ) + ---Purpose: Returns informations about the center (on the curv) + -- of the result. + -- ParArg is the intrinsic parameter of the point on + -- the argument curv. + -- PntSol is the center point of the solution curv. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions. + +IsTheSame1(me ; + Index : Integer from Standard) returns Boolean from Standard + ---Purpose: Returns True if the solution number Index is equal to + -- the first argument and False in the other cases. +raises OutOfRange, NotDone +is static; + ---Purpose: It raises NotDone if the construction algorithm + -- didn't succeed. + -- It raises OutOfRange if Index is greater than the + -- number of solutions. + +fields + + WellDone : Boolean from Standard; + ---Purpose: True if the algorithm succeeded. + + NbrSol : Integer from Standard; + ---Purpose: The number of possible solutions. We have to decide about the + -- status of the multiple solutions... + + cirsol : Array1OfCirc2d from TColgp; + ---Purpose : The solutions. + + qualifier1 : Array1OfPosition from GccEnt; + -- The qualifiers of the first argument. + + TheSame1 : Array1OfInteger from TColStd; + ---Purpose: 1 if the solution and the first argument are the same in the + -- tolerance of Tolerance. + -- 0 in the other cases. + + pnttg1sol : Array1OfPnt2d from TColgp; + ---Purpose: The tangency point between the solution and the first + -- argument on the solution. + + pntcen3 : Array1OfPnt2d from TColgp; + ---Purpose: The center point of the solution on the first argument. + + par1sol : Array1OfReal from TColStd; + ---Purpose: The parameter of the tangency point between the solution + -- and the first argument on thesolution. + + pararg1 : Array1OfReal from TColStd; + ---Purpose: The parameter of the tangency point between the solution + -- and the first argument on the first argument. + + parcen3 : Array1OfReal from TColStd; + ---Purpose: The parameter of the center point of the solution on the + -- second argument. + +end Circ2dTanOnRadGeo; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx new file mode 100644 index 0000000000..f8ca910e0b --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx @@ -0,0 +1,786 @@ +// Copyright (c) 1995-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. + +//======================================================================== +// circulaire tangent a un element de type : - Cercle. + +// - Ligne. + +// - Point. + +// centre sur un deuxieme element de type : - Cercle. + +// - Ligne. + +// de rayon donne : Radius. + +//======================================================================== + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +//========================================================================= +// Cercle tangent : a un cercle Qualified1 (C1). + +// centre : sur une droite OnLine. + +// de rayon : Radius. + +// + +// On initialise le tableau de solutions cirsol ainsi que tous les + +// champs. + +// On elimine en fonction du qualifieur les cas ne presentant pas de + +// solutions. + +// On resoud l equation du second degre indiquant que le point de centre + +// recherche (xc,yc) est a une distance Radius du cercle C1 et + +// sur la droite OnLine. + +// Les solutions sont representees par les cercles : + +// - de centre Pntcen(xc,yc) + +// - de rayon Radius. + +//========================================================================= + +Geom2dGcc_Circ2dTanOnRadGeo:: +Geom2dGcc_Circ2dTanOnRadGeo (const Geom2dGcc_QCurve& Qualified1, + const gp_Lin2d& OnLine , + const Standard_Real Radius , + const Standard_Real Tolerance ): + +//========================================================================= +// Initialisation des champs. + +//========================================================================= + +cirsol(1,8) , +qualifier1(1,8) , +TheSame1(1,8) , +pnttg1sol(1,8) , +pntcen3(1,8) , +par1sol(1,8) , +pararg1(1,8) , +parcen3(1,8) +{ + + //========================================================================= + // Traitement. + + //========================================================================= + + gp_Dir2d dirx(1.0,0.0); + Standard_Real Tol = Abs(Tolerance); + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + WellDone = Standard_False; + NbrSol = 0; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Integer nbrcote1 = 0; + TColStd_Array1OfReal Coef(1,2); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + + if (Radius < 0.0) { Standard_NegativeValue::Raise(); } + else { + if (Qualified1.IsEnclosed()) { + // =========================== + nbrcote1 = 1; + Coef(1) = Radius; + } + else if(Qualified1.IsOutside()) { + // =============================== + nbrcote1 = 1; + Coef(1) = -Radius; + } + else if(Qualified1.IsUnqualified()) { + // =================================== + nbrcote1 = 2; + Coef(1) = Radius; + Coef(2) = -Radius; + } + IntRes2d_Domain D1; + Geom2dInt_TheIntConicCurveOfGInter Intp; + for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1); + Adaptor3d_OffsetCurve C2(HCu1,Coef(jcote1)); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); + Intp.Perform(OnLine,D1,C2,D2,Tol,Tol); + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + NbrSol++; + gp_Pnt2d Center(Intp.Point(i).Value()); + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + qualifier1(NbrSol) = Qualified1.Qualifier(); + TheSame1(NbrSol) = 0; + pararg1(NbrSol) = Intp.Point(i).ParamOnSecond(); + parcen3(NbrSol) = Intp.Point(i).ParamOnFirst(); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pnttg1sol(NbrSol) = gp_Pnt2d(Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol))); + pntcen3(NbrSol) = Center; + } + } + WellDone = Standard_True; + } + } + } +} + +//========================================================================= +// Cercle tangent : a un cercle Qualified1 (C1). + +// centre : sur une droite OnLine. + +// de rayon : Radius. + +// + +// On initialise le tableau de solutions cirsol ainsi que tous les + +// champs. + +// On elimine en fonction du qualifieur les cas ne presentant pas de + +// solutions. + +// On resoud l equation du second degre indiquant que le point de centre + +// recherche (xc,yc) est a une distance Radius du cercle C1 et + +// sur la droite OnLine. + +// Les solutions sont representees par les cercles : + +// - de centre Pntcen(xc,yc) + +// - de rayon Radius. + +//========================================================================= + +Geom2dGcc_Circ2dTanOnRadGeo:: +Geom2dGcc_Circ2dTanOnRadGeo (const Geom2dGcc_QCurve& Qualified1, + const gp_Circ2d& OnCirc , + const Standard_Real Radius , + const Standard_Real Tolerance ): + +//========================================================================= +// Initialisation des champs. + +//========================================================================= + +cirsol(1,8) , +qualifier1(1,8) , +TheSame1(1,8) , +pnttg1sol(1,8) , +pntcen3(1,8) , +par1sol(1,8) , +pararg1(1,8) , +parcen3(1,8) +{ + + //========================================================================= + // Traitement. + + //========================================================================= + + gp_Dir2d dirx(1.0,0.0); + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + Standard_Real Tol = Abs(Tolerance); + Standard_Integer nbrcote1=0; + WellDone = Standard_False; + NbrSol = 0; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + TColStd_Array1OfReal cote1(1,2); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + + if (Radius < 0.0) { + Standard_NegativeValue::Raise(); + } + else { + if (Qualified1.IsEnclosed()) { + // =========================== + nbrcote1 = 1; + cote1(1) = Radius; + } + else if(Qualified1.IsOutside()) { + // =============================== + nbrcote1 = 1; + cote1(1) = -Radius; + } + else if(Qualified1.IsUnqualified()) { + // =================================== + nbrcote1 = 2; + cote1(1) = Radius; + cote1(2) = -Radius; + } + IntRes2d_Domain D1(ElCLib::Value(0.,OnCirc), 0.,Tol, + ElCLib::Value(2.*M_PI,OnCirc),2.*M_PI,Tol); + D1.SetEquivalentParameters(0.,2.*M_PI); + Geom2dInt_TheIntConicCurveOfGInter Intp; + for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1); + Adaptor3d_OffsetCurve C2(HCu1,cote1(jcote1)); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); + Intp.Perform(OnCirc,D1,C2,D2,Tol,Tol); + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + NbrSol++; + gp_Pnt2d Center(Intp.Point(i).Value()); + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + qualifier1(NbrSol) = Qualified1.Qualifier(); + TheSame1(NbrSol) = 0; + pararg1(NbrSol) = Intp.Point(i).ParamOnSecond(); + parcen3(NbrSol) = Intp.Point(i).ParamOnFirst(); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pnttg1sol(NbrSol) = gp_Pnt2d(Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol))); + pntcen3(NbrSol) = Center; + } + } + WellDone = Standard_True; + } + } + } +} + +//========================================================================= +// Cercle tangent : a un cercle Qualified1 (C1). + +// centre : sur une droite OnLine. + +// de rayon : Radius. + +// + +// On initialise le tableau de solutions cirsol ainsi que tous les + +// champs. + +// On elimine en fonction du qualifieur les cas ne presentant pas de + +// solutions. + +// On resoud l equation du second degre indiquant que le point de centre + +// recherche (xc,yc) est a une distance Radius du cercle C1 et + +// sur la droite OnLine. + +// Les solutions sont representees par les cercles : + +// - de centre Pntcen(xc,yc) + +// - de rayon Radius. + +//========================================================================= + +Geom2dGcc_Circ2dTanOnRadGeo:: +Geom2dGcc_Circ2dTanOnRadGeo (const GccEnt_QualifiedCirc& Qualified1, + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Radius , + const Standard_Real Tolerance ): + +//========================================================================= +// Initialisation des champs. + +//========================================================================= + +cirsol(1,8) , +qualifier1(1,8) , +TheSame1(1,8) , +pnttg1sol(1,8) , +pntcen3(1,8) , +par1sol(1,8) , +pararg1(1,8) , +parcen3(1,8) +{ + + //========================================================================= + // Traitement. + + //========================================================================= + + gp_Dir2d dirx(1.0,0.0); + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + Standard_Real Tol = Abs(Tolerance); + Standard_Integer nbrcote1=0; + WellDone = Standard_False; + NbrSol = 0; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + TColStd_Array1OfReal cote1(1,2); + gp_Circ2d C1 = Qualified1.Qualified(); + gp_Pnt2d center1(C1.Location()); + Standard_Real R1 = C1.Radius(); + + if (Radius < 0.0) { + Standard_NegativeValue::Raise(); + } + else { + if (Qualified1.IsEnclosed()) { + // =========================== + nbrcote1 = 1; + cote1(1) = Radius; + } + else if(Qualified1.IsOutside()) { + // =============================== + nbrcote1 = 1; + cote1(1) = -Radius; + } + else if(Qualified1.IsUnqualified()) { + // =================================== + nbrcote1 = 2; + cote1(1) = Radius; + cote1(2) = -Radius; + } + Geom2dInt_TheIntConicCurveOfGInter Intp; + for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + gp_Circ2d Circ(C1.XAxis(),R1 + cote1(jcote1)); + IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, + ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol); + D1.SetEquivalentParameters(0.,2.*M_PI); + firstparam = Max(Geom2dGcc_CurveTool::FirstParameter(OnCurv),thefirst); + lastparam = Min(Geom2dGcc_CurveTool::LastParameter(OnCurv),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveTool::Value(OnCurv,firstparam),firstparam,Tol, + Geom2dGcc_CurveTool::Value(OnCurv,lastparam),lastparam,Tol); + Intp.Perform(Circ,D1,OnCurv,D2,Tol,Tol); + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + NbrSol++; + gp_Pnt2d Center(Intp.Point(i).Value()); + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + Standard_Real distcc1 = Center.Distance(center1); + if (!Qualified1.IsUnqualified()) { + qualifier1(NbrSol) = Qualified1.Qualifier(); + } + else if (Abs(distcc1+Radius-R1) < Tol) { + qualifier1(NbrSol) = GccEnt_enclosed; + } + else if (Abs(distcc1-R1-Radius) < Tol) { + qualifier1(NbrSol) = GccEnt_outside; + } + else { qualifier1(NbrSol) = GccEnt_enclosing; } + TheSame1(NbrSol) = 0; + pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); + parcen3(NbrSol) = Intp.Point(i).ParamOnSecond(); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),C1); + pntcen3(NbrSol) = Center; + } + } + WellDone = Standard_True; + } + } + } +} + +//========================================================================= +// Cercle tangent : a un cercle Qualified1 (C1). + +// centre : sur une droite OnLine. + +// de rayon : Radius. + +// + +// On initialise le tableau de solutions cirsol ainsi que tous les + +// champs. + +// On elimine en fonction du qualifieur les cas ne presentant pas de + +// solutions. + +// On resoud l equation du second degre indiquant que le point de centre + +// recherche (xc,yc) est a une distance Radius du cercle C1 et + +// sur la droite OnLine. + +// Les solutions sont representees par les cercles : + +// - de centre Pntcen(xc,yc) + +// - de rayon Radius. + +//========================================================================= + +Geom2dGcc_Circ2dTanOnRadGeo:: +Geom2dGcc_Circ2dTanOnRadGeo (const GccEnt_QualifiedLin& Qualified1, + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Radius , + const Standard_Real Tolerance ): + +//========================================================================= +// Initialisation des champs. + +//========================================================================= + +cirsol(1,8) , +qualifier1(1,8) , +TheSame1(1,8) , +pnttg1sol(1,8) , +pntcen3(1,8) , +par1sol(1,8) , +pararg1(1,8) , +parcen3(1,8) +{ + + //========================================================================= + // Traitement. + + //========================================================================= + + gp_Dir2d dirx(1.0,0.0); + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + NbrSol = 0; + if (!(Qualified1.IsEnclosed() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + Standard_Integer nbrcote1=0; + TColStd_Array1OfReal cote1(1,2); + gp_Lin2d L1 = Qualified1.Qualified(); + gp_Pnt2d origin1(L1.Location()); + gp_Dir2d dir1(L1.Direction()); + gp_Dir2d norm1(-dir1.Y(),dir1.X()); + + if (Radius < 0.0) { + Standard_NegativeValue::Raise(); + } + else { + if (Qualified1.IsEnclosed()) { + // =========================== + nbrcote1 = 1; + cote1(1) = Radius; + } + else if(Qualified1.IsOutside()) { + // =============================== + nbrcote1 = 1; + cote1(1) = -Radius; + } + else if(Qualified1.IsUnqualified()) { + // =================================== + nbrcote1 = 2; + cote1(1) = Radius; + cote1(2) = -Radius; + } + Geom2dInt_TheIntConicCurveOfGInter Intp; + for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + gp_Pnt2d Point(dir1.XY()+cote1(jcote1)*norm1.XY()); + gp_Lin2d Line(Point,dir1); // ligne avec deport. + IntRes2d_Domain D1; + firstparam = Max(Geom2dGcc_CurveTool::FirstParameter(OnCurv),thefirst); + lastparam = Min(Geom2dGcc_CurveTool::LastParameter(OnCurv),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveTool::Value(OnCurv,firstparam),firstparam,Tol, + Geom2dGcc_CurveTool::Value(OnCurv,lastparam),lastparam,Tol); + Intp.Perform(Line,D1,OnCurv,D2,Tol,Tol); + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + NbrSol++; + gp_Pnt2d Center(Intp.Point(i).Value()); + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + gp_Dir2d dc1(origin1.XY()-Center.XY()); + if (!Qualified1.IsUnqualified()) { + qualifier1(NbrSol) = Qualified1.Qualifier(); + } + else if (dc1.Dot(norm1) > 0.0) { + qualifier1(NbrSol) = GccEnt_outside; + } + else { qualifier1(NbrSol) = GccEnt_enclosed; } + TheSame1(NbrSol) = 0; + pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); + parcen3(NbrSol) = Intp.Point(i).ParamOnSecond(); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),L1); + pntcen3(NbrSol) = Center; + } + } + WellDone = Standard_True; + } + } + } +} + +//========================================================================= +// Cercle tangent : a un cercle Qualified1 (C1). + +// centre : sur une droite OnLine. + +// de rayon : Radius. + +// + +// On initialise le tableau de solutions cirsol ainsi que tous les + +// champs. + +// On elimine en fonction du qualifieur les cas ne presentant pas de + +// solutions. + +// On resoud l equation du second degre indiquant que le point de centre + +// recherche (xc,yc) est a une distance Radius du cercle C1 et + +// sur la droite OnLine. + +// Les solutions sont representees par les cercles : + +// - de centre Pntcen(xc,yc) + +// - de rayon Radius. + +//========================================================================= + +Geom2dGcc_Circ2dTanOnRadGeo:: +Geom2dGcc_Circ2dTanOnRadGeo (const Geom2dGcc_QCurve& Qualified1, + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Radius , + const Standard_Real Tolerance ): + +//========================================================================= +// Initialisation des champs. + +//========================================================================= + +cirsol(1,8) , +qualifier1(1,8) , +TheSame1(1,8) , +pnttg1sol(1,8) , +pntcen3(1,8) , +par1sol(1,8) , +pararg1(1,8) , +parcen3(1,8) +{ + + //========================================================================= + // Traitement. + + //========================================================================= + + gp_Dir2d dirx(1.0,0.0); + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + Standard_Real Tol = Abs(Tolerance); + Standard_Integer nbrcote1=0; + WellDone = Standard_False; + NbrSol = 0; + if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || + Qualified1.IsOutside() || Qualified1.IsUnqualified())) { + GccEnt_BadQualifier::Raise(); + return; + } + TColStd_Array1OfReal cote1(1,2); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + + if (Radius < 0.0) { + Standard_NegativeValue::Raise(); + } + else { + if (Qualified1.IsEnclosed()) { + // =========================== + nbrcote1 = 1; + cote1(1) = Radius; + } + else if(Qualified1.IsOutside()) { + // =============================== + nbrcote1 = 1; + cote1(1) = -Radius; + } + else if(Qualified1.IsUnqualified()) { + // =================================== + nbrcote1 = 2; + cote1(1) = Radius; + cote1(2) = -Radius; + } + Geom2dInt_GInter Intp; + for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1); + Adaptor3d_OffsetCurve C1(HCu1,cote1(jcote1)); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C1),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C1),thelast); + IntRes2d_Domain D1(Geom2dGcc_CurveToolGeo::Value(C1,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C1,lastparam),lastparam,Tol); + Handle(Geom2dAdaptor_HCurve) HOnCurv = new Geom2dAdaptor_HCurve(OnCurv); + Adaptor3d_OffsetCurve C2(HOnCurv); + firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); + lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); + Intp.Perform(C1,D1,C2,D2,Tol,Tol); + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + NbrSol++; + gp_Pnt2d Center(Intp.Point(i).Value()); + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + qualifier1(NbrSol) = Qualified1.Qualifier(); + TheSame1(NbrSol) = 0; + pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); + parcen3(NbrSol) = Intp.Point(i).ParamOnSecond(); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pnttg1sol(NbrSol) = gp_Pnt2d(Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol))); + pntcen3(NbrSol) = Center; + } + } + WellDone = Standard_True; + } + } + } +} + +//========================================================================= +// Cercle tangent : a un cercle Qualified1 (C1). + +// centre : sur une droite OnLine. + +// de rayon : Radius. + +// + +// On initialise le tableau de solutions cirsol ainsi que tous les + +// champs. + +// On elimine en fonction du qualifieur les cas ne presentant pas de + +// solutions. + +// On resoud l equation du second degre indiquant que le point de centre + +// recherche (xc,yc) est a une distance Radius du cercle C1 et + +// sur la droite OnLine. + +// Les solutions sont representees par les cercles : + +// - de centre Pntcen(xc,yc) + +// - de rayon Radius. + +//========================================================================= + +Geom2dGcc_Circ2dTanOnRadGeo:: +Geom2dGcc_Circ2dTanOnRadGeo (const gp_Pnt2d& Point1 , + const Geom2dAdaptor_Curve& OnCurv , + const Standard_Real Radius , + const Standard_Real Tolerance ): + +//========================================================================= +// Initialisation des champs. + +//========================================================================= + +cirsol(1,8) , +qualifier1(1,8) , +TheSame1(1,8) , +pnttg1sol(1,8) , +pntcen3(1,8) , +par1sol(1,8) , +pararg1(1,8) , +parcen3(1,8) +{ + + //========================================================================= + // Traitement. + + //========================================================================= + + gp_Dir2d dirx(1.0,0.0); + Standard_Real thefirst = -100000.; + Standard_Real thelast = 100000.; + Standard_Real firstparam; + Standard_Real lastparam; + Standard_Real Tol = Abs(Tolerance); + WellDone = Standard_False; + NbrSol = 0; + + if (Radius < 0.0) { + Standard_NegativeValue::Raise(); + } + else { + // gp_Dir2d Dir(-y1dir,x1dir); + gp_Circ2d Circ(gp_Ax2d(Point1,gp_Dir2d(1.,0.)),Radius); + IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, + ElCLib::Value(2.*M_PI,Circ),2*M_PI,Tol); + D1.SetEquivalentParameters(0.,2.*M_PI); + firstparam = Max(Geom2dGcc_CurveTool::FirstParameter(OnCurv),thefirst); + lastparam = Min(Geom2dGcc_CurveTool::LastParameter(OnCurv),thelast); + IntRes2d_Domain D2(Geom2dGcc_CurveTool::Value(OnCurv,firstparam),firstparam,Tol, + Geom2dGcc_CurveTool::Value(OnCurv,lastparam),lastparam,Tol); + Geom2dInt_TheIntConicCurveOfGInter Intp(Circ,D1,OnCurv,D2,Tol,Tol); + if (Intp.IsDone()) { + if (!Intp.IsEmpty()) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + NbrSol++; + gp_Pnt2d Center(Intp.Point(i).Value()); + cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); + // ======================================================= + qualifier1(NbrSol) = GccEnt_noqualifier; + TheSame1(NbrSol) = 0; + pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); + parcen3(NbrSol) = Intp.Point(i).ParamOnSecond(); + par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), + pnttg1sol(NbrSol)); + pnttg1sol(NbrSol) = Point1; + pntcen3(NbrSol) = Center; + } + WellDone = Standard_True; + } + } + } +} + +//========================================================================= + +Standard_Boolean Geom2dGcc_Circ2dTanOnRadGeo:: +IsDone () const { return WellDone; } + +Standard_Integer Geom2dGcc_Circ2dTanOnRadGeo:: +NbSolutions () const { return NbrSol; } + +gp_Circ2d Geom2dGcc_Circ2dTanOnRadGeo:: +ThisSolution (const Standard_Integer Index) const +{ + + if (Index > NbrSol || Index <= 0) + Standard_OutOfRange::Raise(); + + return cirsol(Index); +} + +void Geom2dGcc_Circ2dTanOnRadGeo:: +WhichQualifier(const Standard_Integer Index , + GccEnt_Position& Qualif1 ) const +{ + if (!WellDone) { StdFail_NotDone::Raise(); } + else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } + else { + Qualif1 = qualifier1(Index); + } +} + +void Geom2dGcc_Circ2dTanOnRadGeo:: +Tangency1 (const Standard_Integer Index, + Standard_Real& ParSol, + Standard_Real& ParArg, + gp_Pnt2d& PntSol) const{ + if (!WellDone) { + StdFail_NotDone::Raise(); + } + else if (Index <= 0 ||Index > NbrSol) { + Standard_OutOfRange::Raise(); + } + else { + ParSol = par1sol(Index); + ParArg = pararg1(Index); + PntSol = gp_Pnt2d(pnttg1sol(Index)); + } +} + +void Geom2dGcc_Circ2dTanOnRadGeo:: +CenterOn3 (const Standard_Integer Index, + Standard_Real& ParArg, + gp_Pnt2d& PntSol) const { + if (!WellDone) { + StdFail_NotDone::Raise(); + } + else if (Index <= 0 ||Index > NbrSol) { + Standard_OutOfRange::Raise(); + } + else { + ParArg = parcen3(Index); + PntSol = pnttg1sol(Index); + } +} + +Standard_Boolean Geom2dGcc_Circ2dTanOnRadGeo:: +IsTheSame1 (const Standard_Integer Index) const +{ + if (!WellDone) StdFail_NotDone::Raise(); + if (Index <= 0 ||Index > NbrSol) Standard_OutOfRange::Raise(); + + if (TheSame1(Index) == 0) + return Standard_False; + + return Standard_True; +} diff --git a/src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cdl b/src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cdl new file mode 100644 index 0000000000..a6c01b17ab --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cdl @@ -0,0 +1,127 @@ +-- Created on: 1992-06-04 +-- Created by: Jacques GOUSSARD +-- 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. + +class CurveToolGeo from Geom2dGcc + +uses Pnt2d from gp, + Vec2d from gp, + Lin2d from gp, + Circ2d from gp, + Elips2d from gp, + Parab2d from gp, + Hypr2d from gp, + CurveType from GeomAbs, + Shape from GeomAbs, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + OffsetCurve from Adaptor3d + +is + + TheType(myclass; C: OffsetCurve from Adaptor3d ) + returns CurveType from GeomAbs; + + Line(myclass; C: OffsetCurve from Adaptor3d) + ---Purpose: Returns the Lin2d from gp corresponding to the curve C. + -- This method is called only when TheType returns + -- IntCurve_Lin. + returns Lin2d from gp; + + Circle(myclass; C: OffsetCurve from Adaptor3d) + ---Purpose: Returns the Circ2d from gp corresponding to the curve C. + -- This method is called only when TheType returns + -- IntCurve_Cir. + returns Circ2d from gp; + + Ellipse(myclass; C: OffsetCurve from Adaptor3d) + ---Purpose: Returns the Elips2d from gp corresponding to the curve C. + -- This method is called only when TheType returns + -- IntCurve_Eli. + returns Elips2d from gp; + + Parabola(myclass; C: OffsetCurve from Adaptor3d) + ---Purpose: Returns the Parab2d from gp corresponding to the curve C. + -- This method is called only when TheType returns + -- IntCurve_Prb. + returns Parab2d from gp; + + Hyperbola(myclass; C: OffsetCurve from Adaptor3d) + ---Purpose: Returns the Hypr2d from gp corresponding to the curve C. + -- This method is called only when TheType returns + -- IntCurve_Hpr. + returns Hypr2d from gp; + +-- The following method are used only when TheType returns IntCurve_Other. + + FirstParameter(myclass;C: OffsetCurve from Adaptor3d) + returns Real; + + LastParameter(myclass;C: OffsetCurve from Adaptor3d) + returns Real; + + EpsX (myclass ; + C : OffsetCurve from Adaptor3d ; + Tol : Real from Standard) + returns Real; + + NbSamples(myclass ; + C : OffsetCurve from Adaptor3d) + returns Integer; + + Value (myclass ; + C : OffsetCurve from Adaptor3d; + X : Real ) + returns Pnt2d from gp; + + D1 (myclass; C : OffsetCurve from Adaptor3d ; + U : Real ; + P : out Pnt2d ; + T : out Vec2d ); + + D2 (myclass; C : OffsetCurve from Adaptor3d ; + U : Real ; + P : out Pnt2d ; + T,N : out Vec2d ); + + IsComposite(myclass; C:OffsetCurve from Adaptor3d) + + returns Boolean from Standard; + +-- The following methods are used only when IsComposite returns True. + + + GetIntervals(myclass ; C:OffsetCurve from Adaptor3d) returns Integer from Standard; + ---Purpose : Outputs the number of interval of continuity C1 of + -- the curve + -- used if Type == Composite. + + GetInterval (myclass; C : OffsetCurve from Adaptor3d + ; Index : Integer from Standard + ; U1, U2 : out Real from Standard); + ---Purpose : Outputs the bounds of interval of index + -- used if Type == Composite. + + SetCurrentInterval (myclass; C: in out OffsetCurve from Adaptor3d + ; Index : Integer from Standard); + ---Purpose : Set the current valid interval of index + -- inside which the computations will be done + -- (used if Type == Composite). + +end CurveToolGeo; + + + + diff --git a/src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cxx b/src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cxx new file mode 100644 index 0000000000..85bad409b7 --- /dev/null +++ b/src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cxx @@ -0,0 +1,147 @@ +// Copyright (c) 1995-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 +#include +#include +#include +#include +#include + +#include +#include + +#include + +GeomAbs_CurveType Geom2dGcc_CurveToolGeo:: +TheType(const Adaptor3d_OffsetCurve& ) { + return GeomAbs_OtherCurve; +} + +gp_Lin2d Geom2dGcc_CurveToolGeo:: +Line (const Adaptor3d_OffsetCurve& ) { + cout << "Not implemented" << endl; + return gp_Lin2d(); +} + +gp_Circ2d Geom2dGcc_CurveToolGeo:: +Circle (const Adaptor3d_OffsetCurve& ) { + cout << "Not implemented" << endl; + return gp_Circ2d(); +} + +gp_Elips2d Geom2dGcc_CurveToolGeo:: +Ellipse (const Adaptor3d_OffsetCurve& ) { + cout << "Not implemented" << endl; + return gp_Elips2d(); +} + +gp_Parab2d Geom2dGcc_CurveToolGeo:: +Parabola (const Adaptor3d_OffsetCurve& ) { + cout << "Not implemented" << endl; + return gp_Parab2d(); +} + +gp_Hypr2d Geom2dGcc_CurveToolGeo:: +Hyperbola (const Adaptor3d_OffsetCurve& ) { + cout << "Not implemented" << endl; + return gp_Hypr2d(); +} + +Standard_Real +Geom2dGcc_CurveToolGeo::EpsX (const Adaptor3d_OffsetCurve& /*C*/, + const Standard_Real Tol) { + return Tol; +} + +Standard_Integer +Geom2dGcc_CurveToolGeo::NbSamples (const Adaptor3d_OffsetCurve& C) { + GeomAbs_CurveType typC = C.GetType(); + Standard_Integer nbs = 20; + if(typC == GeomAbs_Line) + nbs = 2; + else if(typC == GeomAbs_BezierCurve) + nbs = 3 + C.Bezier()->NbPoles(); + else if(typC == GeomAbs_BSplineCurve) { + Handle(Geom2d_BSplineCurve) BSC = C.BSpline(); + nbs = BSC->NbKnots(); + nbs*= BSC->Degree(); + if(nbs < 2) nbs=2; + } + return(nbs); +} + +Standard_Real +Geom2dGcc_CurveToolGeo::FirstParameter (const Adaptor3d_OffsetCurve& C) { + return C.FirstParameter(); +} + +Standard_Real +Geom2dGcc_CurveToolGeo::LastParameter (const Adaptor3d_OffsetCurve& C) { + return C.LastParameter(); +} + +gp_Pnt2d +Geom2dGcc_CurveToolGeo::Value (const Adaptor3d_OffsetCurve& C, + const Standard_Real U) { + + return C.Value(U); +} + +void Geom2dGcc_CurveToolGeo::D1(const Adaptor3d_OffsetCurve& C, + const Standard_Real U, + gp_Pnt2d& P, + gp_Vec2d& T) { + C.D1(U,P,T); +} + +void Geom2dGcc_CurveToolGeo::D2(const Adaptor3d_OffsetCurve& C, + const Standard_Real U, + gp_Pnt2d& P, + gp_Vec2d& T, + gp_Vec2d& N) { + C.D2(U,P,T,N); +} + +Standard_Boolean Geom2dGcc_CurveToolGeo:: +IsComposite (const Adaptor3d_OffsetCurve& ) { + return Standard_False; +} + +Standard_Integer Geom2dGcc_CurveToolGeo:: +GetIntervals (const Adaptor3d_OffsetCurve& ) { + cout << "Not implemented" << endl; + return 0; +} + +void Geom2dGcc_CurveToolGeo:: +GetInterval (const Adaptor3d_OffsetCurve& , + const Standard_Integer , + Standard_Real& , + Standard_Real& ) { + cout << "Not implemented" << endl; +} + +void Geom2dGcc_CurveToolGeo:: +SetCurrentInterval ( Adaptor3d_OffsetCurve& , + const Standard_Integer ) { + cout << "Not implemented" << endl; +} + diff --git a/src/TKGeomAlgo/PACKAGES b/src/TKGeomAlgo/PACKAGES index 2104279d5b..d80a909504 100755 --- a/src/TKGeomAlgo/PACKAGES +++ b/src/TKGeomAlgo/PACKAGES @@ -17,7 +17,6 @@ GccAna GccEnt GccInt GccIter -GccGeo HatchGen Geom2dHatch Law