0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / gp / gp_Ax1.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 1/10/90 Changement de nom du package vgeom -> gp
16 // JCV 12/12/90 modif introduction des classes XYZ et Mat dans le package
17 // LPA, JCV  07/92 passage sur C1.
18 // JCV 07/92 Introduction de la method Dump 
19
20 #define No_Standard_OutOfRange
21
22
23 #include <gp.hxx>
24 #include <gp_Ax1.hxx>
25 #include <gp_Ax2.hxx>
26 #include <gp_Dir.hxx>
27 #include <gp_Pnt.hxx>
28 #include <gp_Trsf.hxx>
29 #include <gp_Vec.hxx>
30 #include <Standard_Dump.hxx>
31
32 Standard_Boolean gp_Ax1::IsCoaxial
33 (const gp_Ax1& Other, 
34  const Standard_Real AngularTolerance,
35  const Standard_Real LinearTolerance) const
36 {
37   gp_XYZ XYZ1 = loc.XYZ();
38   XYZ1.Subtract (Other.loc.XYZ());
39   XYZ1.Cross (Other.vdir.XYZ());
40   Standard_Real D1 = XYZ1.Modulus();
41   gp_XYZ XYZ2 = Other.loc.XYZ();
42   XYZ2.Subtract (loc.XYZ());
43   XYZ2.Cross (vdir.XYZ());
44   Standard_Real D2 = XYZ2.Modulus();
45   return (vdir.IsEqual (Other.vdir, AngularTolerance) &&
46           D1 <= LinearTolerance && D2 <= LinearTolerance);
47 }
48
49 void gp_Ax1::Mirror (const gp_Pnt& P)
50 {
51   loc.Mirror(P);
52   vdir.Reverse();
53 }
54
55 gp_Ax1 gp_Ax1::Mirrored (const gp_Pnt& P) const
56 {
57   gp_Ax1 A1 = *this;    
58   A1.Mirror (P);
59   return A1;
60 }
61
62 void gp_Ax1::Mirror (const gp_Ax1& A1)
63 {
64   loc.Mirror(A1);
65   vdir.Mirror(A1.vdir);
66 }
67
68 gp_Ax1 gp_Ax1::Mirrored (const gp_Ax1& A1) const
69 {
70   gp_Ax1 A = *this;
71   A.Mirror (A1);
72   return A;
73 }
74
75 void gp_Ax1::Mirror (const gp_Ax2& A2)
76 {
77   loc.Mirror  (A2);
78   vdir.Mirror (A2);
79 }
80
81 gp_Ax1 gp_Ax1::Mirrored (const gp_Ax2& A2) const
82 {
83   gp_Ax1 A1 = *this;
84   A1.Mirror (A2);
85   return A1;
86 }
87
88 void gp_Ax1::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
89 {
90   OCCT_DUMP_VECTOR_CLASS (theOStream, "Location", 3, loc.X(), loc.Y(), loc.Z())
91   OCCT_DUMP_VECTOR_CLASS (theOStream, "Direction", 3, vdir.X(), vdir.Y(), vdir.Z())
92 }