From 578ce4bebf7b8bc7c265869977c16097f789720b Mon Sep 17 00:00:00 2001 From: dln Date: Fri, 28 Mar 2014 09:35:15 +0400 Subject: [PATCH] 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. --- adm/UDLIST | 1 - src/GccGeo/GccGeo.cdl | 55 - src/GccGeo/GccGeo_Circ2d2TanOn.gxx | 1077 ----------------- src/GccGeo/GccGeo_Circ2dTanOnRad.gxx | 777 ------------ src/GccGeo/GccGeo_CurvePGTool.gxx | 148 --- src/GccGeo/GccGeo_ParGenCurve.cdl | 58 - src/GccGeo/GccGeo_ParGenCurve.gxx | 122 -- src/Geom2dGcc/Geom2dGcc.cdl | 68 +- src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cdl | 6 +- src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cxx | 18 +- .../Geom2dGcc_Circ2d2TanOnGeo.cdl} | 52 +- src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx | 1074 ++++++++++++++++ src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cdl | 4 +- src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cxx | 16 +- .../Geom2dGcc_Circ2d2TanRadGeo.cdl} | 53 +- .../Geom2dGcc_Circ2d2TanRadGeo.cxx} | 234 ++-- src/Geom2dGcc/Geom2dGcc_Circ2dTanCen.cxx | 4 +- .../Geom2dGcc_Circ2dTanCenGeo.cdl} | 23 +- .../Geom2dGcc_Circ2dTanCenGeo.cxx} | 124 +- src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRad.cdl | 30 +- src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRad.cxx | 12 +- .../Geom2dGcc_Circ2dTanOnRadGeo.cdl} | 58 +- src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx | 786 ++++++++++++ .../Geom2dGcc_CurveToolGeo.cdl} | 47 +- src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cxx | 147 +++ src/TKGeomAlgo/PACKAGES | 1 - 26 files changed, 2361 insertions(+), 2634 deletions(-) delete mode 100644 src/GccGeo/GccGeo.cdl delete mode 100644 src/GccGeo/GccGeo_Circ2d2TanOn.gxx delete mode 100644 src/GccGeo/GccGeo_Circ2dTanOnRad.gxx delete mode 100644 src/GccGeo/GccGeo_CurvePGTool.gxx delete mode 100644 src/GccGeo/GccGeo_ParGenCurve.cdl delete mode 100644 src/GccGeo/GccGeo_ParGenCurve.gxx rename src/{GccGeo/GccGeo_Circ2d2TanOn.cdl => Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cdl} (90%) create mode 100644 src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx rename src/{GccGeo/GccGeo_Circ2d2TanRad.cdl => Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cdl} (89%) rename src/{GccGeo/GccGeo_Circ2d2TanRad.gxx => Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx} (81%) rename src/{GccGeo/GccGeo_Circ2dTanCen.cdl => Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cdl} (91%) rename src/{GccGeo/GccGeo_Circ2dTanCen.gxx => Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx} (54%) rename src/{GccGeo/GccGeo_Circ2dTanOnRad.cdl => Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cdl} (88%) create mode 100644 src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx rename src/{GccGeo/GccGeo_CurvePGTool.cdl => Geom2dGcc/Geom2dGcc_CurveToolGeo.cdl} (74%) create mode 100644 src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cxx 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.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_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.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 CurveToolGeo; -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 Circ2d2TanOnGeo; -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 Circ2d2TanRadGeo; -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 Circ2dTanCenGeo; + +class Circ2dTanOnRadGeo; 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); - + (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/GccGeo/GccGeo_Circ2d2TanOn.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cdl similarity index 90% rename from src/GccGeo/GccGeo_Circ2d2TanOn.cdl rename to src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cdl index 60b70808be..6e8209525e 100644 --- a/src/GccGeo/GccGeo_Circ2d2TanOn.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cdl @@ -14,22 +14,7 @@ -- 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) - +class Circ2d2TanOnGeo from Geom2dGcc ---Purpose: This class implements the algorithms used to -- create 2d circles TANgent to 2 entities and @@ -55,7 +40,14 @@ uses Pnt2d from gp, Array1OfInteger from TColStd, Array1OfReal from TColStd, Position from GccEnt, - Array1OfPosition 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, @@ -65,8 +57,8 @@ is Create(Qualified1 : QualifiedCirc from GccEnt ; Qualified2 : QualifiedCirc from GccEnt ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn + 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. @@ -74,8 +66,8 @@ raises BadQualifier from GccEnt; Create(Qualified1 : QualifiedCirc from GccEnt ; Qualified2 : QualifiedLin from GccEnt ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn + 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. @@ -83,8 +75,8 @@ raises BadQualifier from GccEnt; Create(Qualified1 : QualifiedCirc from GccEnt ; Point2 : Pnt2d from gp ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn + 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. @@ -92,8 +84,8 @@ raises BadQualifier from GccEnt; Create(Qualified1 : QualifiedLin from GccEnt ; Qualified2 : QualifiedLin from GccEnt ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn + 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. @@ -101,8 +93,8 @@ raises BadQualifier from GccEnt; Create(Qualified1 : QualifiedLin from GccEnt ; Qualified2 : Pnt2d from gp ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn + 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. @@ -110,8 +102,8 @@ raises BadQualifier from GccEnt; Create(Point1 : Pnt2d from gp ; Point2 : Pnt2d from gp ; - OnCurv : TheCurve ; - Tolerance : Real from Standard) returns Circ2d2TanOn ; + 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. @@ -298,4 +290,4 @@ fields ---Purpose: The parameter of the center point of the solution on the -- second argument. -end Circ2d2TanOn; +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/GccGeo/GccGeo_Circ2d2TanRad.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cdl similarity index 89% rename from src/GccGeo/GccGeo_Circ2d2TanRad.cdl rename to src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cdl index e535a2399b..91d1a188b5 100644 --- a/src/GccGeo/GccGeo_Circ2d2TanRad.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cdl @@ -14,23 +14,8 @@ -- 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) - +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. @@ -64,7 +49,15 @@ uses Pnt2d from gp, Array1OfReal from TColStd, Array1OfInteger from TColStd, Position from GccEnt, - Array1OfPosition 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, @@ -73,40 +66,40 @@ raises OutOfRange from Standard, is -Create(Qualified1 : QualifiedCirc from GccEnt ; - Qualified2 : TheQCurve ; +Create(Qualified1 : QualifiedCirc from GccEnt; + Qualified2 : QCurve from Geom2dGcc; Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2d2TanRad + 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 : TheQCurve ; +Create(Qualified1 : QualifiedLin from GccEnt; + Qualified2 : QCurve from Geom2dGcc; Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2d2TanRad + 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 : TheQCurve ; - Qualified2 : TheQCurve ; +Create(Qualified1 : QCurve from Geom2dGcc; + Qualified2 : QCurve from Geom2dGcc; Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2d2TanRad + 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 : TheQCurve ; +Create(Qualified1 : QCurve from Geom2dGcc; Point2 : Pnt2d from gp ; Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2d2TanRad + 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. @@ -265,4 +258,4 @@ fields ---Purpose: The parameter of the tangency point between the solution -- and the second argument on the second argument. -end Circ2d2TanRad; +end Circ2d2TanRadGeo; diff --git a/src/GccGeo/GccGeo_Circ2d2TanRad.gxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx similarity index 81% rename from src/GccGeo/GccGeo_Circ2d2TanRad.gxx rename to src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx index c03b3e9d8c..c2b92c1366 100644 --- a/src/GccGeo/GccGeo_Circ2d2TanRad.gxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx @@ -12,6 +12,8 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include + #include #include #include @@ -24,6 +26,12 @@ #include #include +#include +#include +#include +#include +#include + // circulaire tant a une courbe et une droite ,de rayon donne //============================================================== @@ -38,11 +46,11 @@ // On remplit les champs. + //======================================================================== -GccGeo_Circ2d2TanRad:: -GccGeo_Circ2d2TanRad (const GccEnt_QualifiedLin& Qualified1, - const TheQCurve& Qualified2, - const Standard_Real Radius , - const Standard_Real Tolerance ): +Geom2dGcc_Circ2d2TanRadGeo:: +Geom2dGcc_Circ2d2TanRadGeo (const GccEnt_QualifiedLin& Qualified1, + const Geom2dGcc_QCurve& Qualified2, + const Standard_Real Radius , + const Standard_Real Tolerance ): //======================================================================== // initialisation des champs. + @@ -92,7 +100,7 @@ pararg2(1,16) Standard_Real lyloc = (L1.Location()).Y(); gp_Pnt2d origin1(lxloc,lyloc); gp_Dir2d normL1(-y1dir,x1dir); - TheCurve Cu2= Qualified2.Qualified(); + Geom2dAdaptor_Curve Cu2= Qualified2.Qualified(); if (Radius < 0.0) { Standard_NegativeValue::Raise(); } else { if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { @@ -170,13 +178,13 @@ pararg2(1,16) 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); + 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++) { @@ -198,7 +206,7 @@ pararg2(1,16) 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)); + pnttg2sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu2,pararg2(NbrSol)); par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), pnttg1sol(NbrSol)); par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), @@ -226,11 +234,11 @@ pararg2(1,16) // On remplit les champs. + //======================================================================== -GccGeo_Circ2d2TanRad:: -GccGeo_Circ2d2TanRad (const GccEnt_QualifiedCirc& Qualified1, - const TheQCurve& Qualified2, - const Standard_Real Radius , - const Standard_Real Tolerance ): +Geom2dGcc_Circ2d2TanRadGeo:: +Geom2dGcc_Circ2d2TanRadGeo (const GccEnt_QualifiedCirc& Qualified1, + const Geom2dGcc_QCurve& Qualified2, + const Standard_Real Radius , + const Standard_Real Tolerance ): //======================================================================== // initialisation des champs. + @@ -274,7 +282,7 @@ pararg2(1,16) } gp_Circ2d C1 = Qualified1.Qualified(); gp_Pnt2d center1(C1.Location()); - TheCurve Cu2 = Qualified2.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); if (Radius < 0.0) { Standard_NegativeValue::Raise(); } else { if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { @@ -347,19 +355,19 @@ pararg2(1,16) cote2(2) = -Radius; } Standard_Real R1 = C1.Radius(); - TheIntConicCurve Intp; + 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(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); + 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()) { @@ -391,7 +399,7 @@ pararg2(1,16) 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)); + pnttg2sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu2,pararg2(NbrSol)); par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), pnttg1sol(NbrSol)); par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), @@ -419,11 +427,11 @@ pararg2(1,16) // On remplit les champs. + //======================================================================== -GccGeo_Circ2d2TanRad:: -GccGeo_Circ2d2TanRad (const TheQCurve& Qualified1, - const gp_Pnt2d& Point2 , - const Standard_Real Radius , - const Standard_Real Tolerance ): +Geom2dGcc_Circ2d2TanRadGeo:: +Geom2dGcc_Circ2d2TanRadGeo (const Geom2dGcc_QCurve& Qualified1, + const gp_Pnt2d& Point2 , + const Standard_Real Radius , + const Standard_Real Tolerance ): //======================================================================== // initialisation des champs. + @@ -461,7 +469,7 @@ pararg2(1,16) GccEnt_BadQualifier::Raise(); return; } - TheCurve Cu1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); if (Radius < 0.0) { Standard_NegativeValue::Raise(); } else { if (Qualified1.IsEnclosed()) { @@ -484,14 +492,14 @@ pararg2(1,16) 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; + Geom2dInt_TheIntConicCurveOfGInter 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); + 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()) { @@ -506,7 +514,7 @@ pararg2(1,16) TheSame2(NbrSol) = 0; pararg1(NbrSol) = Intp.Point(i).ParamOnSecond(); pararg2(NbrSol) = 0.; - pnttg1sol(NbrSol) = TheTool::Value(Cu1,pararg1(NbrSol)); + pnttg1sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol)); pnttg2sol(NbrSol) = Point2; par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), pnttg1sol(NbrSol)); @@ -520,19 +528,19 @@ pararg2(1,16) } } -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) +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; + aInitStepV = (theVmax - theVmin)/2.0; Standard_Real aStepU = aInitStepU, aStepV = aInitStepV; @@ -542,8 +550,8 @@ static void PrecRoot(const TheParGenCurve& theC1, gp_Pnt2d aP1, aP2; gp_Vec2d aD1, aD2; - TheCurvePGTool::D1(theC1, theU0, aP1, aD1); - TheCurvePGTool::D1(theC2, theV0, aP2, aD2); + Geom2dGcc_CurveToolGeo::D1(theC1, theU0, aP1, aD1); + Geom2dGcc_CurveToolGeo::D1(theC2, theV0, aP2, aD2); gp_Vec2d vP12(aP1.XY() - aP2.XY()); @@ -552,7 +560,7 @@ static void PrecRoot(const TheParGenCurve& theC1, theVfinal = theV0; Standard_Real aSQDistPrev = aP1.SquareDistance(aP2); - + Standard_Integer aNbIter = 1; do @@ -580,8 +588,8 @@ static void PrecRoot(const TheParGenCurve& theC1, //method diverges return; - TheCurvePGTool::D1(theC1, aU, aP1, aD1); - TheCurvePGTool::D1(theC2, aV, aP2, aD2); + 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)) @@ -627,8 +635,8 @@ static void PrecRoot(const TheParGenCurve& theC1, if(!isInBound) { - TheCurvePGTool::D1(theC1, aU, aP1, aD1); - TheCurvePGTool::D1(theC2, aV, aP2, aD2); + 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(); @@ -644,12 +652,12 @@ static void PrecRoot(const TheParGenCurve& theC1, if(aV2 > theVmax) aV2 = theVmax; - aP1 = TheCurvePGTool::Value(theC1,theUfinal); - aP2 = TheCurvePGTool::Value(theC2,aV1); + aP1 = Geom2dGcc_CurveToolGeo::Value(theC1,theUfinal); + aP2 = Geom2dGcc_CurveToolGeo::Value(theC2,aV1); Standard_Real aSQ1 = aP1.SquareDistance(aP2); - aP2 = TheCurvePGTool::Value(theC2,aV2); + aP2 = Geom2dGcc_CurveToolGeo::Value(theC2,aV2); Standard_Real aSQ2 = aP1.SquareDistance(aP2); if(aSQ1 < aSQ2) @@ -681,8 +689,8 @@ static void PrecRoot(const TheParGenCurve& theC1, if(isInBound) return; - TheCurvePGTool::D1(theC1, aU, aP1, aD1); - TheCurvePGTool::D1(theC2, aV, aP2, aD2); + 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(); @@ -698,12 +706,12 @@ static void PrecRoot(const TheParGenCurve& theC1, if(aU2 > theUmax) aU2 = theUmax; - aP2 = TheCurvePGTool::Value(theC2,theVfinal); - aP1 = TheCurvePGTool::Value(theC1,aU1); + aP2 = Geom2dGcc_CurveToolGeo::Value(theC2,theVfinal); + aP1 = Geom2dGcc_CurveToolGeo::Value(theC1,aU1); Standard_Real aSQ1 = aP1.SquareDistance(aP2); - aP1 = TheCurvePGTool::Value(theC1,aU2); + aP1 = Geom2dGcc_CurveToolGeo::Value(theC1,aU2); Standard_Real aSQ2 = aP1.SquareDistance(aP2); if(aSQ1 < aSQ2) @@ -726,11 +734,11 @@ static void PrecRoot(const TheParGenCurve& theC1, // On remplit les champs. + //======================================================================== -GccGeo_Circ2d2TanRad:: -GccGeo_Circ2d2TanRad (const TheQCurve& Qualified1, - const TheQCurve& Qualified2, - const Standard_Real Radius , - const Standard_Real Tolerance ): +Geom2dGcc_Circ2d2TanRadGeo:: +Geom2dGcc_Circ2d2TanRadGeo (const Geom2dGcc_QCurve& Qualified1, + const Geom2dGcc_QCurve& Qualified2, + const Standard_Real Radius , + const Standard_Real Tolerance ): //======================================================================== // initialisation des champs. + @@ -772,8 +780,8 @@ pararg2(1,16) GccEnt_BadQualifier::Raise(); return; } - TheCurve Cu1 = Qualified1.Qualified(); - TheCurve Cu2 = Qualified2.Qualified(); + Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); + Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); if (Radius < 0.0) { Standard_NegativeValue::Raise(); } else { if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { @@ -845,30 +853,30 @@ pararg2(1,16) cote2(1) = Radius; cote2(2) = -Radius; } - TheIntCurveCurve Intp; + Geom2dInt_GInter 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); + 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(TheCurvePGTool::Value(C1,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C1,lastparam),lastparam,Tol); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C1,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C1,lastparam),lastparam,Tol); #else - TheCurvePGTool::Value(C1,firstparam); - TheCurvePGTool::Value(C1,lastparam); + Geom2dGcc_CurveToolGeo::Value(C1,firstparam); + Geom2dGcc_CurveToolGeo::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); + 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(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, - TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); + IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, + Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); #else - TheCurvePGTool::Value(C2,firstparam); - TheCurvePGTool::Value(C2,lastparam); + Geom2dGcc_CurveToolGeo::Value(C2,firstparam); + Geom2dGcc_CurveToolGeo::Value(C2,lastparam); #endif Intp.Perform(C1,C2,Tol,Tol); if (Intp.IsDone()) { @@ -884,10 +892,10 @@ pararg2(1,16) 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); + 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); @@ -896,18 +904,18 @@ pararg2(1,16) Standard_Real aDist2122 = P21.Distance(P22); if( Min(aDist1112, aDist1122) <= Precision::Approximation() && - Min(aDist1221, aDist2122) <= 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); + 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(TheCurvePGTool::Value(C1, aU0)); + gp_Pnt2d Center(Geom2dGcc_CurveToolGeo::Value(C1, aU0)); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); // ======================================================= qualifier1(NbrSol) = Qualified1.Qualifier(); @@ -916,8 +924,8 @@ pararg2(1,16) 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)); + 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), @@ -934,13 +942,13 @@ pararg2(1,16) //========================================================================= -Standard_Boolean GccGeo_Circ2d2TanRad:: +Standard_Boolean Geom2dGcc_Circ2d2TanRadGeo:: IsDone () const { return WellDone; } -Standard_Integer GccGeo_Circ2d2TanRad:: +Standard_Integer Geom2dGcc_Circ2d2TanRadGeo:: NbSolutions () const { return NbrSol; } -gp_Circ2d GccGeo_Circ2d2TanRad:: +gp_Circ2d Geom2dGcc_Circ2d2TanRadGeo:: ThisSolution (const Standard_Integer Index) const { if (!WellDone) { StdFail_NotDone::Raise(); } @@ -948,7 +956,7 @@ ThisSolution (const Standard_Integer Index) const return cirsol(Index); } -void GccGeo_Circ2d2TanRad:: +void Geom2dGcc_Circ2d2TanRadGeo:: WhichQualifier(const Standard_Integer Index , GccEnt_Position& Qualif1 , GccEnt_Position& Qualif2 ) const @@ -961,7 +969,7 @@ WhichQualifier(const Standard_Integer Index , } } -void GccGeo_Circ2d2TanRad:: +void Geom2dGcc_Circ2d2TanRadGeo:: Tangency1 (const Standard_Integer Index, Standard_Real& ParSol, Standard_Real& ParArg, @@ -978,7 +986,7 @@ Tangency1 (const Standard_Integer Index, } } -void GccGeo_Circ2d2TanRad:: +void Geom2dGcc_Circ2d2TanRadGeo:: Tangency2 (const Standard_Integer Index, Standard_Real& ParSol, Standard_Real& ParArg, @@ -995,7 +1003,7 @@ Tangency2 (const Standard_Integer Index, } } -Standard_Boolean GccGeo_Circ2d2TanRad:: +Standard_Boolean Geom2dGcc_Circ2d2TanRadGeo:: IsTheSame1 (const Standard_Integer Index) const { if (!WellDone) { StdFail_NotDone::Raise(); } @@ -1005,7 +1013,7 @@ IsTheSame1 (const Standard_Integer Index) const return Standard_True; } -Standard_Boolean GccGeo_Circ2d2TanRad:: +Standard_Boolean Geom2dGcc_Circ2d2TanRadGeo:: IsTheSame2 (const Standard_Integer Index) const { if (!WellDone) { StdFail_NotDone::Raise(); } 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/GccGeo/GccGeo_Circ2dTanCen.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cdl similarity index 91% rename from src/GccGeo/GccGeo_Circ2dTanCen.cdl rename to src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cdl index 63ac5b8651..cdaf5021c6 100644 --- a/src/GccGeo/GccGeo_Circ2dTanCen.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cdl @@ -14,13 +14,8 @@ -- 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) - +class Circ2dTanCenGeo from Geom2dGcc + ---Purpose: This class implements the algorithms used to -- create 2d circles tangent to a curve and -- centered on a point. @@ -48,7 +43,11 @@ uses Pnt2d from gp, Array1OfReal from TColStd, Array1OfInteger from TColStd, Position from GccEnt, - Array1OfPosition from GccEnt + Array1OfPosition from GccEnt, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + ExtPC2d from Extrema, + QCurve from Geom2dGcc raises OutOfRange from Standard, BadQualifier from GccEnt, @@ -56,9 +55,9 @@ raises OutOfRange from Standard, is -Create( Qualified1 : TheQualifiedCurve ; - Pcenter : Pnt2d from gp ; - Tolerance : Real from Standard) returns Circ2dTanCen +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. @@ -148,4 +147,4 @@ fields -- The parameter of the tangency point between the solution and the first -- argument on the first argument. -end Circ2dTanCen; +end Circ2dTanCenGeo; diff --git a/src/GccGeo/GccGeo_Circ2dTanCen.gxx b/src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx similarity index 54% rename from src/GccGeo/GccGeo_Circ2dTanCen.gxx rename to src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx index 7dc0a9d4ed..dd85c052f5 100644 --- a/src/GccGeo/GccGeo_Circ2dTanCen.gxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanCenGeo.cxx @@ -12,6 +12,8 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include + #include #include #include @@ -22,26 +24,28 @@ #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 ): +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) + 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); @@ -53,27 +57,27 @@ GccGeo_Circ2dTanCen:: 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); + 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)=TheCurveTool::FirstParameter(curve) && - thePar <= TheCurveTool::LastParameter(curve)) { - theDist2(1) = distmin.SquareDistance(i); - theParam(1) = thePar; - pTan(1) = distmin.Point(i).Value(); + thePar>=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>=TheCurveTool::FirstParameter(curve) && - thePar <= TheCurveTool::LastParameter(curve)) { - theDist2(2) = distmin.SquareDistance(i); - theParam(2) = thePar; - pTan(2) = distmin.Point(i).Value(); + 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++; } @@ -82,7 +86,7 @@ GccGeo_Circ2dTanCen:: for (i = 1 ; i <= nbsol; i++) { gp_Pnt2d point1; gp_Vec2d Tan1; - TheCurveTool::D1(curve,theParam(i),point1,Tan1); + Geom2dGcc_CurveTool::D1(curve,theParam(i),point1,Tan1); Standard_Real normetan1 = Tan1.Magnitude(); gp_Vec2d Vec1(point1,Pcenter); Standard_Real normevec1 = Vec1.Magnitude(); @@ -95,16 +99,16 @@ GccGeo_Circ2dTanCen:: 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; + (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; } } } @@ -115,23 +119,23 @@ GccGeo_Circ2dTanCen:: //========================================================================= -Standard_Boolean GccGeo_Circ2dTanCen:: - IsDone () const { return WellDone; } +Standard_Boolean Geom2dGcc_Circ2dTanCenGeo:: +IsDone () const { return WellDone; } -Standard_Integer GccGeo_Circ2dTanCen:: - NbSolutions () const { return NbrSol; } +Standard_Integer Geom2dGcc_Circ2dTanCenGeo:: +NbSolutions () const { return NbrSol; } -gp_Circ2d GccGeo_Circ2dTanCen:: - ThisSolution (const Standard_Integer Index) const +gp_Circ2d Geom2dGcc_Circ2dTanCenGeo:: +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 +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(); } @@ -140,21 +144,21 @@ void GccGeo_Circ2dTanCen:: } } -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); - } - } +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/GccGeo/GccGeo_Circ2dTanOnRad.cdl b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cdl similarity index 88% rename from src/GccGeo/GccGeo_Circ2dTanOnRad.cdl rename to src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cdl index 221be61829..9640e86738 100644 --- a/src/GccGeo/GccGeo_Circ2dTanOnRad.cdl +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cdl @@ -14,21 +14,7 @@ -- 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) +class Circ2dTanOnRadGeo from Geom2dGcc ---Purpose: This class implements the algorithms used to -- create a 2d circle tangent to a 2d entity, @@ -65,7 +51,15 @@ uses Lin2d from gp, Array1OfReal from TColStd, Array1OfInteger from TColStd, Position from GccEnt, - Array1OfPosition 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, @@ -76,10 +70,10 @@ is -- On a line ............................................................. -Create(Qualified1 : TheQCurve ; - OnLine : Lin2d from gp ; +Create(Qualified1 : QCurve from Geom2dGcc; + OnLine : Lin2d from gp; Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad + 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. @@ -89,10 +83,10 @@ raises NegativeValue, BadQualifier; -- -- On a circle ........................................................... -Create(Qualified1 : TheQCurve ; - OnCirc : Circ2d from gp ; +Create(Qualified1 : QCurve from Geom2dGcc; + OnCirc : Circ2d from gp; Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad + 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. @@ -103,9 +97,9 @@ raises NegativeValue, BadQualifier; -- On a curve ............................................................ Create(Qualified1 : QualifiedCirc from GccEnt ; - OnCurv : TheCurve ; + OnCurv : Curve from Geom2dAdaptor ; Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad + 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. @@ -114,9 +108,9 @@ raises NegativeValue, BadQualifier; ---Purpose: raises NegativeValue in case of NegativeRadius. Create(Qualified1 : QualifiedLin from GccEnt ; - OnCurv : TheCurve ; + OnCurv : Curve from Geom2dAdaptor ; Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad + 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. @@ -124,10 +118,10 @@ Create(Qualified1 : QualifiedLin from GccEnt ; raises NegativeValue, BadQualifier; ---Purpose: raises NegativeValue in case of NegativeRadius. -Create(Qualified1 : TheQCurve ; - OnCurv : TheCurve ; +Create(Qualified1 : QCurve from Geom2dGcc; + OnCurv : Curve from Geom2dAdaptor; Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad + 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. @@ -136,9 +130,9 @@ raises NegativeValue, BadQualifier; ---Purpose: raises NegativeValue in case of NegativeRadius. Create(Point1 : Pnt2d from gp ; - OnCurv : TheCurve ; + OnCurv : Curve from Geom2dAdaptor ; Radius : Real from Standard; - Tolerance : Real from Standard) returns Circ2dTanOnRad + 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. @@ -270,4 +264,4 @@ fields ---Purpose: The parameter of the center point of the solution on the -- second argument. -end Circ2dTanOnRad; +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/GccGeo/GccGeo_CurvePGTool.cdl b/src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cdl similarity index 74% rename from src/GccGeo/GccGeo_CurvePGTool.cdl rename to src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cdl index bb99d123e9..a6c01b17ab 100644 --- a/src/GccGeo/GccGeo_CurvePGTool.cdl +++ b/src/Geom2dGcc/Geom2dGcc_CurveToolGeo.cdl @@ -14,11 +14,7 @@ -- 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: +class CurveToolGeo from Geom2dGcc uses Pnt2d from gp, Vec2d from gp, @@ -28,38 +24,41 @@ uses Pnt2d from gp, Parab2d from gp, Hypr2d from gp, CurveType from GeomAbs, - Shape from GeomAbs + Shape from GeomAbs, + Curve from Geom2dAdaptor, + CurveTool from Geom2dGcc, + OffsetCurve from Adaptor3d is - TheType(myclass; C: TheParGenCurve ) + TheType(myclass; C: OffsetCurve from Adaptor3d ) returns CurveType from GeomAbs; - Line(myclass; C: TheParGenCurve) + 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: TheParGenCurve) + 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: TheParGenCurve) + 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: TheParGenCurve) + 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: TheParGenCurve) + 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. @@ -67,61 +66,61 @@ is -- The following method are used only when TheType returns IntCurve_Other. - FirstParameter(myclass;C: TheParGenCurve) + FirstParameter(myclass;C: OffsetCurve from Adaptor3d) returns Real; - LastParameter(myclass;C: TheParGenCurve) + LastParameter(myclass;C: OffsetCurve from Adaptor3d) returns Real; EpsX (myclass ; - C : TheParGenCurve ; + C : OffsetCurve from Adaptor3d ; Tol : Real from Standard) returns Real; NbSamples(myclass ; - C : TheParGenCurve) + C : OffsetCurve from Adaptor3d) returns Integer; Value (myclass ; - C : TheParGenCurve; + C : OffsetCurve from Adaptor3d; X : Real ) returns Pnt2d from gp; - D1 (myclass; C : TheParGenCurve ; + D1 (myclass; C : OffsetCurve from Adaptor3d ; U : Real ; P : out Pnt2d ; T : out Vec2d ); - D2 (myclass; C : TheParGenCurve ; + D2 (myclass; C : OffsetCurve from Adaptor3d ; U : Real ; P : out Pnt2d ; T,N : out Vec2d ); - IsComposite(myclass; C:TheParGenCurve) + IsComposite(myclass; C:OffsetCurve from Adaptor3d) returns Boolean from Standard; -- The following methods are used only when IsComposite returns True. - GetIntervals(myclass ; C:TheParGenCurve) returns Integer from Standard; + 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 : TheParGenCurve + 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 TheParGenCurve + 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 CurvePGTool; +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