0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / GccAna / GccAna_Circ2d2TanOn_5.cxx
CommitLineData
b311480e 1// Created on: 1992-01-02
2// Created by: Remi GILET
3// Copyright (c) 1992-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#include <GccAna_Circ2d2TanOn.jxx>
23
24#include <ElCLib.hxx>
25#include <gp_Dir2d.hxx>
26#include <gp_Ax2d.hxx>
27#include <IntAna2d_AnaIntersection.hxx>
28#include <IntAna2d_IntPoint.hxx>
29
30//=========================================================================
0d969553
Y
31// Creation of a circle passing by : 2 points Point1 and Point2. +
32// Centered on : 1 straight line OnLine. +
33// with a Tolerance of precision : Tolerance. +
7fd59977 34// +
0d969553
Y
35// Create L1 straight line of points equidistant from Point1 and Point2. +
36// Then create solutions cirsol such as : +
37// cirsol is all circle with center at the intersections of +
38// L1 with OnLine and the radius the distance between Point1 and the point +
39// calculated above. +
7fd59977 40//=========================================================================
41
42GccAna_Circ2d2TanOn::
43 GccAna_Circ2d2TanOn (const gp_Pnt2d& Point1 ,
44 const gp_Pnt2d& Point2 ,
45 const gp_Lin2d& OnLine ,
46 const Standard_Real Tolerance ):
47 cirsol(1,2) ,
48 qualifier1(1,2) ,
49 qualifier2(1,2),
50 TheSame1(1,2) ,
51 TheSame2(1,2) ,
52 pnttg1sol(1,2) ,
53 pnttg2sol(1,2) ,
54 pntcen(1,2) ,
55 par1sol(1,2) ,
56 par2sol(1,2) ,
57 pararg1(1,2) ,
58 pararg2(1,2) ,
59 parcen3(1,2)
60{
61 TheSame1.Init(0);
62 TheSame2.Init(0);
63 WellDone = Standard_False;
64 NbrSol = 0;
65
66 gp_Dir2d dirx(1.,0.);
67 Standard_Real dist = Point1.Distance(Point2);
68 if (dist < Abs(Tolerance)) { WellDone = Standard_True; }
69 else {
70 gp_Lin2d L1(gp_Pnt2d((Point1.XY()+Point2.XY())/2.0),
71 gp_Dir2d(Point1.Y()-Point2.Y(),Point2.X()-Point1.X()));
72 IntAna2d_AnaIntersection Intp(L1,OnLine);
73 if (Intp.IsDone()) {
74 if (!Intp.IsEmpty()) {
75 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
76 NbrSol++;
77 gp_Ax2d axe(Intp.Point(i).Value(),dirx);
78 cirsol(NbrSol)=gp_Circ2d(axe,Point1.Distance(Intp.Point(i).Value()));
79// ====================================================================
80 qualifier1(NbrSol) = GccEnt_noqualifier;
81 qualifier2(NbrSol) = GccEnt_noqualifier;
82 pnttg1sol(NbrSol) = Point1;
83 pnttg2sol(NbrSol) = Point2;
84 pntcen(NbrSol) = cirsol(NbrSol).Location();
85 pararg1(NbrSol) = 0.;
86 pararg2(NbrSol) = 0.;
87 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg1sol(NbrSol));
88 par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg2sol(NbrSol));
89 parcen3(NbrSol)=ElCLib::Parameter(OnLine,pntcen(NbrSol));
90 }
91 }
92 WellDone = Standard_True;
93 }
94 }
95}
96
97
98
99
100
101