CFx SDK Documentation  2020SP3
TrVisDefs.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, 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 Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 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 // GLES2 device definitions
24 
25 #ifndef ODTRVISDEVICEDEFINITIONS
26 #define ODTRVISDEVICEDEFINITIONS
27 
28 #include "TD_PackPush.h"
29 
30 #include "Ge/GePoint3d.h"
31 #include "Gs/Gs.h"
32 
33 #ifndef OD_FORCEINLINE
34 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
35 #define OD_FORCEINLINE __forceinline
36 #elif defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
37 #define OD_FORCEINLINE inline __attribute__((always_inline))
38 #elif defined(__APPLE__) && !defined(__GNUC__)
39 #define OD_FORCEINLINE inline __attribute__((always_inline))
40 #else
41 #define OD_FORCEINLINE inline
42 #endif
43 #endif // OD_FORCEINLINE
44 
45 #if (__cplusplus > 199711L) || (_MSC_VER > 1700)
46 #define OD_CPP0X_SUPPORTED
47 #endif
48 
49 #ifndef OD_CONSTEXPR
50 #ifdef OD_CPP0X_SUPPORTED
51 #define OD_CONSTEXPR_FUNC constexpr
52 #define OD_CONSTEXPR constexpr
53 #else
54 #define OD_CONSTEXPR_FUNC OD_FORCEINLINE
55 #define OD_CONSTEXPR
56 #endif
57 #endif // OD_CONSTEXPR
58 
64 {
67  void setSyncFlag(OdUInt32 flag) { SETBIT_1(m_syncFlags, flag); }
68  bool isSyncFlagSet(OdUInt32 flag) const { return GETBIT(m_syncFlags, flag); }
69  void resetSyncFlag(OdUInt32 flag) { SETBIT_0(m_syncFlags, flag); }
70  void resetSyncFlags() { m_syncFlags = 0; }
71  void setSyncAll() { m_syncFlags = 0xFFFFFFFF; }
72  bool isSynchronized() const { return m_syncFlags == 0; }
73 };
74 
75 // GsMarker
76 
80 inline bool isValidMarker(OdTrVisGsMarker marker)
81 { return marker != kTrVisNullGsMarker; }
82 
83 // Internal ID's
84 
86 
88 
91 
94 
96 
98 
100 
102 
104 
106 
107 #define OdTrVisPtrToId(ptr) ((OdTrVisId)((OdIntPtr)ptr))
108 #define OdTrVisIdToPtr(ptrType, id) ((ptrType*)(OdIntPtr)(id))
109 
112 {
113  return id != kTrVisNegativeId;
114 }
115 
118 {
119  return id != kTrVisNullId;
120 }
121 
124 {
125  return id != kTrVisMainOverlayId;
126 }
127 
130 {
131  return id != kTrVisNegativeArrayId;
132 }
133 
135 
141 {
142  OdUInt8 r, g, b, a;
143  bool operator ==(const OdTrVisColorRGBA &sec) const
144  { return (r == sec.r) && (g == sec.g) && (b == sec.b) && (a == sec.a); }
145  bool operator !=(const OdTrVisColorRGBA &sec) const
146  { return (r != sec.r) || (g != sec.g) || (b != sec.b) || (a != sec.a); }
148  r = _r; g = _g; b = _b; a = _a; return *this; }
149  OdTrVisColorRGBA &set_r(OdUInt8 _r) { r = _r; return *this; }
150  OdTrVisColorRGBA &set_g(OdUInt8 _g) { g = _g; return *this; }
151  OdTrVisColorRGBA &set_b(OdUInt8 _b) { b = _b; return *this; }
152  OdTrVisColorRGBA &set_a(OdUInt8 _a) { a = _a; return *this; }
153  OdTrVisColorRGBA &setCRef(ODCOLORREF color) { r = ODGETRED(color); g = ODGETGREEN(color);
154  b = ODGETBLUE(color); a = ODGETALPHA(color); return *this; }
155  void setFlt(float _r, float _g, float _b, float _a) { r = (OdUInt8)(_r * 255); g = (OdUInt8)(_g * 255);
156  b = (OdUInt8)(_b * 255); a = (OdUInt8)(_a * 255); }
157  void asFlt(float &_r, float &_g, float &_b, float _a) const { _r = float(r) / 255; _g = float(g) / 255; _b = float(b) / 255; _a = float(a) / 255; }
158  ODCOLORREF asCRef() const { return ODRGBA(r, g, b, a); }
159  const OdUInt8 *asArray() const { return &r; }
160  // Color representations
162  void setRep(const OdTrVisColorRGBA &clr, ColorRep rep, OdUInt8 alpha = 255)
163  { switch (rep) {
164  case kRGBA: *this = clr; break; case kBGRA: r = clr.b; g = clr.g; b = clr.r; a = clr.a; break;
165  case kARGB: r = clr.g; g = clr.b; b = clr.a; a = clr.r; break; case kABGR: r = clr.a; g = clr.b; b = clr.g; a = clr.r; break;
166  case kRGBX: r = clr.r; g = clr.g; b = clr.b; a = alpha; break; case kBGRX: r = clr.b; g = clr.g; b = clr.r; a = alpha; break;
167  case kXRGB: r = clr.g; g = clr.b; b = clr.a; a = alpha; break; case kXBGR: r = clr.a; g = clr.b; b = clr.g; a = alpha; break;
168  } }
169  void getRep(OdTrVisColorRGBA &clr, ColorRep rep, OdUInt8 alpha = 255) const
170  { switch (rep) {
171  case kRGBA: clr = *this; break; case kBGRA: clr.r = b; clr.g = g; clr.b = r; clr.a = a; break;
172  case kARGB: clr.r = a; clr.g = r; clr.b = g; clr.a = b; break; case kABGR: clr.r = a; clr.g = b; clr.b = g; clr.a = r; break;
173  case kRGBX: clr.r = r; clr.g = g; clr.b = b; clr.a = alpha; break; case kBGRX: clr.r = b; clr.g = g; clr.b = r; clr.a = alpha; break;
174  case kXRGB: clr.r = alpha; clr.g = r; clr.b = g; clr.a = b; break; case kXBGR: clr.r = alpha; clr.g = b; clr.b = g; clr.a = r; break;
175  } }
176  OdTrVisColorRGBA getRep(ColorRep rep, OdUInt8 alpha = 255) const { OdTrVisColorRGBA getter; getRep(getter, rep, alpha); return getter; }
177 };
178 
184 {
185  float entry[4][4];
186 };
187 
189 
195 {
196  float entry[3][3];
198  {
199  entry[0][0] = entry[0][1] = entry[0][2] = 0.0f;
200  entry[1][0] = entry[1][1] = 0.0f; entry[1][2] = 1.0f;
201  entry[2][0] = entry[2][1] = entry[2][2] = 0.0f;
202  }
204  {
205  entry[0][0] = (float)position.x; entry[0][1] = (float)position.y; entry[0][2] = (float)position.z;
206  entry[1][0] = (float)normal.x; entry[1][1] = (float)normal.y; entry[1][2] = (float)normal.z;
207  }
208  OdGePoint3d position() const { return OdGePoint3d(entry[0][0], entry[0][1], entry[0][2]); }
209  OdGeVector3d normal() const { return OdGeVector3d(entry[1][0], entry[1][1], entry[1][2]); }
210  void transformBy(const OdGeMatrix3d &xfm) { set(xfm * position(), xfm * normal()); }
211 };
212 
214 
215 #define OD_TRVIS_OPAQUE(color) ((color) | 0xFF000000)
216 #define OD_TRVIS_TRANSPARENT(color) ((color) & 0x00FFFFFF)
217 #define OD_TRVIS_SETALPHA(color, alpha) (OD_TRVIS_TRANSPARENT(color) | (ODCOLORREF(alpha) << 24))
218 
219 // FP comparison functions
220 
221 OD_FORCEINLINE bool OdTrVisFPEqual(float a, float b, float tol = 1.e-8f)
222 {
223  const float dif = a - b;
224  return (dif < tol) && (dif > -tol);
225 }
226 OD_FORCEINLINE bool OdTrVisFPZero(float a, float tol = 1.e-8f)
227 {
228  return !(a > tol) && !(a < -tol);
229 }
230 
236 {
237  public:
238  OdRxObjectPtr create() const { return OdRxObjectPtr(); }
239  const OdString appName() const { return OdString::kEmpty; }
241  const OdString dxfName() const { return OdString::kEmpty; }
242  const OdString name() const { return OdString::kEmpty; }
244  OdUInt32 proxyFlags() const { return 0; }
245  OdUInt32 customFlags() const { return 0; }
246  OdRxClass* myParent() const { return OdRxClass::desc(); }
247  OdRxModule* module() const { return NULL; }
249  OdRxOverruleIterator* getOverrule(OverrulingType t) const { return 0; }
250  void setOverrule(OdRxOverruleIterator* pIt, OverrulingType t) {}
251 };
252 
253 #include "TD_PackPop.h"
254 
255 #endif // ODTRVISDEVICEDEFINITIONS
GETBIT
#define GETBIT(flags, bit)
Definition: OdaDefs.h:498
kTrVisNegativeId
const OdTrVisId kTrVisNegativeId
Definition: TrVisDefs.h:110
OdTrVisMatrixArray
OdArray< OdTrVisMatrix, OdMemoryAllocator< OdTrVisMatrix > > OdTrVisMatrixArray
Definition: TrVisDefs.h:188
OdTrVisColorRGBA::set_b
OdTrVisColorRGBA & set_b(OdUInt8 _b)
Definition: TrVisDefs.h:151
OdTrVisSyncFlags::resetSyncFlag
void resetSyncFlag(OdUInt32 flag)
Definition: TrVisDefs.h:69
OdDb::kDHL_CURRENT
@ kDHL_CURRENT
Definition: OdaDefs.h:101
OdGeVector3d
Definition: GeVector3d.h:54
OdString
Definition: OdString.h:95
NULL
#define NULL
Definition: GsProperties.h:177
OdRxObjectPtr
Definition: RxObject.h:345
OdTrVisColorRGBA::b
OdUInt8 b
Definition: TrVisDefs.h:142
OdUInt8
unsigned char OdUInt8
Definition: OdPlatformSettings.h:759
OdTrVisColorRGBA::setRep
void setRep(const OdTrVisColorRGBA &clr, ColorRep rep, OdUInt8 alpha=255)
Definition: TrVisDefs.h:162
OdTrVisColorRGBA::asCRef
ODCOLORREF asCRef() const
Definition: TrVisDefs.h:158
tol
tol
Definition: DimVarDefs.h:2287
SETBIT_1
#define SETBIT_1(flags, bit)
Definition: OdaDefs.h:501
OdGeVector3d::x
double x
Definition: GeVector3d.h:601
OdTrVisDescStub::getOverrule
OdRxOverruleIterator * getOverrule(OverrulingType t) const
Definition: TrVisDefs.h:249
OdTrVisVisualStyleId
OdTrVisId OdTrVisVisualStyleId
Definition: TrVisDefs.h:101
OdTrVisColorRGBA::getRep
void getRep(OdTrVisColorRGBA &clr, ColorRep rep, OdUInt8 alpha=255) const
Definition: TrVisDefs.h:169
isValidMarker
bool isValidMarker(OdTrVisGsMarker marker)
Definition: TrVisDefs.h:80
OdTrVisColorRGBA::kXBGR
@ kXBGR
Definition: TrVisDefs.h:161
OdGeVector3d::z
double z
Definition: GeVector3d.h:603
OdTrVisColorRGBA::kXRGB
@ kXRGB
Definition: TrVisDefs.h:161
OdTrVisColorRGBA::ColorRep
ColorRep
Definition: TrVisDefs.h:161
ODGETBLUE
#define ODGETBLUE(rgb)
Definition: OdPlatform.h:889
OdTrVisColorRGBA::kARGB
@ kARGB
Definition: TrVisDefs.h:161
OdTrVisColorRGBA::setFlt
void setFlt(float _r, float _g, float _b, float _a)
Definition: TrVisDefs.h:155
OdTrVisColorRGBA::operator!=
bool operator!=(const OdTrVisColorRGBA &sec) const
Definition: TrVisDefs.h:145
OdTrVisMatrix
Definition: TrVisDefs.h:184
OdTrVisSyncFlags
Definition: TrVisDefs.h:64
OdTrVisDisplayId
OdTrVisId OdTrVisDisplayId
Definition: TrVisDefs.h:97
OdTrVisSectionPlane::set
void set(OdGePoint3d position, OdGeVector3d normal)
Definition: TrVisDefs.h:203
AppNameChangeFuncPtr
void(* AppNameChangeFuncPtr)(const OdRxClass *classObj, OdString &newAppName, int saveVer)
Definition: RxObject.h:44
OdGePoint3d::y
double y
Definition: GePoint3d.h:368
OdArray
Definition: OdArray.h:591
OdGePoint3d::x
double x
Definition: GePoint3d.h:367
TD_PackPop.h
OdTrVisColorRGBA::g
OdUInt8 g
Definition: TrVisDefs.h:142
OdTrVisColorRGBA::set_r
OdTrVisColorRGBA & set_r(OdUInt8 _r)
Definition: TrVisDefs.h:149
OdTrVisColorRGBA::a
OdUInt8 a
Definition: TrVisDefs.h:142
OdTrVisDescStub::appName
const OdString appName() const
Definition: TrVisDefs.h:239
ODGETALPHA
#define ODGETALPHA(rgba)
Definition: OdPlatform.h:890
OdTrVisGsMarkerArray
OdArray< OdTrVisGsMarker, OdMemoryAllocator< OdTrVisGsMarker > > OdTrVisGsMarkerArray
Definition: TrVisDefs.h:78
isValidTrVisArrayId
OD_FORCEINLINE bool isValidTrVisArrayId(OdTrVisArrayId id)
Definition: TrVisDefs.h:129
OverrulingType
OverrulingType
Definition: RxObject.h:820
OdTrVisDescStub::customFlags
OdUInt32 customFlags() const
Definition: TrVisDefs.h:245
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdGeMatrix3d
Definition: GeMatrix3d.h:73
OdTrVisSyncFlags::m_syncFlags
OdUInt32 m_syncFlags
Definition: TrVisDefs.h:65
OdFloatArray
OdArray< float, OdMemoryAllocator< float > > OdFloatArray
Definition: TrVisDefs.h:134
OdDb::DwgVersion
DwgVersion
Definition: OdaDefs.h:46
ODGETRED
#define ODGETRED(rgb)
Definition: OdPlatform.h:887
OdTrVisColorRGBA::set_a
OdTrVisColorRGBA & set_a(OdUInt8 _a)
Definition: TrVisDefs.h:152
OdTrVisColorRGBA::set_g
OdTrVisColorRGBA & set_g(OdUInt8 _g)
Definition: TrVisDefs.h:150
OdTrVisDescStub::getClassVersion
OdDb::DwgVersion getClassVersion(OdDb::MaintReleaseVer *=0) const
Definition: TrVisDefs.h:243
OdTrVisSectionPlane::transformBy
void transformBy(const OdGeMatrix3d &xfm)
Definition: TrVisDefs.h:210
OdTrVisColorRGBA::operator==
bool operator==(const OdTrVisColorRGBA &sec) const
Definition: TrVisDefs.h:143
OdRxClass
Definition: RxObject.h:865
isNullTrVisId
OD_FORCEINLINE bool isNullTrVisId(OdTrVisId id)
Definition: TrVisDefs.h:117
OdTrVisSyncFlags::setSyncAll
void setSyncAll()
Definition: TrVisDefs.h:71
OdTrVisColorRGBA::kBGRX
@ kBGRX
Definition: TrVisDefs.h:161
OdDb::MaintReleaseVer
MaintReleaseVer
Definition: OdaDefs.h:107
OdTrVisColorRGBA::kRGBX
@ kRGBX
Definition: TrVisDefs.h:161
OdGePoint3d
Definition: GePoint3d.h:55
SETBIT_0
#define SETBIT_0(flags, bit)
Definition: OdaDefs.h:500
OdTrVisLayerId
OdTrVisId OdTrVisLayerId
Definition: TrVisDefs.h:103
OdTrVisFPZero
OD_FORCEINLINE bool OdTrVisFPZero(float a, float tol=1.e-8f)
Definition: TrVisDefs.h:226
OdTrVisColorRGBA::kBGRA
@ kBGRA
Definition: TrVisDefs.h:161
OdTrVisColorRGBA::set
OdTrVisColorRGBA & set(OdUInt8 _r, OdUInt8 _g, OdUInt8 _b, OdUInt8 _a)
Definition: TrVisDefs.h:147
OD_FORCEINLINE
#define OD_FORCEINLINE
Definition: TrVisDefs.h:41
GePoint3d.h
kTrVisNullGsMarker
const OdTrVisGsMarker kTrVisNullGsMarker
Definition: TrVisDefs.h:79
OdTrVisSectionPlane::position
OdGePoint3d position() const
Definition: TrVisDefs.h:208
Gs.h
OdTrVisDescStub::proxyFlags
OdUInt32 proxyFlags() const
Definition: TrVisDefs.h:244
ODGETGREEN
#define ODGETGREEN(rgb)
Definition: OdPlatform.h:888
OdTrVisTextureId
OdTrVisId OdTrVisTextureId
Definition: TrVisDefs.h:92
OdTrVisSectionPlaneArray
OdArray< OdTrVisSectionPlane, OdMemoryAllocator< OdTrVisSectionPlane > > OdTrVisSectionPlaneArray
Definition: TrVisDefs.h:213
isMainTrVisOverlayId
OD_FORCEINLINE bool isMainTrVisOverlayId(OdTrVisId id)
Definition: TrVisDefs.h:123
OdTrVisColorRGBA::asFlt
void asFlt(float &_r, float &_g, float &_b, float _a) const
Definition: TrVisDefs.h:157
OdTrVisColorRGBA::asArray
const OdUInt8 * asArray() const
Definition: TrVisDefs.h:159
OdTrVisDescStub
Definition: TrVisDefs.h:236
OdTrVisDescStub::setConstructor
void setConstructor(OdPseudoConstructorType)
Definition: TrVisDefs.h:248
OdTrVisDescStub::name
const OdString name() const
Definition: TrVisDefs.h:242
TD_PackPush.h
OdTrVisFPEqual
OD_FORCEINLINE bool OdTrVisFPEqual(float a, float b, float tol=1.e-8f)
Definition: TrVisDefs.h:221
OdTrVisDescStub::create
OdRxObjectPtr create() const
Definition: TrVisDefs.h:238
OdTrVisSyncFlags::isSynchronized
bool isSynchronized() const
Definition: TrVisDefs.h:72
OdTrVisMatrix::entry
float entry[4][4]
Definition: TrVisDefs.h:185
OdTrVisSyncFlags::resetSyncFlags
void resetSyncFlags()
Definition: TrVisDefs.h:70
OdTrVisSyncFlags::isSyncFlagSet
bool isSyncFlagSet(OdUInt32 flag) const
Definition: TrVisDefs.h:68
kNullSubentIndex
const OdGsMarker kNullSubentIndex
Definition: Gs.h:1426
OdTrVisColorRGBA::kRGBA
@ kRGBA
Definition: TrVisDefs.h:161
kTrVisNegativeArrayId
const OdTrVisArrayId kTrVisNegativeArrayId
Definition: TrVisDefs.h:128
OdTrVisMaterialId
OdTrVisId OdTrVisMaterialId
Definition: TrVisDefs.h:93
OdGePoint3d::z
double z
Definition: GePoint3d.h:369
OdTrVisId
OdUInt64 OdTrVisId
Definition: TrVisDefs.h:85
OdTrVisSectionPlane::OdTrVisSectionPlane
OdTrVisSectionPlane()
Definition: TrVisDefs.h:197
OdTrVisOverlayId
OdTrVisId OdTrVisOverlayId
Definition: TrVisDefs.h:105
isValidTrVisId
OD_FORCEINLINE bool isValidTrVisId(OdTrVisId id)
Definition: TrVisDefs.h:111
OdTrVisMetafileId
OdTrVisId OdTrVisMetafileId
Definition: TrVisDefs.h:89
OdTrVisColorRGBA::kABGR
@ kABGR
Definition: TrVisDefs.h:161
f
GLfloat f
Definition: gles2_ext.h:564
OdTrVisHlBranchId
OdTrVisId OdTrVisHlBranchId
Definition: TrVisDefs.h:99
kTrVisNullId
const OdTrVisId kTrVisNullId
Definition: TrVisDefs.h:116
ODRGBA
#define ODRGBA(r, g, b, a)
Definition: OdPlatform.h:885
OdRxModule
Definition: RxModule.h:45
ODCOLORREF
#define ODCOLORREF
Definition: OdPlatform.h:883
OdTrVisColorRGBA::setCRef
OdTrVisColorRGBA & setCRef(ODCOLORREF color)
Definition: TrVisDefs.h:153
OdTrVisSectionPlane::normal
OdGeVector3d normal() const
Definition: TrVisDefs.h:209
OdTrVisSyncFlags::OdTrVisSyncFlags
OdTrVisSyncFlags()
Definition: TrVisDefs.h:66
OdTrVisProgramId
OdTrVisId OdTrVisProgramId
Definition: TrVisDefs.h:95
OdString::kEmpty
FIRSTDLL_EXPORT_STATIC static const OdString kEmpty
Definition: OdString.h:98
kTrVisMainOverlayId
const OdTrVisId kTrVisMainOverlayId
Definition: TrVisDefs.h:122
OdTrVisSyncFlags::setSyncFlag
void setSyncFlag(OdUInt32 flag)
Definition: TrVisDefs.h:67
OdTrVisViewportId
OdTrVisId OdTrVisViewportId
Definition: TrVisDefs.h:87
OdGeVector3d::y
double y
Definition: GeVector3d.h:602
OdTrVisSectionPlane::entry
float entry[3][3]
Definition: TrVisDefs.h:196
OdTrVisDescStub::dxfName
const OdString dxfName() const
Definition: TrVisDefs.h:241
alpha
GLfloat GLfloat GLfloat alpha
Definition: gles2_ext.h:147
OdTrVisDescStub::appNameCallbackPtr
AppNameChangeFuncPtr appNameCallbackPtr() const
Definition: TrVisDefs.h:240
OdTrVisDescStub::module
OdRxModule * module() const
Definition: TrVisDefs.h:247
OdTrVisArrayId
OdUInt32 OdTrVisArrayId
Definition: TrVisDefs.h:90
OdTrVisColorRGBA::r
OdUInt8 r
Definition: TrVisDefs.h:142
OdTrVisSectionPlane
Definition: TrVisDefs.h:195
OdRxObject::desc
static OdRxClass * desc()
OdTrVisDescStub::myParent
OdRxClass * myParent() const
Definition: TrVisDefs.h:246
OdTrVisDescStub::setOverrule
void setOverrule(OdRxOverruleIterator *pIt, OverrulingType t)
Definition: TrVisDefs.h:250
OdTrVisColorRGBA
Definition: TrVisDefs.h:141
OdTrVisGsMarker
OdUInt64 OdTrVisGsMarker
Definition: TrVisDefs.h:77
OdTrVisColorRGBA::getRep
OdTrVisColorRGBA getRep(ColorRep rep, OdUInt8 alpha=255) const
Definition: TrVisDefs.h:176
OdUInt64
Definition: Int64.h:137
OdPseudoConstructorType
OdRxObjectPtr(* OdPseudoConstructorType)()
Definition: RxObject.h:849