0024624: Lost word in license statement in source files
[occt.git] / src / GccAna / GccAna_CircLin2dBisec.cxx
CommitLineData
b311480e 1// Created on: 1991-10-11
2// Created by: Remi GILET
3// Copyright (c) 1991-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17//=========================================================================
0d969553 18// CREATION of the BISSECTICE between a CIRCLE and a STRAIGHT LINE. +
7fd59977 19//=========================================================================
20
21#include <GccAna_CircLin2dBisec.ixx>
22
23#include <gp_XY.hxx>
24#include <gp_Dir2d.hxx>
25#include <gp_Ax2d.hxx>
26#include <GccInt_BParab.hxx>
27#include <GccInt_BLine.hxx>
28#include <Standard_OutOfRange.hxx>
29#include <StdFail_NotDone.hxx>
30#include <gp.hxx>
31
32//=========================================================================
33
34GccAna_CircLin2dBisec::
35 GccAna_CircLin2dBisec (const gp_Circ2d& Circle ,
36 const gp_Lin2d& Line ):
37
38 circle(Circle),
39 line(Line)
40{
41
42//=========================================================================
0d969553
Y
43// Initialization of fields : +
44// - circle +
45// - line (straight line.) +
46// - NbrSol (number of solution.) +
47// - WellDone (Booleen showing success or failure of algorithm). +
7fd59977 48//=========================================================================
49
50 NbrSol = 2;
51 WellDone = Standard_True;
52 }
53
54//=========================================================================
0d969553
Y
55// Processing. +
56// Return coordinates of origins of the straight line (xloc,yloc) and the +
57// circle (xcencir, ycencir). +
58// Also return the coordinates of the direction of the straight line (xdir, +
59// ydir) and the radius of circle R1. +
60// Check at which side of the straight line is found the center of the circle +
61// to orientate the parabola (sign). +
62// Create axis of each parabola (axeparab1, axeparb2), then +
63// two parabolas (biscirlin1, biscirlin1). +
7fd59977 64//=========================================================================
65
66Handle(GccInt_Bisec) GccAna_CircLin2dBisec::
67 ThisSolution (const Standard_Integer Index) const
68{
69
70 if (!WellDone) StdFail_NotDone::Raise();
71
72 if ((Index <=0) || (Index > NbrSol)) Standard_OutOfRange::Raise();
73
74 Handle(GccInt_Bisec) bissol;
75 Standard_Real xdir = line.Direction().X();
76 Standard_Real ydir = line.Direction().Y();
77 Standard_Real xloc = line.Location().X();
78 Standard_Real yloc = line.Location().Y();
79 Standard_Real xcencir = circle.Location().X();
80 Standard_Real ycencir = circle.Location().Y();
81 Standard_Real R1 = circle.Radius();
82 Standard_Real dist = line.Distance(circle.Location());
83 if ((Abs(line.Distance(circle.Location())-circle.Radius())
84 <= gp::Resolution()) && (Index == 1)) {
85 gp_Lin2d biscirlin1(circle.Location(),gp_Dir2d(-ydir,xdir));
86 bissol = new GccInt_BLine(biscirlin1);
87 // ==========================================================
88 }
89 else {
90 Standard_Integer signe;
91 if ((-ydir*(xcencir-xloc)+xdir*(ycencir-yloc)) > 0.0) {
92 signe = 1;
93 }
94 else {
95 signe = -1;
96 }
97 gp_Ax2d axeparab1;
98// gp_Ax2d axeparab2;
99 gp_Parab2d biscirlin;
100 if (dist != R1) {
101 if (Index == 1) {
102 axeparab1=gp_Ax2d(gp_Pnt2d(gp_XY(xcencir+signe*ydir*(dist+R1)/2,
103 ycencir-signe*xdir*(dist+R1)/2.)),
104 gp_Dir2d(-signe*ydir,signe*xdir));
105 biscirlin = gp_Parab2d(axeparab1,(dist+R1)/2.0);
106 }
107 else {
108 if (dist < R1) {
109 axeparab1=gp_Ax2d(gp_Pnt2d(gp_XY(xcencir+signe*ydir*(dist-R1)/2,
110 ycencir-signe*xdir*(dist-R1)/2.)),
111 gp_Dir2d(signe*ydir,-signe*xdir));
112 }
113 else {
114 axeparab1=gp_Ax2d(gp_Pnt2d(gp_XY(xcencir+signe*ydir*(dist-R1)/2,
115 ycencir-signe*xdir*(dist-R1)/2.)),
116 gp_Dir2d(-signe*ydir,signe*xdir));
117 }
118 biscirlin = gp_Parab2d(axeparab1,Abs(dist-R1)/2.0);
119 }
120 bissol = new GccInt_BParab(biscirlin);
121 // ==========================================================
122 }
123 else {
124 axeparab1 = gp_Ax2d(gp_Pnt2d(gp_XY(xcencir+signe*ydir*(dist+R1)/2.,
125 ycencir-signe*xdir*(dist+R1)/2.)),
126 gp_Dir2d(signe*(-ydir),signe*xdir));
127 biscirlin = gp_Parab2d(axeparab1,R1);
128 bissol = new GccInt_BParab(biscirlin);
129 // ==========================================================
130 }
131 }
132
133 return bissol;
134}
135
136//=========================================================================
137
138Standard_Boolean GccAna_CircLin2dBisec::
139 IsDone () const { return WellDone; }
140
141Standard_Integer GccAna_CircLin2dBisec::
142 NbSolutions () const { return NbrSol; }
143
144