summaryrefslogtreecommitdiff
path: root/src/GccAna/GccAna_Pnt2dBisec.cxx
blob: 2811d19aca82d5b1d3a9168bd6c53386c7b70665 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// File:	GccAna_Pnt2dBisec.cxx
// Created:	Fri Oct  4 09:53:31 1991
// Author:	Remi GILET
//		<reg@phobox>


//=========================================================================
//   CREATION DE LA BISSECTRICE ENTRE DEUX POINTS.                         +
//=========================================================================

#include <GccAna_Pnt2dBisec.ixx>

#include <gp_XY.hxx>
#include <gp_Dir2d.hxx>
#include <Standard_ConstructionError.hxx>
#include <StdFail_NotDone.hxx>
#include <GccAna_NoSolution.hxx>
#include <gp.hxx>

//=========================================================================

GccAna_Pnt2dBisec::
   GccAna_Pnt2dBisec (const gp_Pnt2d& Point1,
		      const gp_Pnt2d& Point2) {

   WellDone = Standard_False;
//   if (Point1.Distance(Point2) > gp::Resolution()) {
   if (Point1.Distance(Point2) > 1.e-10) {
     gp_Dir2d dir1(Point2.XY()-Point1.XY());
     linsol = gp_Lin2d(gp_Pnt2d((Point2.X()+Point1.X())/2.,
//   ======================================================
				   (Point2.Y()+Point1.Y())/2.),
//                                 ============================
			  gp_Dir2d(-dir1.Y(),dir1.X()));
//                        =============================
     HasSol = Standard_True;
     WellDone = Standard_True;
   }
   else { 
     HasSol = Standard_False;
     WellDone = Standard_True;
   }
 }


//=========================================================================

Standard_Boolean GccAna_Pnt2dBisec::
   IsDone () const { return WellDone; }

Standard_Boolean GccAna_Pnt2dBisec::
   HasSolution () const { return HasSol; }

gp_Lin2d GccAna_Pnt2dBisec::
   ThisSolution () const {
   if (!WellDone) { StdFail_NotDone::Raise(); }
   else if (!HasSol) { GccAna_NoSolution::Raise(); }
   return linsol;
 }