OpenLexocad  28.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 <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 
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
Geom::Pnt::rotated
Pnt rotated(const Geom::Ax1 &A1, const double Ang) const
Geom::Pnt::changeCoord
Geom::XYZ & changeCoord()
Geom::Pnt::setX
void setX(const double X)
Assigns the given value to the X coordinate of this point.
Geom::Pnt::Pnt
Pnt(const Geom::XYZ &Coord)
Creates a point with a triplet of coordinates.
Geom::Pnt::operator<
bool operator<(const Geom::Pnt &rhs) const
XYZ.h
Geom::Pnt::coord
const Geom::XYZ & coord() const
For this point, returns its three coordinates as a number triple.
Geom::Pnt::isEqual
bool isEqual(const Pnt &Other, const double LinearTolerance) const
Geom::Vec
Defines a non-persistent vector in 3D space.
Definition: Vec.h:41
Geom::Pnt::scale
void scale(const Pnt &P, const double S)
Scales a point. S is the scaling value.
Geom::Pnt::mirror
void mirror(const Pnt &P)
Geom::Pnt::transformed
Pnt transformed(const Geom::Trsf &T) const
Geom::Pnt::operator[]
double & operator[](int i)
Geom::Pnt::setCoord
void setCoord(const int Index, const double Xi)
Geom::Pnt::y
double y() const
For this point, returns its X coordinate.
Geom::Pnt::x
double x() const
For this point, returns its X coordinate.
X
X
Definition: Globals.h:29
Geom::Pnt::mirrored
Pnt mirrored(const Pnt &P) const
Geom::Pnt::mirrored
Pnt mirrored(const Geom::Ax1 &A1) const
Geom::Ax1
Definition: Ax1.h:50
Geom::Pnt::Pnt
Pnt(const Pnt &rhs)
Copy constructor.
Geom::XYZ
Definition: XYZ.h:44
PNTS
std::vector< Geom::Pnt > PNTS
Definition: Pnt.h:35
Geom::Pnt::translate
void translate(const Pnt &P1, const Pnt &P2)
Geom::Pnt::z
double z() const
For this point, returns its X coordinate.
Geom::Pnt::Pnt
Pnt(const double Xp, const double Yp, const double Zp=.0)
Creates a point with its 3 Cartesian's coordinates : Xp, Yp, Zp.
Geom::Pnt::mirrored
Pnt mirrored(const Geom::Ax2 &A2) const
Geom::Pnt::translated
Pnt translated(const Pnt &P1, const Pnt &P2) const
Geom::Pnt::setCoord
void setCoord(const double Xp, const double Yp, const double Zp=.0)
For this point, assigns the values Xp, Yp and Zp to its three coordinates.
Geom::Pnt::setY
void setY(const double Y)
Assigns the given value to the Y coordinate of this point.
Geom::Pnt::mirror
void mirror(const Geom::Ax1 &A1)
Geom::Pnt::operator*
Pnt operator*(double scalar) const
Geom::Pnt
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:44
Geom::Pnt::transform
void transform(const Geom::Trsf &T)
Transforms a point with the transformation T.
Geom::Pnt::translate
void translate(const Geom::Vec &V)
Geom::Ax2
Definition: Ax2.h:66
Geom::Pnt::fx
float fx() const
Z
Z
Definition: Globals.h:31
Geom::Pnt::operator*
Pnt operator*(const Geom::Pnt &other) const
Geom::Pnt::operator==
bool operator==(const Geom::Pnt &other) const
Checks whether two points are equal within linear tolerance (default 1E-07)
Geom::Pnt::fz
float fz() const
Geom::Pnt::mirror
void mirror(const Geom::Ax2 &A2)
Geom::Pnt::rotate
void rotate(const Geom::Ax1 &A1, const double Ang)
Geom::Pnt::fy
float fy() const
Geom::Pnt::operator[]
const double & operator[](int i) const
Y
Y
Definition: Globals.h:30
Geom::Pnt::coord
void coord(double &Xp, double &Yp, double &Zp) const
For this point gives its three coordinates Xp, Yp and Zp.
Geom::Pnt::baryCenter
void baryCenter(const double Alpha, const Pnt &P, const double Beta)
Geom::Pnt::distance
double distance(const Pnt &Other) const
Computes the distance between two points.
Geom::Pnt::ZeroPnt
static Pnt ZeroPnt()
Definition: Pnt.h:65
Geom::Pnt::operator!=
bool operator!=(const Geom::Pnt &other) const
Checks whether two points are unequal within linear tolerance (default 1E-07)
Geom::Pnt::setXYZ
void setXYZ(const Geom::XYZ &Coord)
Assigns the three coordinates of Coord to this point.
Geom::Pnt::setZ
void setZ(const double Z)
Assigns the given value to the Z coordinate of this point.
Geom::Pnt::translated
Pnt translated(const Geom::Vec &V) const
Translates a point from the point P1 to the point P2.
Geom::Pnt::scaled
Pnt scaled(const Pnt &P, const double S) const
Geom::Pnt::coord
double coord(const int Index) const
Geom::Trsf
Definition: Trsf.h:58
Geom::Pnt::Pnt
Pnt()
Creates an indefinite point.
Geom::Pnt::squareDistance
double squareDistance(const Pnt &Other) const
Computes the square distance between two points.
Geom::to_string
LX_GEOM_EXPORT QString to_string(const Dir &dir)
Geom::Pnt::operator+
Pnt operator+(const Geom::Pnt &other) const
Geom::Pnt::operator-
Pnt operator-(const Geom::Pnt &other) const
Geom::Pnt::xyz
const Geom::XYZ & xyz() const
For this point, returns its three coordinates as a number triple.
Geom
Definition: PropertyContainer.h:33