0029915: Porting to VC 2017 : Regressions in Modeling Algorithms on VC 2017
[occt.git] / src / gp / gp_Ax2.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 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
973c2be1 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.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15// JCV 1/10/90 Changement de nom du package vgeom -> gp
16// JCV 12/12/90 Modif mineur suite a la premiere revue de projet
17// LPA, JCV 07/92 passage sur C1.
18// JCV 07/92 Introduction de la method Dump
19
20#define No_Standard_OutOfRange
21
42cf5bc1 22
7fd59977 23#include <gp.hxx>
42cf5bc1 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_ConstructionError.hxx>
7fd59977 31
32gp_Ax2::gp_Ax2 (const gp_Pnt& P, const gp_Dir& V) :
33axis(P,V)
34{
35 Standard_Real A = V.X();
36 Standard_Real B = V.Y();
37 Standard_Real C = V.Z();
38 Standard_Real Aabs = A;
39 if (Aabs < 0) Aabs = - Aabs;
40 Standard_Real Babs = B;
41 if (Babs < 0) Babs = - Babs;
42 Standard_Real Cabs = C;
43 if (Cabs < 0) Cabs = - Cabs;
44 gp_Dir D;
45
46 // pour determiner l axe X :
47 // on dit que le produit scalaire Vx.V = 0.
48 // et on recherche le max(A,B,C) pour faire la division.
49 // l'une des coordonnees du vecteur est nulle.
50
51 if ( Babs <= Aabs && Babs <= Cabs) {
52 if (Aabs > Cabs) D.SetCoord(-C,0., A);
53 else D.SetCoord( C,0.,-A);
54 }
55 else if ( Aabs <= Babs && Aabs <= Cabs) {
56 if (Babs > Cabs) D.SetCoord(0.,-C, B);
57 else D.SetCoord(0., C,-B);
58 }
59 else {
60 if (Aabs > Babs) D.SetCoord(-B, A,0.);
61 else D.SetCoord( B,-A,0.);
62 }
63 SetXDirection(D);
64}
65
66void gp_Ax2::Mirror (const gp_Pnt& P)
67{
68 gp_Pnt Temp = axis.Location();
69 Temp.Mirror (P);
70 axis.SetLocation (Temp);
71 vxdir.Reverse ();
72 vydir.Reverse ();
73}
74
75gp_Ax2 gp_Ax2::Mirrored(const gp_Pnt& P) const
76{
77 gp_Ax2 Temp = *this;
78 Temp.Mirror (P);
79 return Temp;
80}
81
82void gp_Ax2::Mirror (const gp_Ax1& A1)
83{
84 vydir.Mirror (A1);
85 vxdir.Mirror (A1);
86 gp_Pnt Temp = axis.Location();
87 Temp.Mirror (A1);
88 axis.SetLocation (Temp);
89 axis.SetDirection (vxdir.Crossed (vydir));
90}
91
92gp_Ax2 gp_Ax2::Mirrored(const gp_Ax1& A1) const
93{
94 gp_Ax2 Temp = *this;
95 Temp.Mirror (A1);
96 return Temp;
97}
98
99void gp_Ax2::Mirror (const gp_Ax2& A2)
100{
101 vydir.Mirror (A2);
102 vxdir.Mirror (A2);
103 gp_Pnt Temp = axis.Location();
104 Temp.Mirror (A2);
105 axis.SetLocation (Temp);
106 axis.SetDirection (vxdir.Crossed (vydir));
107}
108
109gp_Ax2 gp_Ax2::Mirrored(const gp_Ax2& A2) const
110{
111 gp_Ax2 Temp = *this;
112 Temp.Mirror (A2);
113 return Temp;
114}
115