0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / gp / gp_Pnt.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 30/08/90 Modif passage version C++ 2.0 sur Sun
16// JCV 01/10/90 Changement de nom du package vgeom -> gp
17// JCV 07/12/90 Modifs introduction des classes XYZ, Mat dans le package gp
18
19#define No_Standard_OutOfRange
20
42cf5bc1 21
22#include <gp_Ax1.hxx>
23#include <gp_Ax2.hxx>
24#include <gp_Pnt.hxx>
25#include <gp_Trsf.hxx>
26#include <gp_Vec.hxx>
27#include <gp_XYZ.hxx>
bc73b006 28#include <Standard_Dump.hxx>
42cf5bc1 29#include <Standard_OutOfRange.hxx>
7fd59977 30
31void gp_Pnt::Transform (const gp_Trsf& T)
32{
33 if (T.Form() == gp_Identity) { }
34 else if (T.Form() == gp_Translation) { coord.Add (T.TranslationPart ()); }
35 else if (T.Form() == gp_Scale) {
36 coord.Multiply (T.ScaleFactor ());
37 coord.Add (T.TranslationPart ());
38 }
39 else if(T.Form() == gp_PntMirror) {
40 coord.Reverse ();
41 coord.Add (T.TranslationPart ());
42 }
43 else { T.Transforms(coord); }
44}
45
46void gp_Pnt::Mirror (const gp_Pnt& P)
47{
48 coord.Reverse ();
49 gp_XYZ XYZ = P.coord;
50 XYZ.Multiply (2.0);
51 coord.Add (XYZ);
52}
53
54gp_Pnt gp_Pnt::Mirrored (const gp_Pnt& P) const
55{
56 gp_Pnt Pres = *this;
57 Pres.Mirror (P);
58 return Pres;
59}
60
61void gp_Pnt::Mirror (const gp_Ax1& A1)
62{
63 gp_Trsf T;
64 T.SetMirror (A1);
65 T.Transforms (coord);
66}
67
68gp_Pnt gp_Pnt::Mirrored (const gp_Ax1& A1) const
69{
70 gp_Pnt P = *this;
71 P.Mirror (A1);
72 return P;
73}
74
75void gp_Pnt::Mirror (const gp_Ax2& A2)
76{
77 gp_Trsf T;
78 T.SetMirror (A2);
79 T.Transforms (coord);
80}
81
82gp_Pnt gp_Pnt::Mirrored (const gp_Ax2& A2) const
83{
84 gp_Pnt P = *this;
85 P.Mirror (A2);
86 return P;
87}
88
bc73b006 89void gp_Pnt::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
90{
91 OCCT_DUMP_VECTOR_CLASS (theOStream, "gp_Pnt", 3, coord.X(), coord.Y(), coord.Z())
92}