CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TrVisDefs.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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#if defined(_MSC_VER) && (_MSC_VER < 1900)
48#define OD_CPP0X_PARTIAL_SUPPORT
49#endif
50#endif
51
52#ifndef OD_CONSTEXPR
53#if defined(OD_CPP0X_SUPPORTED) && !defined(OD_CPP0X_PARTIAL_SUPPORT)
54#define OD_CONSTEXPR_FUNC constexpr
55#define OD_CONSTEXPR constexpr
56#else
57#define OD_CONSTEXPR_FUNC OD_FORCEINLINE
58#define OD_CONSTEXPR
59#endif
60#endif // OD_CONSTEXPR
61
62// Main type includes.
63#include "TrVisMatrix.h"
64#include "TrVisIval.h"
65
71{
75 bool isSyncFlagSet(OdUInt32 flag) const { return GETBIT(m_syncFlags, flag); }
78 void setSyncAll() { m_syncFlags = 0xFFFFFFFF; }
79 bool isSynchronized() const { return m_syncFlags == 0; }
80};
81
82// GsMarker
83
87inline bool isValidMarker(OdTrVisGsMarker marker)
88{ return marker != kTrVisNullGsMarker; }
89
90// Database owning (it is depends from underlying database)
92
93// Internal ID's
94
96
98
101
104
106
108
110
112
114
116
118
120
122
124
125#define OdTrVisPtrToId(ptr) ((OdTrVisId)((OdIntPtr)ptr))
126#define OdTrVisIdToPtr(ptrType, id) ((ptrType*)(OdIntPtr)(id))
127
130{
131 return id != kTrVisNegativeId;
132}
133
136{
137 return id == kTrVisNullId;
138}
139
142{
143 return id == kTrVisMainOverlayId;
144}
145
148{
149 return id != kTrVisNegativeArrayId;
150}
151
152// State branch types
153
155{
158
161
162typedef const void *OdTrVisStateBranchPtr;
163
169{
171 bool operator ==(const OdTrVisColorRGBA &sec) const
172 { return (r == sec.r) && (g == sec.g) && (b == sec.b) && (a == sec.a); }
173 bool operator !=(const OdTrVisColorRGBA &sec) const
174 { return (r != sec.r) || (g != sec.g) || (b != sec.b) || (a != sec.a); }
176 r = _r; g = _g; b = _b; a = _a; return *this; }
177 OdTrVisColorRGBA &set_r(OdUInt8 _r) { r = _r; return *this; }
178 OdTrVisColorRGBA &set_g(OdUInt8 _g) { g = _g; return *this; }
179 OdTrVisColorRGBA &set_b(OdUInt8 _b) { b = _b; return *this; }
180 OdTrVisColorRGBA &set_a(OdUInt8 _a) { a = _a; return *this; }
182 b = ODGETBLUE(color); a = ODGETALPHA(color); return *this; }
183 void setFlt(float _r, float _g, float _b, float _a) { r = (OdUInt8)(_r * 255); g = (OdUInt8)(_g * 255);
184 b = (OdUInt8)(_b * 255); a = (OdUInt8)(_a * 255); }
185 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; }
186 ODCOLORREF asCRef() const { return ODRGBA(r, g, b, a); }
187 const OdUInt8 *asArray() const { return &r; }
188 // Color representations
190 void setRep(const OdTrVisColorRGBA &clr, ColorRep rep, OdUInt8 alpha = 255)
191 { switch (rep) {
192 case kRGBA: *this = clr; break; case kBGRA: r = clr.b; g = clr.g; b = clr.r; a = clr.a; break;
193 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;
194 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;
195 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;
196 } }
197 void getRep(OdTrVisColorRGBA &clr, ColorRep rep, OdUInt8 alpha = 255) const
198 { switch (rep) {
199 case kRGBA: clr = *this; break; case kBGRA: clr.r = b; clr.g = g; clr.b = r; clr.a = a; break;
200 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;
201 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;
202 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;
203 } }
204 OdTrVisColorRGBA getRep(ColorRep rep, OdUInt8 alpha = 255) const { OdTrVisColorRGBA getter; getRep(getter, rep, alpha); return getter; }
205};
206
212{
214 {
215 entry[0][0] = entry[0][1] = entry[0][2] = 0.0f;
216 entry[1][0] = entry[1][1] = 0.0f; entry[1][2] = 1.0f;
217 entry[2][0] = entry[2][1] = entry[2][2] = 0.0f;
218 }
220 {
222 }
224 {
225 entry[0][0] = (EntryType)position.x; entry[0][1] = (EntryType)position.y; entry[0][2] = (EntryType)position.z;
226 entry[1][0] = (EntryType)normal.x; entry[1][1] = (EntryType)normal.y; entry[1][2] = (EntryType)normal.z;
227 }
228 OdGePoint3d position() const { return OdGePoint3d(entry[0][0], entry[0][1], entry[0][2]); }
229 OdGeVector3d normal() const { return OdGeVector3d(entry[1][0], entry[1][1], entry[1][2]); }
230 void transformBy(const OdGeMatrix3d &xfm) { set(xfm * position(), xfm * normal()); }
231};
232
234
235#define OD_TRVIS_OPAQUE(color) ((color) | 0xFF000000)
236#define OD_TRVIS_TRANSPARENT(color) ((color) & 0x00FFFFFF)
237#define OD_TRVIS_SETALPHA(color, alpha) (OD_TRVIS_TRANSPARENT(color) | (ODCOLORREF(alpha) << 24))
238
239// FP comparison functions
240
241OD_FORCEINLINE bool OdTrVisFPEqual(float a, float b, float tol = 1.e-8f)
242{
243 const float dif = a - b;
244 return (dif < tol) && (dif > -tol);
245}
246OD_FORCEINLINE bool OdTrVisFPZero(float a, float tol = 1.e-8f)
247{
248 return !(a > tol) && !(a < -tol);
249}
250
252
253// Clamping
254
255template <typename Type>
256OD_FORCEINLINE Type &OdTrVisClamp(Type &val, Type valMin, Type valMax)
257{ if (val < valMin) val = valMin; else if (val > valMax) val = valMax;
258 return val; }
259template <typename Type>
260OD_FORCEINLINE Type OdTrVisClamp(const Type &val, Type valMin, Type valMax)
261{ if (val < valMin) return valMin; else if (val > valMax) return valMax;
262 return val; }
263
264// Helper temporary increment/decrement operators
265template <typename Type>
267{ Type &m_val; OdTrVisTemporalIncreasor(Type &val) : m_val(val) { ++val; }
269template <typename Type>
271{ Type &m_val; OdTrVisTemporalDescreasor(Type &val) : m_val(val) { --val; }
273
274// OdSaveState for multiple elements
275template <typename DataType, long numEntries>
277{
278 protected:
279 DataType *m_pValue;
280 const size_t m_stride;
281 DataType m_oldValues[numEntries];
282 protected:
283 inline DataType *flip(DataType *pValue, long n, size_t stride) const
284 { return (DataType*)(((OdUInt8*)pValue) + stride * n); }
285 inline DataType *flip(DataType *pValue, long n) const
286 { return flip(pValue, n, m_stride); }
287 public:
288 OdTrVisMultiStateSaver(DataType *pValue, size_t stride = sizeof(DataType))
289 : m_pValue(pValue), m_stride(stride)
290 { for (long nEntry = 0; nEntry < numEntries; nEntry++)
291 m_oldValues[nEntry] = *flip(pValue, nEntry);
292 }
293 // Initialize all values by similar value
294 OdTrVisMultiStateSaver(DataType *pValue, const DataType &initValue, size_t stride = sizeof(DataType))
295 : m_pValue(pValue), m_stride(stride)
296 { for (long nEntry = 0; nEntry < numEntries; nEntry++)
297 { DataType &pLVal = *flip(pValue, nEntry);
298 m_oldValues[nEntry] = pLVal;
299 pLVal = initValue;
300 }
301 }
302 // Initialize all values by multiple values
303 OdTrVisMultiStateSaver(DataType *pValue, const DataType *pInitValue, size_t stride = sizeof(DataType), size_t stride2 = sizeof(DataType))
304 : m_pValue(pValue), m_stride(stride)
305 { for (long nEntry = 0; nEntry < numEntries; nEntry++)
306 { DataType &pLVal = *flip(pValue, nEntry);
307 m_oldValues[nEntry] = pLVal;
308 pLVal = *flip(const_cast<DataType*>(pInitValue), nEntry, stride2);
309 }
310 }
312 { for (long nEntry = 0; nEntry < numEntries; nEntry++)
313 *flip(m_pValue, nEntry) = m_oldValues[nEntry];
314 }
315};
316
322{
323 OdRxOverruleIterator* getOverrule(OverrulingType t) const { return 0; }
324 void setOverrule(OdRxOverruleIterator* pIt, OverrulingType t) {}
325};
326
327#include "TD_PackPop.h"
328
329#endif // ODTRVISDEVICEDEFINITIONS
tol
Definition: DimVarDefs.h:2287
const OdGsMarker kNullSubentIndex
Definition: Gs.h:1823
#define ODGETBLUE(rgb)
Definition: OdPlatform.h:939
#define ODCOLORREF
Definition: OdPlatform.h:933
#define ODGETGREEN(rgb)
Definition: OdPlatform.h:938
#define ODRGBA(r, g, b, a)
Definition: OdPlatform.h:935
#define ODGETALPHA(rgba)
Definition: OdPlatform.h:940
#define ODGETRED(rgb)
Definition: OdPlatform.h:937
unsigned int OdUInt32
unsigned char OdUInt8
#define SETBIT_0(flags, bit)
Definition: OdaDefs.h:519
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
#define SETBIT_1(flags, bit)
Definition: OdaDefs.h:520
OverrulingType
Definition: RxObject.h:814
const OdTrVisId kTrVisMainOverlayId
Definition: TrVisDefs.h:140
const OdTrVisId kTrVisNegativeId
Definition: TrVisDefs.h:128
const OdTrVisArrayId kTrVisNegativeArrayId
Definition: TrVisDefs.h:146
OdUInt64 OdTrVisGsMarker
Definition: TrVisDefs.h:84
bool isValidMarker(OdTrVisGsMarker marker)
Definition: TrVisDefs.h:87
const OdTrVisId kTrVisNullId
Definition: TrVisDefs.h:134
OdArray< OdTrVisSectionPlane, OdMemoryAllocator< OdTrVisSectionPlane > > OdTrVisSectionPlaneArray
Definition: TrVisDefs.h:233
OdTrVisId OdTrVisVisualStyleId
Definition: TrVisDefs.h:113
OdTrVisId OdTrVisGroupId
Definition: TrVisDefs.h:119
const void * OdTrVisStateBranchPtr
Definition: TrVisDefs.h:162
OD_FORCEINLINE bool OdTrVisFPZero(float a, float tol=1.e-8f)
Definition: TrVisDefs.h:246
OD_FORCEINLINE Type & OdTrVisClamp(Type &val, Type valMin, Type valMax)
Definition: TrVisDefs.h:256
OdTrVisId OdTrVisOverlayId
Definition: TrVisDefs.h:117
OdTrVisId OdTrVisViewportId
Definition: TrVisDefs.h:97
OD_FORCEINLINE bool OdTrVisFPEqual(float a, float b, float tol=1.e-8f)
Definition: TrVisDefs.h:241
OD_FORCEINLINE bool isNullTrVisId(OdTrVisId id)
Definition: TrVisDefs.h:135
OdTrVisId OdTrVisProgramId
Definition: TrVisDefs.h:105
OdTrVisId OdTrVisMaterialId
Definition: TrVisDefs.h:103
OdTrVisStateBranchType
Definition: TrVisDefs.h:155
@ kTrVisNumStateBranchTypes
Definition: TrVisDefs.h:159
@ kTrVisVisibilityBranch
Definition: TrVisDefs.h:157
@ kTrVisHighlightingBranch
Definition: TrVisDefs.h:156
OdTrVisId OdTrVisExtensionId
Definition: TrVisDefs.h:121
OdArray< OdTrVisGsMarker, OdMemoryAllocator< OdTrVisGsMarker > > OdTrVisGsMarkerArray
Definition: TrVisDefs.h:85
OdUInt32 OdTrVisArrayId
Definition: TrVisDefs.h:100
OdTrVisId OdTrVisLayerId
Definition: TrVisDefs.h:115
const OdTrVisGsMarker kTrVisNullGsMarker
Definition: TrVisDefs.h:86
OdTrVisId OdTrVisStateBranchId
Definition: TrVisDefs.h:111
OD_FORCEINLINE bool isMainTrVisOverlayId(OdTrVisId id)
Definition: TrVisDefs.h:141
OdTrVisId OdTrVisDisplayId
Definition: TrVisDefs.h:107
OdTrVisId OdTrVisTextureId
Definition: TrVisDefs.h:102
OdTrVisId OdTrVisBlockId
Definition: TrVisDefs.h:123
OD_FORCEINLINE bool isValidTrVisId(OdTrVisId id)
Definition: TrVisDefs.h:129
OdTrVisId OdTrVisLightId
Definition: TrVisDefs.h:109
#define OD_FORCEINLINE
Definition: TrVisDefs.h:41
OdTrVisId OdTrVisMetafileId
Definition: TrVisDefs.h:99
OD_FORCEINLINE bool isValidTrVisArrayId(OdTrVisArrayId id)
Definition: TrVisDefs.h:147
OdArray< float, OdMemoryAllocator< float > > OdFloatArray
Definition: TrVisDefs.h:251
OdUInt64 OdTrVisOwning
Definition: TrVisDefs.h:91
OdUInt64 OdTrVisId
Definition: TrVisDefs.h:95
double z
Definition: GePoint3d.h:497
double y
Definition: GePoint3d.h:496
double x
Definition: GePoint3d.h:495
const size_t m_stride
Definition: TrVisDefs.h:280
OdTrVisMultiStateSaver(DataType *pValue, const DataType &initValue, size_t stride=sizeof(DataType))
Definition: TrVisDefs.h:294
DataType * flip(DataType *pValue, long n, size_t stride) const
Definition: TrVisDefs.h:283
OdTrVisMultiStateSaver(DataType *pValue, const DataType *pInitValue, size_t stride=sizeof(DataType), size_t stride2=sizeof(DataType))
Definition: TrVisDefs.h:303
OdTrVisMultiStateSaver(DataType *pValue, size_t stride=sizeof(DataType))
Definition: TrVisDefs.h:288
DataType m_oldValues[numEntries]
Definition: TrVisDefs.h:281
DataType * flip(DataType *pValue, long n) const
Definition: TrVisDefs.h:285
GLfloat GLfloat GLfloat alpha
Definition: gles2_ext.h:147
GLint GLenum GLboolean GLsizei stride
Definition: gles2_ext.h:322
void getRep(OdTrVisColorRGBA &clr, ColorRep rep, OdUInt8 alpha=255) const
Definition: TrVisDefs.h:197
bool operator!=(const OdTrVisColorRGBA &sec) const
Definition: TrVisDefs.h:173
OdTrVisColorRGBA & set(OdUInt8 _r, OdUInt8 _g, OdUInt8 _b, OdUInt8 _a)
Definition: TrVisDefs.h:175
const OdUInt8 * asArray() const
Definition: TrVisDefs.h:187
void setFlt(float _r, float _g, float _b, float _a)
Definition: TrVisDefs.h:183
ODCOLORREF asCRef() const
Definition: TrVisDefs.h:186
OdTrVisColorRGBA & set_r(OdUInt8 _r)
Definition: TrVisDefs.h:177
OdTrVisColorRGBA & set_a(OdUInt8 _a)
Definition: TrVisDefs.h:180
OdTrVisColorRGBA & setCRef(ODCOLORREF color)
Definition: TrVisDefs.h:181
OdTrVisColorRGBA & set_b(OdUInt8 _b)
Definition: TrVisDefs.h:179
bool operator==(const OdTrVisColorRGBA &sec) const
Definition: TrVisDefs.h:171
OdTrVisColorRGBA getRep(ColorRep rep, OdUInt8 alpha=255) const
Definition: TrVisDefs.h:204
OdTrVisColorRGBA & set_g(OdUInt8 _g)
Definition: TrVisDefs.h:178
void setRep(const OdTrVisColorRGBA &clr, ColorRep rep, OdUInt8 alpha=255)
Definition: TrVisDefs.h:190
void asFlt(float &_r, float &_g, float &_b, float &_a) const
Definition: TrVisDefs.h:185
DataType entry[3][3]
Definition: TrVisMatrix.h:55
OdGeVector3d normal() const
Definition: TrVisDefs.h:229
OdGePoint3d position() const
Definition: TrVisDefs.h:228
OdTrVisSectionPlane(OdGePoint3d position, OdGeVector3d normal)
Definition: TrVisDefs.h:219
void set(OdGePoint3d position, OdGeVector3d normal)
Definition: TrVisDefs.h:223
void transformBy(const OdGeMatrix3d &xfm)
Definition: TrVisDefs.h:230
void resetSyncFlags()
Definition: TrVisDefs.h:77
OdUInt32 m_syncFlags
Definition: TrVisDefs.h:72
bool isSynchronized() const
Definition: TrVisDefs.h:79
void setSyncAll()
Definition: TrVisDefs.h:78
void resetSyncFlag(OdUInt32 flag)
Definition: TrVisDefs.h:76
void setSyncFlag(OdUInt32 flag)
Definition: TrVisDefs.h:74
bool isSyncFlagSet(OdUInt32 flag) const
Definition: TrVisDefs.h:75