CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TrVisMetafileAnalyzer.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 metafile parser and comparator
24
25#ifndef ODTRVISMETAFILEANALYZER
26#define ODTRVISMETAFILEANALYZER
27
28#include "TD_PackPush.h"
29
30#include "TrVisDefs.h"
31#include "TrVisMetafileStream.h"
32
41{
42 public:
44 {
67
69 };
71 {
78
80 };
81 struct VarState
82 {
84 VarType m_varType; // Type of current variable
85 OdUInt32 m_nVar; // Number of variable under chunk
86 const void * m_pVar; // Pointer onto variable
87
91 , m_nVar(0)
92 , m_pVar(NULL)
93 { }
94
96 bool isEOF() const { return m_chunk == OdTrVisMetaRecType_NTypes; }
97
98 OdUInt8 asUInt8() const ;
99 OdInt8 asInt8() const ;
100 OdUInt16 asUInt16() const ;
101 OdInt16 asInt16() const ;
102 OdUInt32 asUInt32() const ;
103 OdInt32 asInt32() const ;
104 OdUInt64 asUInt64() const ;
105 OdInt64 asInt64() const ;
106 float asFloat() const ;
107 double asDouble() const ;
108 const float *asFVec() const ;
109 const double *asDVec() const ;
110 const OdGeVector2d &asDVec2() const ;
111 const OdGePoint2d &asDPoint2() const ;
112 const OdGeVector3d &asDVec3() const ;
113 const OdGePoint3d &asDPoint3() const ;
114 const OdGeMatrix3d &asDMatrix3d() const;
115 const float *asFVec(float *out, OdUInt32 count = 1) const;
116 const double *asDVec(double *out, OdUInt32 count = 1) const;
117 };
118 static struct TypeSpec
119 {
120 OdUInt32 m_typeSize;
121 OdUInt32 m_typeNumber;
122 OdUInt32 m_basisType;
124 static struct BasisFuncs
125 {
126 void (*m_pLRegFunc)(OdUInt32 &lReg, const VarState &varState);
127 bool (*m_pCompFunc)(const void *pStream1, const void *pStream2, OdUInt32 nVars);
130 {
131 kOpSkip = 0, // Skip until next chunk
132 kOpProcess = 1 // Process normally
133 };
135 {
136 kSmBasic = 0, // Basic stream scheme
137 kSmStandalone, // Standalone stream scheme
138 kNumSchemes // Number of stream schemes
139 };
140 protected:
141 static struct RecScheme
142 {
143 const char *m_pSpec[kNumSchemes];
146 {
152
154 : m_pDataCont(NULL)
156 , m_nStreamSize(0)
157 , m_pStreamStart(NULL)
158 , m_pStreamEnd(NULL)
159 { }
162 {
164 const char *m_pLogicalCur;
165
167 : m_pStreamCur(NULL)
168 , m_pLogicalCur(NULL)
169 { }
172 };
174 {
175 kLogicInit = (1 << 0),
176 kLogicExclusive = (1 << 1),
177 kLogicLoopSkip = (1 << 2),
178 kLogicSkip = (1 << 3),
179 kLogicSkipByMask = (1 << 4)
180 };
182 {
188
190 : m_logicalReg(0)
191 , m_logicalFlags(0)
192 { }
196 public:
197 OdTrVisMetafileParser(const OdBaseMetafileContainer *pContainer = NULL, Scheme streamScheme = kSmBasic)
198 : m_skipMask(0)
199 {
200 initialize(pContainer, streamScheme);
201 }
202
206
209
210 void initialize(const OdBaseMetafileContainer *pContainer, Scheme streamScheme = kSmBasic);
211 void reset();
212
213 void rewind(OdUInt32 nStreamPos = 0);
214
216 protected:
217 static void lRegFuncUInt8(OdUInt32 &lReg, const VarState &varState);
218 static void lRegFuncUInt16(OdUInt32 &lReg, const VarState &varState);
219 static void lRegFuncUInt32(OdUInt32 &lReg, const VarState &varState);
220 static void lRegFuncStub(OdUInt32 &lReg, const VarState &varState);
221};
222
231{
232 protected:
234 static bool (*s_pCompArrayFunc[OdTrVisArrayWrapper::Type_Marker + 1])(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType);
235 public:
236 OdTrVisMetafileComparator(const OdBaseMetafileContainer *pContainer1 = NULL, const OdBaseMetafileContainer *pContainer2 = NULL, OdTrVisMetafileParser::Scheme streamScheme = OdTrVisMetafileParser::kSmBasic)
237 : m_par1(pContainer1, streamScheme)
238 , m_par2(pContainer2, streamScheme)
239 {
240 }
241
242 bool compare();
243 bool compare(const OdBaseMetafileContainer *pContainer1, const OdBaseMetafileContainer *pContainer2, OdTrVisMetafileParser::Scheme streamScheme = OdTrVisMetafileParser::kSmBasic);
244 protected:
246 static bool compFuncUInt8(const void *pStream1, const void *pStream2, OdUInt32 nVars);
247 static bool compFuncUInt16(const void *pStream1, const void *pStream2, OdUInt32 nVars);
248 static bool compFuncUInt32(const void *pStream1, const void *pStream2, OdUInt32 nVars);
249 static bool compFuncUInt64(const void *pStream1, const void *pStream2, OdUInt32 nVars);
250 static bool compFuncHalfFloat(const void *pStream1, const void *pStream2, OdUInt32 nVars);
251 static bool compFuncFloat(const void *pStream1, const void *pStream2, OdUInt32 nVars);
252 static bool compFuncDouble(const void *pStream1, const void *pStream2, OdUInt32 nVars);
253
254 static bool defAttribsArrayComparator(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType);
255
256 static bool compFuncArrayVertex(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType);
257 static bool compFuncArrayNormal(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType);
258 static bool compFuncArrayColor(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType);
259 static bool compFuncArrayTexCoord(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType);
260 static bool compFuncArrayDepth(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType);
261 static bool compFuncArrayIndex(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType);
262 static bool compFuncArrayMarker(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType);
263};
264
266inline OdInt8 OdTrVisMetafileParser::VarState::asInt8() const { return *(const OdInt8*) m_pVar; }
267
268#ifdef TD_STRICT_ALIGNMENT
269
270template <class T> T align(const void* ptr) { T res; memcpy(&res, ptr, sizeof(T)); return res; }
271
272inline OdUInt16 OdTrVisMetafileParser::VarState::asUInt16() const { return align<OdUInt16>(m_pVar); }
273inline OdInt16 OdTrVisMetafileParser::VarState::asInt16() const { return align<OdInt16 >(m_pVar); }
274inline OdUInt32 OdTrVisMetafileParser::VarState::asUInt32() const { return align<OdUInt32>(m_pVar); }
275inline OdInt32 OdTrVisMetafileParser::VarState::asInt32() const { return align<OdInt32 >(m_pVar); }
276inline OdUInt64 OdTrVisMetafileParser::VarState::asUInt64() const { return align<OdUInt64>(m_pVar); }
277inline OdInt64 OdTrVisMetafileParser::VarState::asInt64() const { return align<OdInt64 >(m_pVar); }
278inline float OdTrVisMetafileParser::VarState::asFloat() const { return align<float >(m_pVar); }
279inline double OdTrVisMetafileParser::VarState::asDouble() const { return align<double >(m_pVar); }
280inline const float* OdTrVisMetafileParser::VarState::asFVec() const { return align<const float*>(m_pVar); }
281inline const double* OdTrVisMetafileParser::VarState::asDVec() const { return align<const double*>(m_pVar); }
282inline const OdGeVector2d& OdTrVisMetafileParser::VarState::asDVec2() const { ODA_ASSERT(OdIntPtr(m_pVar)%8); return *(const OdGeVector2d*)m_pVar; }
283inline const OdGePoint2d& OdTrVisMetafileParser::VarState::asDPoint2() const { ODA_ASSERT(OdIntPtr(m_pVar)%8); return *(const OdGePoint2d*)m_pVar; }
284inline const OdGeVector3d& OdTrVisMetafileParser::VarState::asDVec3() const { ODA_ASSERT(OdIntPtr(m_pVar)%8); return *(const OdGeVector3d*)m_pVar; }
285inline const OdGePoint3d& OdTrVisMetafileParser::VarState::asDPoint3() const { ODA_ASSERT(OdIntPtr(m_pVar)%8); return *(const OdGePoint3d*)m_pVar; }
286inline const OdGeMatrix3d& OdTrVisMetafileParser::VarState::asDMatrix3d() const { ODA_ASSERT(OdIntPtr(m_pVar)%8); return *(const OdGeMatrix3d*)m_pVar; }
287
288#else
289
290inline OdUInt16 OdTrVisMetafileParser::VarState::asUInt16() const { return *(const OdUInt16*)m_pVar; }
291inline OdInt16 OdTrVisMetafileParser::VarState::asInt16() const { return *(const OdInt16*)m_pVar; }
292inline OdUInt32 OdTrVisMetafileParser::VarState::asUInt32() const { return *(const OdUInt32*)m_pVar; }
293inline OdInt32 OdTrVisMetafileParser::VarState::asInt32() const { return *(const OdInt32*)m_pVar; }
294inline OdUInt64 OdTrVisMetafileParser::VarState::asUInt64() const { return *(const OdUInt64*)m_pVar; }
295inline OdInt64 OdTrVisMetafileParser::VarState::asInt64() const { return *(const OdInt64*)m_pVar; }
296inline float OdTrVisMetafileParser::VarState::asFloat() const { return *(const float*)m_pVar; }
297inline double OdTrVisMetafileParser::VarState::asDouble() const { return *(const double*)m_pVar; }
298inline const float* OdTrVisMetafileParser::VarState::asFVec() const { return (const float*)m_pVar; }
299inline const double* OdTrVisMetafileParser::VarState::asDVec() const { return (const double*)m_pVar; }
300inline const OdGeVector2d& OdTrVisMetafileParser::VarState::asDVec2() const { return *(const OdGeVector2d*)m_pVar; }
301inline const OdGePoint2d& OdTrVisMetafileParser::VarState::asDPoint2() const { return *(const OdGePoint2d*)m_pVar; }
302inline const OdGeVector3d& OdTrVisMetafileParser::VarState::asDVec3() const { return *(const OdGeVector3d*)m_pVar; }
303inline const OdGePoint3d& OdTrVisMetafileParser::VarState::asDPoint3() const { return *(const OdGePoint3d*)m_pVar; }
304inline const OdGeMatrix3d& OdTrVisMetafileParser::VarState::asDMatrix3d() const { return *(const OdGeMatrix3d*)m_pVar; }
305
306#endif
307
308inline const float *OdTrVisMetafileParser::VarState::asFVec(float *out, OdUInt32 count) const
309{
310 memcpy(out, m_pVar, sizeof(float) * count);
311 return out;
312}
313inline const double *OdTrVisMetafileParser::VarState::asDVec(double *out, OdUInt32 count) const
314{
315 memcpy(out, m_pVar, sizeof(double) * count);
316 return out;
317}
318
319#include "TD_PackPop.h"
320
321#endif // ODTRVISMETAFILEANALYZER
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
unsigned int OdUInt32
short OdInt16
signed char OdInt8
unsigned short OdUInt16
int OdInt32
unsigned char OdUInt8
ptrdiff_t OdIntPtr
OdTrVisMetaRecType
@ OdTrVisMetaRecType_NTypes
Definition: Int64.h:43
static bool defAttribsArrayComparator(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType)
static bool compFuncUInt64(const void *pStream1, const void *pStream2, OdUInt32 nVars)
static bool compFuncArrayVertex(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType)
static bool compFuncArrayDepth(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType)
static bool compFuncFloat(const void *pStream1, const void *pStream2, OdUInt32 nVars)
static bool compFuncDouble(const void *pStream1, const void *pStream2, OdUInt32 nVars)
static bool compFuncArrayIndex(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType)
OdTrVisMetafileParser m_par1
static bool compFuncUInt32(const void *pStream1, const void *pStream2, OdUInt32 nVars)
static bool compFuncUInt16(const void *pStream1, const void *pStream2, OdUInt32 nVars)
static bool compFuncArrayMarker(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType)
static bool compFuncArrayTexCoord(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType)
OdTrVisMetafileComparator(const OdBaseMetafileContainer *pContainer1=NULL, const OdBaseMetafileContainer *pContainer2=NULL, OdTrVisMetafileParser::Scheme streamScheme=OdTrVisMetafileParser::kSmBasic)
OdTrVisMetafileParser m_par2
bool compare(const OdBaseMetafileContainer *pContainer1, const OdBaseMetafileContainer *pContainer2, OdTrVisMetafileParser::Scheme streamScheme=OdTrVisMetafileParser::kSmBasic)
static bool compFuncUInt8(const void *pStream1, const void *pStream2, OdUInt32 nVars)
static bool compFuncHalfFloat(const void *pStream1, const void *pStream2, OdUInt32 nVars)
static bool compFuncArrayColor(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType)
static bool compFuncArrayNormal(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType)
static bool(* s_pCompArrayFunc[OdTrVisArrayWrapper::Type_Marker+1])(const void *pArray1, const void *pArray2, OdUInt32 nSize, OdUInt32 nType)
static void lRegFuncUInt32(OdUInt32 &lReg, const VarState &varState)
OdTrVisMetafileParser(const OdBaseMetafileContainer *pContainer=NULL, Scheme streamScheme=kSmBasic)
struct OdTrVisMetafileParser::InitialState m_initState
static struct OdTrVisMetafileParser::TypeSpec s_typeSpec[kNTypes]
const OdTrVisFlatMetafileContainer * metafileContainer() const
static struct OdTrVisMetafileParser::RecScheme s_schemes[OdTrVisMetaRecType_NTypes]
static void lRegFuncUInt16(OdUInt32 &lReg, const VarState &varState)
void initialize(const OdBaseMetafileContainer *pContainer, Scheme streamScheme=kSmBasic)
static void lRegFuncUInt8(OdUInt32 &lReg, const VarState &varState)
struct OdTrVisMetafileParser::CurrentState m_curState
static struct OdTrVisMetafileParser::BasisFuncs s_basisFunc[kNBasisTypes]
const VarState & nextStep(NextStepOp op=kOpProcess)
void rewind(OdUInt32 nStreamPos=0)
const OdUInt8 *& userEntryCurProc()
static void lRegFuncStub(OdUInt32 &lReg, const VarState &varState)
typedef void(APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture)
GLsizei GLsizei * count
Definition: gles2_ext.h:276
void clearVars(VarType varType=kTypeInvalid)
const OdTrVisFlatMetafileContainer * m_pDataCont
void logicalCopyIn(const StreamMarker &sm2)
const OdGePoint3d & asDPoint3() const
const OdGePoint2d & asDPoint2() const
const OdGeVector2d & asDVec2() const
const OdGeMatrix3d & asDMatrix3d() const
const OdGeVector3d & asDVec3() const
OdTrVisMetaRecType asChunk() const