0032832: Coding - get rid of unused headers [FairCurve to GeomAPI]
[occt.git] / src / GccAna / GccAna_LinPnt2dBisec.cxx
1 // Created on: 1991-10-04
2 // Created by: Remi GILET
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 //=========================================================================
18 //   CREATION of the BISSECTRICE between a DROITE and POINTS.             +
19 //=========================================================================
20
21 #include <GccAna_LinPnt2dBisec.hxx>
22 #include <GccInt_BLine.hxx>
23 #include <GccInt_BParab.hxx>
24 #include <gp_Ax2d.hxx>
25 #include <gp_Dir2d.hxx>
26 #include <gp_Lin2d.hxx>
27 #include <gp_Pnt2d.hxx>
28 #include <gp_XY.hxx>
29 #include <StdFail_NotDone.hxx>
30
31 //=========================================================================
32 GccAna_LinPnt2dBisec::
33    GccAna_LinPnt2dBisec (const gp_Lin2d& Line1 ,
34                          const gp_Pnt2d& Point2) {
35
36    WellDone = Standard_False;
37
38    Standard_Real xdir = Line1.Direction().X();
39    Standard_Real ydir = Line1.Direction().Y();
40    Standard_Real xloc = Line1.Location().X();
41    Standard_Real yloc = Line1.Location().Y();
42    Standard_Real dist = Line1.Distance(Point2);
43 //   if ( dist > gp::Resolution()) {
44    if ( dist > 1.e-10)
45      {
46        Standard_Real xpoint2 = Point2.X();
47        Standard_Real ypoint2 = Point2.Y();
48        if ((-ydir*(xpoint2-xloc)+xdir*(ypoint2-yloc)) > 0.0)
49          {
50            gp_Ax2d axeparab(gp_Pnt2d(Point2.XY()-dist/2.*gp_XY(-ydir,xdir)),
51                             gp_Dir2d(-ydir,xdir));
52            gp_Parab2d bislinpnt(axeparab,dist/2.0);
53            bissol = new GccInt_BParab(bislinpnt);
54 //         =====================================
55          }
56        else
57          {
58            gp_Ax2d axeparab(gp_Pnt2d(Point2.XY()+dist/2.*gp_XY(-ydir,xdir)),
59                             gp_Dir2d(ydir,-xdir));
60            gp_Parab2d bislinpnt(axeparab,dist/2.0);
61            bissol = new GccInt_BParab(bislinpnt);
62 //         =====================================
63          }
64        WellDone = Standard_True;
65      }
66    else
67      {
68        gp_Lin2d bislinpnt(Point2,gp_Dir2d(-ydir,xdir));
69        bissol = new GccInt_BLine(bislinpnt);
70 //     ====================================
71        WellDone = Standard_True;
72      }
73  }
74
75 //=========================================================================
76
77 Standard_Boolean GccAna_LinPnt2dBisec::
78    IsDone () const { return WellDone; }
79
80 Handle(GccInt_Bisec) GccAna_LinPnt2dBisec::
81    ThisSolution () const 
82 {
83   if (!WellDone)
84     throw StdFail_NotDone();
85
86   return bissol;
87 }