CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TrVisMfStreamStats.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// Metafile stream statistics calculation
24
25#ifndef _EXTRVISMFSTREAMSTATS_INCLUDED_
26#define _EXTRVISMFSTREAMSTATS_INCLUDED_
27
28#include "TD_PackPush.h"
29
30#include "TrVisMetafileStream.h"
31
40{
41 protected:
42 typedef std::pair<OdUInt32, OdUInt64> DataAsB;
47 protected:
48 public:
50
52 {
53 ::memset(m_chunkStats, 0, sizeof(m_chunkStats));
54 ::memset(m_arrayStats, 0, sizeof(m_arrayStats));
56 }
57
59 {
60 for (OdUInt32 nArray = 0; nArray < pMf->arrayElementsSize(); nArray++)
61 { const OdTrVisArrayWrapper &arry = pMf->arrayElement((OdTrVisArrayId)nArray);
62 m_arrayStats[arry.m_type].first++; m_arrayStats[arry.m_type].second += arry.m_uSize;
63 }
65 }
66
67 void endMetafileAnalyse(const OdUInt8 *pEofStreamPos)
68 {
70 m_chunkStats[m_lastChunk].second += (pEofStreamPos - m_pPrevStreamPos) - 1;
71 }
72
73 void addChunk(const OdUInt8 *pCurStreamPos)
74 { const OdTrVisMetaRecType curChunk = (OdTrVisMetaRecType)*pCurStreamPos;
75 endMetafileAnalyse(pCurStreamPos);
76 m_chunkStats[m_lastChunk = curChunk].first++; m_pPrevStreamPos = pCurStreamPos;
77 }
78
80 { OdString resStr; DataAsB arrSumm = DataAsB(0, 0), chunkSumm = DataAsB(0, 0);
81 resStr += OdString().format(OD_T("Statistics for %u metafile streams:\n"), m_nMetafiles);
82 for (OdUInt32 nArray = 0; nArray < OdTrVisArrayWrapper::Type_Invalid; nArray++)
83 {
84 if (m_arrayStats[nArray].first)
85 {
86 resStr += OdString().format(OD_T("%u arrays of type %u: %llu bytes\n"), m_arrayStats[nArray].first, nArray, m_arrayStats[nArray].second);
87 arrSumm.first += m_arrayStats[nArray].first; arrSumm.second += m_arrayStats[nArray].second;
88 }
89 }
90 resStr += OdString().format(OD_T("Summary for %u arrays: %llu bytes\n"), arrSumm.first, arrSumm.second);
91 for (OdUInt32 nChunk = 0; nChunk < OdTrVisMetaRecType_NTypes; nChunk++)
92 {
93 if (m_chunkStats[nChunk].first)
94 {
95 resStr += OdString().format(OD_T("%u %ls chunks: %llu bytes\n"), m_chunkStats[nChunk].first, ::chunkDecode((OdTrVisMetaRecType)nChunk), m_chunkStats[nChunk].second);
96 chunkSumm.first += m_chunkStats[nChunk].first; chunkSumm.second += m_chunkStats[nChunk].second;
97 }
98 }
99 resStr += OdString().format(OD_T("Summary for %u chunks: %llu bytes\n"), chunkSumm.first, chunkSumm.second);
100 resStr += OdString().format(OD_T("Total memory analysed: %llu bytes\n"), arrSumm.second + chunkSumm.second + chunkSumm.first);
101 return resStr;
102 }
103};
104
105#include "TD_PackPop.h"
106
107#endif // _EXTRVISMFSTREAMSTATS_INCLUDED_
#define OD_T(x)
unsigned int OdUInt32
unsigned char OdUInt8
OdUInt32 OdTrVisArrayId
Definition: TrVisDefs.h:100
OdTrVisMetaRecType
@ OdTrVisMetaRecType_NTypes
const OdChar * chunkDecode(OdTrVisMetaRecType rt)
OdString & format(const OdChar *formatString,...)
const OdUInt8 * memoryPtr() const
OdTrVisArrayWrapper & arrayElement(OdTrVisArrayId nElem)
OdTrVisMetaRecType m_lastChunk
DataAsB m_arrayStats[OdTrVisArrayWrapper::Type_Invalid]
void endMetafileAnalyse(const OdUInt8 *pEofStreamPos)
void addChunk(const OdUInt8 *pCurStreamPos)
void startMetafileAnalyse(const OdTrVisFlatMetafileContainer *pMf)
DataAsB m_chunkStats[OdTrVisMetaRecType_NTypes]
std::pair< OdUInt32, OdUInt64 > DataAsB