OpenLexocad  27.0
Pnt.h
Go to the documentation of this file.
1 //
3 // Copyright(C) 2013-2016 OpenCascade [www.opencascade.org]
4 //
5 // This library is free software; you can redistribute it and / or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street,
18 // Fifth Floor, Boston, MA 02110 - 1301 USA
19 //
21 
22 #pragma once
23 
24 #include <Geom/XYZ.h>
25 #include <Geom/geom_defines.h>
26 
27 namespace Geom
28 {
29 class Ax1;
30 class Ax2;
31 class Trsf;
32 class Vec;
33 class Pnt;
34 } // namespace Geom
35 
36 typedef std::vector<Geom::Pnt> PNTS;
37 
38 
39 namespace Geom
40 {
43 {
44 public:
46  // //
47  // --------------------- BEGIN API --------------------- //
48  // //
49  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
50  // //
52 
54  Pnt();
56  Pnt(const Geom::XYZ& Coord);
57 
59  Pnt(const double Xp, const double Yp, const double Zp = .0);
60 
62  Pnt(const Pnt& rhs);
63 
64  static Pnt ZeroPnt() { return Pnt(0, 0, 0); };
65 
70  void setCoord(const int Index, const double Xi);
72  void setCoord(const double Xp, const double Yp, const double Zp = .0);
74  void setX(const double X);
76  void setY(const double Y);
78  void setZ(const double Z);
80  void setXYZ(const Geom::XYZ& Coord);
81 
87  double coord(const int Index) const;
89  void coord(double& Xp, double& Yp, double& Zp) const;
91  double x() const;
93  double y() const;
95  double z() const;
97  const Geom::XYZ& xyz() const;
99  const Geom::XYZ& coord() const;
100 
103  Geom::XYZ& changeCoord();
106  void baryCenter(const double Alpha, const Pnt& P, const double Beta);
110  bool isEqual(const Pnt& Other, const double LinearTolerance) const;
112  double distance(const Pnt& Other) const;
114  double squareDistance(const Pnt& Other) const;
115 
116 
120  void mirror(const Pnt& P);
121 
122 
126  Pnt mirrored(const Pnt& P) const;
127 
128 
129  void mirror(const Geom::Ax1& A1);
130 
131 
135  Pnt mirrored(const Geom::Ax1& A1) const;
136 
137 
138  void mirror(const Geom::Ax2& A2);
139 
140 
143  Pnt mirrored(const Geom::Ax2& A2) const;
144 
145  void rotate(const Geom::Ax1& A1, const double Ang);
146  Pnt rotated(const Geom::Ax1& A1, const double Ang) const;
147 
149  void scale(const Pnt& P, const double S);
150  Pnt scaled(const Pnt& P, const double S) const;
151 
152 
154  void transform(const Geom::Trsf& T);
155  Pnt transformed(const Geom::Trsf& T) const;
156 
159  void translate(const Geom::Vec& V);
160 
162  Pnt translated(const Geom::Vec& V) const;
163  void translate(const Pnt& P1, const Pnt& P2);
164  Pnt translated(const Pnt& P1, const Pnt& P2) const;
165 
167  bool operator==(const Geom::Pnt& other) const;
169  bool operator!=(const Geom::Pnt& other) const;
170 
172  // //
173  // ---------------------- END API ---------------------- //
174  // //
176 
177  double& operator[](int i);
178  const double& operator[](int i) const;
179 
180  Pnt operator-(const Geom::Pnt& other) const;
181  Pnt operator+(const Geom::Pnt& other) const;
182  Pnt operator*(const Geom::Pnt& other) const;
183  Pnt operator*(double scalar) const;
184 
185  bool operator<(const Geom::Pnt& rhs) const;
186 
187 private:
188  Geom::XYZ _coord;
189 };
190 
191 } // namespace Geom
Definition: Rotation.h:5
X
Definition: Globals.h:32
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:42
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) ENTT_NOEXCEPT
Compares two hashed strings.
Definition: entt.hpp:570
#define GEOM_EXPORT
Definition: geom_defines.h:8
Definition: Ax2.h:69
Definition: XYZ.h:46
Definition: Trsf.h:58
Y
Definition: Globals.h:32
Definition: Ax1.h:52
Z
Definition: Globals.h:32
Defines a non-persistent vector in 3D space.
Definition: Vec.h:45
std::vector< Geom::Pnt > PNTS
Definition: Pnt.h:36
Geom::Vec operator *(const double Scalar, const Geom::Vec &V)
Definition: Vec.h:312
static Pnt ZeroPnt()
Definition: Pnt.h:64