a291af2482f0b06aca5827678bcf4a61fd0a1867
[occt.git] / src / gp / gp_Lin.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 // JCV 30/08/90 Modif passage version C++ 2.0 sur Sun
16 // JCV 1/10/90 Changement de nom du package vgeom -> gp
17 // JCV 12/12/90 modifs suite a la premiere revue de projet
18
19 #include <gp_Lin.hxx>
20
21 #include <gp_Ax1.hxx>
22 #include <gp_Ax2.hxx>
23 #include <gp_Dir.hxx>
24 #include <gp_Pnt.hxx>
25 #include <gp_Trsf.hxx>
26 #include <gp_Vec.hxx>
27
28 Standard_Real gp_Lin::Distance (const gp_Lin& Other) const
29 {
30   if (pos.IsParallel (Other.pos, gp::Resolution())) { 
31     return Other.Distance(pos.Location());
32   }
33   else {
34     gp_Dir dir(pos.Direction().Crossed(Other.pos.Direction()));
35     Standard_Real D = gp_Vec (pos.Location(),Other.pos.Location())
36       .Dot(gp_Vec(dir));
37     if (D < 0) D = - D;
38     return D;
39   }
40 }
41
42 void gp_Lin::Mirror (const gp_Pnt& P)
43 { pos.Mirror(P);  }
44
45 gp_Lin gp_Lin::Mirrored (const gp_Pnt& P)  const
46 {
47   gp_Lin L = *this;    
48   L.pos.Mirror (P);
49   return L;
50 }
51
52 void gp_Lin::Mirror (const gp_Ax1& A1)
53 { pos.Mirror(A1); }
54
55 gp_Lin gp_Lin::Mirrored (const gp_Ax1& A1) const
56 {
57   gp_Lin L = *this;
58   L.pos.Mirror (A1);
59   return L;
60 }
61
62 void gp_Lin::Mirror (const gp_Ax2& A2)
63 { pos.Mirror(A2); }
64
65 gp_Lin gp_Lin::Mirrored (const gp_Ax2& A2) const
66 {
67   gp_Lin L = *this;
68   L.pos.Mirror (A2);
69   return L;
70 }
71