CFx SDK Documentation  2020SP3
GsBaseMaterialView.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 
24 #ifndef __OD_GS_BASE_MATERIAL_VIEW__
25 #define __OD_GS_BASE_MATERIAL_VIEW__
26 
27 #include "Gs/GsBaseInclude.h"
28 #include "Gs/GsExtAccum.h"
29 #include "Gi/GiMapperItem.h"
30 #include "Gi/GiMaterialItem.h"
31 
32 #include "TD_PackPush.h"
33 
34 class OdGsMaterialNode;
38 {
39  virtual bool saveClientMaterialTextureData(const OdGiMaterialTextureData * /*pTextureData*/, OdGsFiler * /*pFiler*/)
40  {
41  return false;
42  }
44  {
46  }
47 };
48 
61 {
62  public:
64  {
65  kProcessMappers = 1, // Process material mappers
66  kProcessMaterials = (1 << 1), // Process materials
67 
68  kProcessMappersAndMaterials = 3, // Process both material mappers and materials
69 
70  kMappersForRender = (1 << 2), // OdGiMapperRenderItem instead of OdGiMapperItem
71  kMaterialsForRender = (1 << 3), // OdGiMaterialRenderItem instead of OdGiMaterialItem
72 
73  kMappersAndMaterialsForRender = 12, // kMappersForRender | kMaterialsForRender
74 
75  kProcessForRender = 15, // kProcessMappersAndMaterials | kMappersAndMaterialsForRender
76 
77  // #5127 fix. Delay cache implementation.
78  kEnableDelayCache = (1 << 4) // Enable cache, which drop extents data after drawable extents computation
79  };
80 
81  // Cache structures
83  {
84  kInternal = 0,
85  kUser
86  };
88  {
89  DelayCacheEntry() : m_pNext(NULL) { }
90  virtual ~DelayCacheEntry() { }
91 
93 
94  // Don't return kInternal here if you want get callback
95  virtual DelayCacheEntryType internalType() const { return kUser; }
96 
97  DelayCacheEntry *nextEntry() { return m_pNext; }
98  void setNextEntry(DelayCacheEntry *pNext) { m_pNext = pNext; }
99 
100  virtual void play(OdGsBaseMaterialVectorizer &mView) const
101  {
102  mView.playDelayCacheEntry(this);
103  }
104  };
105  friend class OdDefDelayCacheEntryMap;
106  friend class OdManageMViewPerDrawableData;
107  private:
108  bool m_bMaterialCommited; // Material already emitted by GsModel
109  struct ExtentsContainer
110  {
111  const OdGiDrawable *m_pCurrentDrawable;
112  OdGeExtents3d m_Extents;
113  bool m_bExtentsValid;
114  bool m_bAwaiting;
115  };
116  struct DelayCache
117  {
118  const OdGiMapper *m_pCurMapper, *m_pCopyMapper;
119  const OdDbStub *m_pCurMaterial, *m_pCopyMaterial;
120  DelayCacheEntry m_Cache;
121  DelayCacheEntry *m_pTail;
122 
123  DelayCache() : m_pCurMapper(NULL), m_pCopyMapper(NULL)
124  , m_pCurMaterial(NULL), m_pCopyMaterial(NULL)
125  , m_pTail(&m_Cache)
126  {
127  }
128 
129  void clear();
130  };
131  struct MViewPerDrawableData
132  {
133  bool m_bMapperNeedExtents; // Mapper awaiting current drawable extents
134  bool m_bBaseLevel;
135  ExtentsContainer m_CurrentDrawableExtents;
136  DelayCache m_DelayCache;
137  MViewPerDrawableData()
138  : m_bMapperNeedExtents(false)
139  , m_bBaseLevel(false)
140  {
141  m_CurrentDrawableExtents.m_bExtentsValid = m_CurrentDrawableExtents.m_bAwaiting = false;
142  m_CurrentDrawableExtents.m_pCurrentDrawable = NULL;
143  }
144  ~MViewPerDrawableData()
145  {
146  }
147  void clear()
148  {
149  m_CurrentDrawableExtents.m_bExtentsValid = m_CurrentDrawableExtents.m_bAwaiting = false;
150  m_bMapperNeedExtents = false;
151  m_CurrentDrawableExtents.m_pCurrentDrawable = NULL;
152  }
153  } *m_pCurMvDrawableData, m_mvBaseDrawableData, m_mvGlobalDrawableDataInitializer;
154  protected:
155  OdUInt32 m_uMaterialViewFlags; // Set of material view flags
160  public:
161  explicit OdGsBaseMaterialVectorizer(OdUInt32 uMaterialViewFlags = kProcessMappersAndMaterials);
163 
164  // OdGsBaseVectorizerView overrides
165 
166  virtual void onTraitsModified();
167 
168  virtual void beginMetafile(OdRxObject* pMetafile);
169  virtual void endMetafile(OdRxObject* pMetafile);
170  virtual void beginViewVectorization();
171  virtual void endViewVectorization();
172 
173  virtual void processMaterialNode(OdDbStub *materialId, OdGsMaterialNode *node);
174  virtual bool saveMaterialCache(const OdGsMaterialNode *pNode, OdGsFiler *pFiler);
175  virtual bool loadMaterialCache(OdGsMaterialNode *pNode, OdGsFiler *pFiler);
176 
177  virtual bool doDraw(OdUInt32 drawableFlags, const OdGiDrawable *pDrawable);
178 
179  // OdGsBaseMaterialView methods
180 
193  bool isMaterialEnabled() const;
197  bool isMaterialAvailable() const;
206  OdGiMapperItemPtr currentMapper(bool bForCoords = true) const;
215  bool isMapperEnabled() const;
219  bool isMapperAvailable() const;
220 
224  bool isMappingDelayed() const;
225 
226  // Output callbacks
227 
234  virtual bool getDeviceMapperMatrix(OdGeMatrix3d &dm) const;
242  virtual bool skipMaterialProcess(OdDbStub *materialId) const;
246  virtual void nullMaterialStub();
255  virtual OdGiMaterialItemPtr fillMaterialCache(OdGiMaterialItemPtr prevCache, OdDbStub *materialId, const OdGiMaterialTraitsData &materialData);
263  virtual void renderMaterialCache(OdGiMaterialItemPtr pCache, OdDbStub *materialId);
264 
269  virtual void playDelayCacheEntry(const DelayCacheEntry *pEntry);
288  virtual void delayCacheProcessed(const OdGiDrawable *pDrawable);
289 
290  bool saveMaterialItem(const OdGiMaterialItem *pMatItem, OdGsFiler *pFiler);
292  static bool saveMaterialTexture(const OdGiMaterialTexture *pTexture, OdGsFiler *pFiler);
296  virtual bool saveClientMaterialCache(const OdRxObject* pMtl, OdGsFiler *pFiler);
298  protected:
307  virtual bool computeDrawableExtents(const OdGiDrawable *pDrawable, OdGeExtents3d &extents);
316  virtual bool computeDelayedExtents(const OdGiDrawable *pDrawable, OdGeExtents3d &extents);
317  private:
318  void computeDrawableExtents();
319  bool tryGsModelExtents(OdGeExtents3d &extents) const;
320  protected:
323 };
324 
333 {
334  protected:
335  void resetConstructorFlags(OdUInt32 uMaterialViewFlags);
336  public:
338 };
339 
348 {
349  public:
350  explicit OdGsBaseMaterialView(OdUInt32 uMaterialViewFlags = kProcessMappersAndMaterials)
351  {
352  resetConstructorFlags(uMaterialViewFlags);
353  }
354 };
355 
364 {
365  public:
366  explicit OdGsBaseMaterialViewMT(OdUInt32 uMaterialViewFlags = kProcessMappersAndMaterials)
367  {
368  resetConstructorFlags(uMaterialViewFlags);
369  }
370 
371  bool isMTView() const
372  {
373  return (&view() != this);
374  }
375 };
376 
377 #include "TD_PackPop.h"
378 
379 #endif // __OD_GS_BASE_MATERIAL_VIEW__
OdGsBaseMaterialVectorizer::loadMaterialItem
OdGiMaterialItemPtr loadMaterialItem(OdGsFiler *pFiler)
OdGsBaseMaterialVectorizer::isMappingDelayed
bool isMappingDelayed() const
NULL
#define NULL
Definition: GsProperties.h:177
OdRxObjectPtr
Definition: RxObject.h:345
OdGsBaseMaterialVectorizer::loadMaterialCache
virtual bool loadMaterialCache(OdGsMaterialNode *pNode, OdGsFiler *pFiler)
OdGsBaseMaterialVectorizer::DelayCacheEntry
Definition: GsBaseMaterialView.h:88
OdGsBaseMaterialVectorizer::saveMaterialTextureManager
static bool saveMaterialTextureManager(const OdGiMaterialTextureManager *pManager, OdGsFiler *pFiler, OdGsMaterialTextureDataFiler *pSaver)
OdGsBaseVectorizeViewJoinMT
Definition: GsBaseInclude.h:126
OdGsBaseMaterialVectorizer::doDraw
virtual bool doDraw(OdUInt32 drawableFlags, const OdGiDrawable *pDrawable)
OdGsBaseMaterialVectorizer::isMapperEnabled
bool isMapperEnabled() const
OdGsBaseMaterialViewPC::OdGsBaseMaterialViewPC
OdGsBaseMaterialViewPC()
Definition: GsBaseMaterialView.h:337
OdGsBaseMaterialVectorizer::saveClientMaterialCache
virtual bool saveClientMaterialCache(const OdRxObject *pMtl, OdGsFiler *pFiler)
OdGsBaseVectorizer
Definition: GsBaseVectorizer.h:112
OdGsBaseMaterialVectorizer::fillMaterialCache
virtual OdGiMaterialItemPtr fillMaterialCache(OdGiMaterialItemPtr prevCache, OdDbStub *materialId, const OdGiMaterialTraitsData &materialData)
OdGsBaseMaterialVectorizer::resetCurrentMapper
void resetCurrentMapper(OdGiMapperItemPtr pMapper)
OdGsBaseMaterialVectorizer::DelayCacheEntry::play
virtual void play(OdGsBaseMaterialVectorizer &mView) const
Definition: GsBaseMaterialView.h:100
OdGsBaseMaterialVectorizer::isMapperAvailable
bool isMapperAvailable() const
OdGsBaseMaterialVectorizer::DelayCacheEntry::m_pNext
DelayCacheEntry * m_pNext
Definition: GsBaseMaterialView.h:92
false
false
Definition: DimVarDefs.h:165
OdRxObject
Definition: RxObject.h:564
OdGsBaseMaterialVectorizer::computeDrawableExtents
virtual bool computeDrawableExtents(const OdGiDrawable *pDrawable, OdGeExtents3d &extents)
OdGsBaseMaterialVectorizer::m_nullMaterialTraitsData
OdGiMaterialTraitsData m_nullMaterialTraitsData
Definition: GsBaseMaterialView.h:158
OdGsBaseMaterialVectorizer::~OdGsBaseMaterialVectorizer
~OdGsBaseMaterialVectorizer()
OdGsBaseMaterialVectorizer::isMaterialEnabled
bool isMaterialEnabled() const
OdGsBaseMaterialVectorizer::resetCurrentMaterial
void resetCurrentMaterial(OdGiMaterialItemPtr pMaterial)
OdGsBaseMaterialVectorizer::isMaterialAvailable
bool isMaterialAvailable() const
GsBaseInclude.h
TD_PackPop.h
OdGiMaterialTextureManager
Definition: GiMaterialItem.h:263
OdGsBaseMaterialVectorizer::skipMaterialProcess
virtual bool skipMaterialProcess(OdDbStub *materialId) const
OdGsBaseVectorizeViewJoin
Definition: GsBaseInclude.h:52
OdGsBaseMaterialVectorizer::DelayCacheEntry::~DelayCacheEntry
virtual ~DelayCacheEntry()
Definition: GsBaseMaterialView.h:90
OdGsBaseMaterialVectorizer::resetCurrentMaterial
void resetCurrentMaterial()
OdGiMaterialTextureDataPtr
OdSmartPtr< OdGiMaterialTextureData > OdGiMaterialTextureDataPtr
Definition: GiMaterialItem.h:176
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdGeMatrix3d
Definition: GeMatrix3d.h:73
OdGsBaseMaterialVectorizer::computeDelayedExtents
virtual bool computeDelayedExtents(const OdGiDrawable *pDrawable, OdGeExtents3d &extents)
OdGsMaterialTextureDataFiler::loadClientMaterialTextureData
virtual OdGiMaterialTextureDataPtr loadClientMaterialTextureData(OdGsFiler *)
Definition: GsBaseMaterialView.h:43
OdGsBaseMaterialViewMT::isMTView
bool isMTView() const
Definition: GsBaseMaterialView.h:371
OdGsMaterialNode
Definition: GsMaterialNode.h:50
OdGsBaseMaterialViewPC::resetConstructorFlags
void resetConstructorFlags(OdUInt32 uMaterialViewFlags)
OdGsBaseMaterialVectorizer::mapperChangedForDelayCache
virtual void mapperChangedForDelayCache()
OdGsBaseMaterialVectorizer::DelayCacheEntry::nextEntry
DelayCacheEntry * nextEntry()
Definition: GsBaseMaterialView.h:97
OdGsBaseMaterialView
Definition: GsBaseMaterialView.h:348
OdGsBaseMaterialVectorizer::processMaterialNode
virtual void processMaterialNode(OdDbStub *materialId, OdGsMaterialNode *node)
OdSmartPtr
Definition: SmartPtr.h:58
OdGsBaseMaterialVectorizer::endViewVectorization
virtual void endViewVectorization()
OdGiMaterialTraitsData
Definition: GiMaterialTraitsData.h:38
OdGsBaseMaterialVectorizer::m_uMaterialViewFlags
OdUInt32 m_uMaterialViewFlags
Definition: GsBaseMaterialView.h:155
GiMaterialItem.h
OdGsBaseMaterialVectorizer::appendDelayCacheEntry
void appendDelayCacheEntry(DelayCacheEntry *pEntry)
OdGsBaseMaterialVectorizer::saveMaterialCache
virtual bool saveMaterialCache(const OdGsMaterialNode *pNode, OdGsFiler *pFiler)
OdGiDrawable
Definition: GiDrawable.h:49
OdIfc::kUser
@ kUser
Definition: IfcAttributesEnum.h:1275
OdGsBaseMaterialVectorizer::beginViewVectorization
virtual void beginViewVectorization()
OdGsBaseMaterialVectorizer::saveMaterialTexture
static bool saveMaterialTexture(const OdGiMaterialTexture *pTexture, OdGsFiler *pFiler)
OdGsBaseMaterialVectorizer::_itlCreateMapperItem
OdGiMapperItemPtr _itlCreateMapperItem() const
OdGsBaseMaterialVectorizer::loadMaterialTextureManager
static bool loadMaterialTextureManager(OdGiMaterialTextureManager *pManager, OdGsFiler *pFiler, OdGsMaterialTextureDataFiler *pSaver)
OdGsBaseMaterialVectorizer::MaterialViewFlags
MaterialViewFlags
Definition: GsBaseMaterialView.h:64
OdGsBaseMaterialVectorizer::DelayCacheEntryType
DelayCacheEntryType
Definition: GsBaseMaterialView.h:83
OdGsBaseMaterialVectorizer::currentMapper
OdGiMapperItemPtr currentMapper(bool bForCoords=true) const
OdGsBaseMaterialVectorizer
Definition: GsBaseMaterialView.h:61
OdGiMaterialItem
Definition: GiMaterialItem.h:517
TD_PackPush.h
OdGsBaseMaterialVectorizer::playDelayCacheEntry
virtual void playDelayCacheEntry(const DelayCacheEntry *pEntry)
OdGiMaterialTextureData
Definition: GiMaterialItem.h:49
OdGsBaseMaterialVectorizer::m_pCurrentMapperItem
OdGiMapperItemPtr m_pCurrentMapperItem
Definition: GsBaseMaterialView.h:157
OdGsBaseMaterialViewPC
Definition: GsBaseMaterialView.h:333
OdGsMaterialTextureDataFiler
Definition: GsBaseMaterialView.h:38
OdGiMaterialTexture
Definition: GiMaterial.h:713
OdGsMaterialTextureDataFiler::saveClientMaterialTextureData
virtual bool saveClientMaterialTextureData(const OdGiMaterialTextureData *, OdGsFiler *)
Definition: GsBaseMaterialView.h:39
GiMapperItem.h
OdGsBaseMaterialVectorizer::renderMaterialCache
virtual void renderMaterialCache(OdGiMaterialItemPtr pCache, OdDbStub *materialId)
OdGsBaseMaterialVectorizer::beginMetafile
virtual void beginMetafile(OdRxObject *pMetafile)
GsExtAccum.h
OdGsBaseMaterialVectorizer::_itlCreateMaterialItem
OdGiMaterialItemPtr _itlCreateMaterialItem() const
OdGsBaseMaterialVectorizer::OdGsBaseMaterialVectorizer
OdGsBaseMaterialVectorizer(OdUInt32 uMaterialViewFlags=kProcessMappersAndMaterials)
OdGsBaseMaterialView::OdGsBaseMaterialView
OdGsBaseMaterialView(OdUInt32 uMaterialViewFlags=kProcessMappersAndMaterials)
Definition: GsBaseMaterialView.h:350
OdGsBaseMaterialVectorizer::getDeviceMapperMatrix
virtual bool getDeviceMapperMatrix(OdGeMatrix3d &dm) const
OdGsBaseMaterialVectorizer::m_pNullMaterialItem
OdGiMaterialItemPtr m_pNullMaterialItem
Definition: GsBaseMaterialView.h:159
OdGsBaseMaterialVectorizer::delayCacheProcessed
virtual void delayCacheProcessed(const OdGiDrawable *pDrawable)
OdGeExtents3d
Definition: GeExtents3d.h:45
GS_TOOLKIT_EXPORT
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
OdGsBaseMaterialVectorizer::DelayCacheEntry::setNextEntry
void setNextEntry(DelayCacheEntry *pNext)
Definition: GsBaseMaterialView.h:98
OdGsBaseMaterialVectorizer::nullMaterialStub
virtual void nullMaterialStub()
OdGsBaseMaterialVectorizer::m_pCurrentMaterialItem
OdGiMaterialItemPtr m_pCurrentMaterialItem
Definition: GsBaseMaterialView.h:156
OdGsFiler
Definition: GsFiler.h:63
OdGsBaseMaterialViewMT
Definition: GsBaseMaterialView.h:364
OdGsBaseMaterialVectorizer::DelayCacheEntry::internalType
virtual DelayCacheEntryType internalType() const
Definition: GsBaseMaterialView.h:95
OdGsBaseMaterialVectorizer::endMetafile
virtual void endMetafile(OdRxObject *pMetafile)
OdGiMapper
Definition: GiMaterial.h:1123
OdGsBaseMaterialVectorizer::loadClientMaterialCache
virtual OdRxObjectPtr loadClientMaterialCache(OdGsFiler *pFiler, OdGiMaterialItem *pMatItem)
OdGsBaseMaterialVectorizer::saveMaterialItem
bool saveMaterialItem(const OdGiMaterialItem *pMatItem, OdGsFiler *pFiler)
OdGsBaseMaterialVectorizer::loadMaterialTexture
static OdGiMaterialTexturePtr loadMaterialTexture(OdGsFiler *pFiler)
OdGsBaseMaterialVectorizer::currentMaterial
OdGiMaterialItemPtr currentMaterial() const
OdGsBaseMaterialVectorizer::onTraitsModified
virtual void onTraitsModified()
OdGsBaseMaterialVectorizer::DelayCacheEntry::DelayCacheEntry
DelayCacheEntry()
Definition: GsBaseMaterialView.h:89
OdGsBaseMaterialViewMT::OdGsBaseMaterialViewMT
OdGsBaseMaterialViewMT(OdUInt32 uMaterialViewFlags=kProcessMappersAndMaterials)
Definition: GsBaseMaterialView.h:366