OpenLexocad  27.0
GeometricTools.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Geom/Ax1.h>
4 #include <Geom/Ax2.h>
5 #include <Geom/Dir.h>
6 #include <Geom/GeomEnums.h>
7 #include <Geom/Lin.h>
8 #include <Geom/Pln.h>
9 #include <Geom/Pnt.h>
10 #include <Geom/Trsf.h>
11 #include <Geom/Vec.h>
12 #include <Geom/Vec2d.h>
13 #include <Geom/XYZ.h>
14 #include <Geom/geom_defines.h>
15 
16 #include <iostream>
17 #include <vector>
18 
19 
20 namespace Geom
21 {
23 {
24 public:
25  GeometricTools(void);
26  ~GeometricTools(void);
27 
29  static Geom::Dir getFaceNormal(const COORDS& face);
30  static Geom::Dir getFaceNormal(const std::vector<Geom::Pnt>& face);
31 
33  static Geom::Dir getNFaceNormal(const std::vector<Geom::Pnt>& face);
34  static Geom::Dir getNFaceNormal(const COORDS& face);
35  // Newell's method without exceptions
36  static bool getNFaceNormalNoExc(const std::vector<Geom::Pnt>& face, Geom::Dir& dir);
37 
43  static Geom::Dir getConcaveFaceNormalXY(const std::vector<Geom::Pnt>& face);
44 
45  static bool getNonColinearEdges(const COORDS& face, Geom::Vec& edge1, Geom::Vec& edge2);
46  static int savePoint(const Geom::XYZ& p, COORDS& points);
47  static bool isEqual(double d1, double d2, double tolerance = 1E-06);
48  static bool isEqual(const Geom::XYZ& v1, const Geom::XYZ& v2, double tolerance = 1E-06);
49  static bool isEqual(const Geom::Dir& d1, const Geom::Dir& d2, double tolerance = 1E-06);
50  static bool isEqual(const Geom::Vec& v1, const Geom::Vec& v2, double tolerance = 1E-06);
51  static bool isEqual(const Geom::Pnt& p1, const Geom::Pnt& p2, double tolerance = 1E-06);
52  static double roundValue(double value, double roundValue);
53 #ifndef LXAPI // NOT PART OF THE LEXOCAD API (FOR LXSDK AND SWIG)
54  static float roundfValue(float value, float roundValue);
55 #endif
56  static double round(double value, int digits);
57  static double roundValueOffset(const double& coord, const double& valueToRound, const double& roundToValue);
58  static bool isEven(const int Value) { return Value % 2 == 0; }
59  static bool isOdd(const int Value) { return Value % 2 == 1; }
60  static int factorial(int x) { return x > 1 ? x * factorial(x - 1) : 1; }
61  static bool getMedianPlaneFromPoints(const std::vector<Geom::Pnt>& points, Geom::Pln& pln);
62 
63 private:
64  static bool _calculateNonColinearEdges(const COORDS& face, Geom::Vec& edge1, Geom::Vec& edge2);
65  static Geom::Dir _getNewellNormal(const COORDS& face);
66  static bool _getPredominantEdgesDirXY(const COORDS& face, Geom::Dir& normal);
67 
68  // To get the face normal
69  static int _checkFaceCounter;
70  static unsigned int _checkEdgeIndex;
71 };
72 
73 } // namespace Geom
74 
75 
76 GEOM_EXPORT std::ostream& operator<<(std::ostream& o, const Geom::Vec& vec);
77 GEOM_EXPORT std::ostream& operator<<(std::ostream& o, const Geom::Dir& dir);
78 GEOM_EXPORT std::ostream& operator<<(std::ostream& o, const Geom::Pln& dir);
79 GEOM_EXPORT std::ostream& operator<<(std::ostream& o, const Geom::Pnt& pnt);
80 GEOM_EXPORT std::ostream& operator<<(std::ostream& o, const Geom::Vec2d& pnt);
81 GEOM_EXPORT std::ostream& operator<<(std::ostream& o, const Geom::XYZ& xyz);
82 GEOM_EXPORT std::ostream& operator<<(std::ostream& o, const Geom::Ax2& placement);
83 GEOM_EXPORT std::ostream& operator<<(std::ostream& o, const Geom::Trsf& t);
Definition: Rotation.h:5
Definition: Pln.h:59
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:42
Definition: GeometricTools.h:22
std::vector< Geom::XYZ > COORDS
Definition: XYZ.h:35
#define GEOM_EXPORT
Definition: geom_defines.h:8
static bool isEven(const int Value)
Definition: GeometricTools.h:58
Definition: Ax2.h:69
Definition: XYZ.h:46
Definition: Trsf.h:58
Definition: Dir.h:46
GEOM_EXPORT std::ostream & operator<<(std::ostream &o, const Geom::Vec &vec)
static int factorial(int x)
Definition: GeometricTools.h:60
Defines a non-persistent vector in 2D space.
Definition: Vec2d.h:34
static bool isOdd(const int Value)
Definition: GeometricTools.h:59
Defines a non-persistent vector in 3D space.
Definition: Vec.h:45