OpenLexocad  27.1
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 <QString>
26 namespace Geom
27 {
28 class Ax1;
29 class Ax2;
30 class Trsf;
31 class Vec;
32 class Pnt;
33 } // namespace Geom
34 
35 typedef std::vector<Geom::Pnt> PNTS;
36 
37 
38 
39 
40 namespace Geom
41 {
43 class LX_GEOM_EXPORT Pnt
44 {
45 public:
47  // //
48  // --------------------- BEGIN API --------------------- //
49  // //
50  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
51  // //
53 
55  Pnt();
57  Pnt(const Geom::XYZ& Coord);
58 
60  Pnt(const double Xp, const double Yp, const double Zp = .0);
61 
63  Pnt(const Pnt& rhs);
64 
65  static Pnt ZeroPnt() { return Pnt(0, 0, 0); };
66 
71  void setCoord(const int Index, const double Xi);
73  void setCoord(const double Xp, const double Yp, const double Zp = .0);
75  void setX(const double X);
77  void setY(const double Y);
79  void setZ(const double Z);
81  void setXYZ(const Geom::XYZ& Coord);
82 
88  double coord(const int Index) const;
90  void coord(double& Xp, double& Yp, double& Zp) const;
92  double x() const;
94  double y() const;
96  double z() const;
97 
98  float fx() const;
99  float fy() const;
100  float fz() const;
102  const Geom::XYZ& xyz() const;
104  const Geom::XYZ& coord() const;
105 
108  Geom::XYZ& changeCoord();
111  void baryCenter(const double Alpha, const Pnt& P, const double Beta);
115  bool isEqual(const Pnt& Other, const double LinearTolerance) const;
117  double distance(const Pnt& Other) const;
119  double squareDistance(const Pnt& Other) const;
120 
121 
125  void mirror(const Pnt& P);
126 
127 
131  Pnt mirrored(const Pnt& P) const;
132 
133 
134  void mirror(const Geom::Ax1& A1);
135 
136 
140  Pnt mirrored(const Geom::Ax1& A1) const;
141 
142 
143  void mirror(const Geom::Ax2& A2);
144 
145 
148  Pnt mirrored(const Geom::Ax2& A2) const;
149 
150  void rotate(const Geom::Ax1& A1, const double Ang);
151  Pnt rotated(const Geom::Ax1& A1, const double Ang) const;
152 
154  void scale(const Pnt& P, const double S);
155  Pnt scaled(const Pnt& P, const double S) const;
156 
157 
159  void transform(const Geom::Trsf& T);
160  Pnt transformed(const Geom::Trsf& T) const;
161 
164  void translate(const Geom::Vec& V);
165 
167  Pnt translated(const Geom::Vec& V) const;
168  void translate(const Pnt& P1, const Pnt& P2);
169  Pnt translated(const Pnt& P1, const Pnt& P2) const;
170 
172  bool operator==(const Geom::Pnt& other) const;
174  bool operator!=(const Geom::Pnt& other) const;
175 
177  // //
178  // ---------------------- END API ---------------------- //
179  // //
181 
182  double& operator[](int i);
183  const double& operator[](int i) const;
184 
185  Pnt operator-(const Geom::Pnt& other) const;
186  Pnt operator+(const Geom::Pnt& other) const;
187  Pnt operator*(const Geom::Pnt& other) const;
188  Pnt operator*(double scalar) const;
189 
190  bool operator<(const Geom::Pnt& rhs) const;
191 
192 private:
193  Geom::XYZ _coord;
194 };
195 
196 LX_GEOM_EXPORT QString to_string(const Pnt& pnt);
197 
198 } // namespace Geom
Definition: Variant.h:60
X
Definition: Globals.h:29
DualNumber operator-(DualNumber a, DualNumber b)
Definition: DualNumber.h:61
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:43
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
void transform(Container container, OutputIt out, BinaryFunction function)
Definition: Algorithms.h:29
Definition: Ax2.h:67
Definition: XYZ.h:43
DualNumber operator+(DualNumber a, DualNumber b)
Definition: DualNumber.h:51
Definition: Trsf.h:57
Y
Definition: Globals.h:29
LX_GEOM_EXPORT QString to_string(const Dir &dir)
Definition: Ax1.h:50
Z
Definition: Globals.h:29
Defines a non-persistent vector in 3D space.
Definition: Vec.h:44
double distance(const Geom::Vec &v1, const Geom::Vec &v2)
Returns the distance between two points.
Definition: Vec.h:345
std::vector< Geom::Pnt > PNTS
Definition: Pnt.h:35
static Pnt ZeroPnt()
Definition: Pnt.h:65
DualNumber operator *(DualNumber a, DualNumber b)
Definition: DualNumber.h:71