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