CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
AECUtils.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a
16// license agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24#ifndef __AECUTILS_H__
25#define __AECUTILS_H__
26
27#include <set>
28#include "Ge/GePoint3d.h"
29#include "Ge/GePoint2d.h"
30#include "Ge/GeVector3d.h"
31#include "Modeler/FMDrawBody.h"
33#include "Ge/GeGbl.h"
34#include <sstream>
35
36namespace AecUtils
37{
39 {
40 bool operator()(const OdGeVector3d& a, const OdGeVector3d& b) const
41 {
42 if (OdEqual(a.x, b.x))
43 {
44 if (OdEqual(a.y, b.y))
45 return OdGreater(a.z, b.z);
46 else
47 return OdGreater(a.y, b.y);
48 }
49 else return OdGreater(a.x, b.x);
50 }
51 };
52
54 {
55 public:
57 AecVector3d(const OdGeVector3d &vector3d): OdGeVector3d(vector3d){}
58
59 bool operator <(const AecVector3d& a) const
60 {
61 return OdGeVector3dComparator()(a, *this);
62 }
63
65 if(isZeroLength())
66 return *this;
67
69 }
70
72 {
73 z = 0;
74 if (isZeroLength())
75 return *this;
76
77 *this = normalize();
78 return *this;
79 }
80
82 {
83 return v.dotProduct(*this) * *this;
84 }
85 };
86
87 typedef std::set<OdGeVector3d, AecUtils::OdGeVector3dComparator> OdGeVector3dSet;
88
90 {
91 bool operator()(const OdGePoint3d& a, const OdGePoint3d& b) const
92 {
93 if (OdEqual(a.x, b.x))
94 {
95 if (OdEqual(a.y, b.y))
96 return OdGreater(a.z, b.z);
97 else
98 return OdGreater(a.y, b.y);
99 }
100 else return OdGreater(a.x, b.x);
101 }
102 };
103
104 typedef std::set<OdGePoint3d, AecUtils::OdGePoint3dComparator> OdGePoint3dSet;
105
107 {
108 bool operator()(const OdGePoint2d& a, const OdGePoint2d& b) const
109 {
110 if (OdEqual(a.x, b.x))
111 return OdGreater(a.y, b.y);
112 else return OdGreater(a.x, b.x);
113 }
114 };
115
117 {
118 return OdGeVector3d(pt.x, pt.y, pt.z);
119 }
120
122 {
123 return OdGeVector3d(v.x, v.y, 0);
124 }
125
127 {
128 return OdGePoint3d(v.x, v.y, 0);
129 }
130
132 double dMin,
133 double dMax,
134 double dValue,
135 bool bIncludeMin = true,
136 bool bIncludeMax = true,
137 double dTol = 1.e-10)
138 {
139 bool belowMax = bIncludeMax ?
140 OdGreaterOrEqual(dMax, dValue, dTol) :
141 OdGreater(dMax, dValue, dTol);
142
143 bool aboveMin = bIncludeMin ?
144 OdLessOrEqual(dMin, dValue, dTol) :
145 OdLess(dMin, dValue, dTol);
146
147 return belowMax && aboveMin;
148 }
149
150 inline OdString numberToString(int number)
151 {
152 std::ostringstream ss;
153 ss << number;
154 return ss.str().c_str();
155 }
156}
157
158#endif // __AECUTILS_H__
bool OdEqual(double x, double y, double tol=1.e-10)
Definition OdaDefs.h:542
bool OdLessOrEqual(double x, double y, double tol=1.e-10)
Definition OdaDefs.h:552
bool OdLess(double x, double y, double tol=1.e-10)
Definition OdaDefs.h:547
bool OdGreater(double x, double y, double tol=1.e-10)
Definition OdaDefs.h:557
bool OdGreaterOrEqual(double x, double y, double tol=1.e-10)
Definition OdaDefs.h:562
OdGeVector3d projectToVector(const OdGeVector3d &v)
Definition AECUtils.h:81
OdGeVector3d perpVector() const
Definition AECUtils.h:64
AecVector3d(const OdGeVector3d &vector3d)
Definition AECUtils.h:57
AecVector3d & projectOnXY()
Definition AECUtils.h:71
bool operator<(const AecVector3d &a) const
Definition AECUtils.h:59
bool isZeroLength(const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector3d perpVector() const
OdGeVector3d & normalize(const OdGeTol &tol=OdGeContext::gTol)
const OdChar * c_str() const
Definition OdString.h:205
const GLfloat * v
Definition gles2_ext.h:315
OdString numberToString(int number)
Definition AECUtils.h:150
bool checkValueInsideRange(double dMin, double dMax, double dValue, bool bIncludeMin=true, bool bIncludeMax=true, double dTol=1.e-10)
Definition AECUtils.h:131
OdGeVector3d toVector(const OdGePoint3d &pt)
Definition AECUtils.h:116
OdGeVector3d to3d(const OdGeVector2d &v)
Definition AECUtils.h:121
std::set< OdGePoint3d, AecUtils::OdGePoint3dComparator > OdGePoint3dSet
Definition AECUtils.h:104
std::set< OdGeVector3d, AecUtils::OdGeVector3dComparator > OdGeVector3dSet
Definition AECUtils.h:87
bool operator()(const OdGePoint2d &a, const OdGePoint2d &b) const
Definition AECUtils.h:108
bool operator()(const OdGePoint3d &a, const OdGePoint3d &b) const
Definition AECUtils.h:91
bool operator()(const OdGeVector3d &a, const OdGeVector3d &b) const
Definition AECUtils.h:40