Integration of OCCT 6.5.0 from SVN
[occt.git] / src / GccAna / GccAna_LinPnt2dBisec.cxx
CommitLineData
7fd59977 1// File: GccAna_LinPnt2dBisec.cxx
2// Created: Fri Oct 4 09:53:31 1991
3// Author: Remi GILET
4// <reg@phobox>
5
6
7//=========================================================================
8// CREATION DE LA BISSECTRICE ENTRE UNE DROITE ET UN POINTS. +
9//=========================================================================
10
11#include <GccAna_LinPnt2dBisec.ixx>
12
13#include <gp_XY.hxx>
14#include <gp_Dir2d.hxx>
15#include <gp_Ax2d.hxx>
16#include <GccInt_BParab.hxx>
17#include <GccInt_BLine.hxx>
18#include <Standard_ConstructionError.hxx>
19#include <StdFail_NotDone.hxx>
20#include <gp.hxx>
21
22//=========================================================================
23
24GccAna_LinPnt2dBisec::
25 GccAna_LinPnt2dBisec (const gp_Lin2d& Line1 ,
26 const gp_Pnt2d& Point2) {
27
28 WellDone = Standard_False;
29
30 Standard_Real xdir = Line1.Direction().X();
31 Standard_Real ydir = Line1.Direction().Y();
32 Standard_Real xloc = Line1.Location().X();
33 Standard_Real yloc = Line1.Location().Y();
34 Standard_Real dist = Line1.Distance(Point2);
35// if ( dist > gp::Resolution()) {
36 if ( dist > 1.e-10)
37 {
38 Standard_Real xpoint2 = Point2.X();
39 Standard_Real ypoint2 = Point2.Y();
40 if ((-ydir*(xpoint2-xloc)+xdir*(ypoint2-yloc)) > 0.0)
41 {
42 gp_Ax2d axeparab(gp_Pnt2d(Point2.XY()-dist/2.*gp_XY(-ydir,xdir)),
43 gp_Dir2d(-ydir,xdir));
44 gp_Parab2d bislinpnt(axeparab,dist/2.0);
45 bissol = new GccInt_BParab(bislinpnt);
46// =====================================
47 }
48 else
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 WellDone = Standard_True;
57 }
58 else
59 {
60 gp_Lin2d bislinpnt(Point2,gp_Dir2d(-ydir,xdir));
61 bissol = new GccInt_BLine(bislinpnt);
62// ====================================
63 WellDone = Standard_True;
64 }
65 }
66
67//=========================================================================
68
69Standard_Boolean GccAna_LinPnt2dBisec::
70 IsDone () const { return WellDone; }
71
72Handle(GccInt_Bisec) GccAna_LinPnt2dBisec::
73 ThisSolution () const
74{
75 if (!WellDone)
76 StdFail_NotDone::Raise();
77
78 return bissol;
79}