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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 //=========================================================================
18 // CREATION of the BISSECTRICE between a DROITE and POINTS. +
19 //=========================================================================
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>
29 #include <StdFail_NotDone.hxx>
31 //=========================================================================
32 GccAna_LinPnt2dBisec::
33 GccAna_LinPnt2dBisec (const gp_Lin2d& Line1 ,
34 const gp_Pnt2d& Point2) {
36 WellDone = Standard_False;
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()) {
46 Standard_Real xpoint2 = Point2.X();
47 Standard_Real ypoint2 = Point2.Y();
48 if ((-ydir*(xpoint2-xloc)+xdir*(ypoint2-yloc)) > 0.0)
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 // =====================================
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 // =====================================
64 WellDone = Standard_True;
68 gp_Lin2d bislinpnt(Point2,gp_Dir2d(-ydir,xdir));
69 bissol = new GccInt_BLine(bislinpnt);
70 // ====================================
71 WellDone = Standard_True;
75 //=========================================================================
77 Standard_Boolean GccAna_LinPnt2dBisec::
78 IsDone () const { return WellDone; }
80 Handle(GccInt_Bisec) GccAna_LinPnt2dBisec::
84 throw StdFail_NotDone();