CFx SDK Documentation  2023 SP0
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__
false
Definition: DimVarDefs.h:165
OdSmartPtr< OdGiMaterialTextureData > OdGiMaterialTextureDataPtr
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
#define NULL
Definition: GsProperties.h:177
unsigned int OdUInt32
OdGsViewImpl & view() const
virtual void playDelayCacheEntry(const DelayCacheEntry *pEntry)
void resetCurrentMaterial(OdGiMaterialItemPtr pMaterial)
virtual void beginViewVectorization()
bool saveMaterialItem(const OdGiMaterialItem *pMatItem, OdGsFiler *pFiler)
virtual void onTraitsModified()
virtual bool getDeviceMapperMatrix(OdGeMatrix3d &dm) const
virtual void beginMetafile(OdRxObject *pMetafile)
virtual void delayCacheProcessed(const OdGiDrawable *pDrawable)
OdGiMaterialItemPtr m_pNullMaterialItem
OdGiMaterialTraitsData m_nullMaterialTraitsData
OdGsBaseMaterialVectorizer(OdUInt32 uMaterialViewFlags=kProcessMappersAndMaterials)
OdGiMaterialItemPtr currentMaterial() const
static OdGiMaterialTexturePtr loadMaterialTexture(OdGsFiler *pFiler)
virtual bool saveClientMaterialCache(const OdRxObject *pMtl, OdGsFiler *pFiler)
void appendDelayCacheEntry(DelayCacheEntry *pEntry)
virtual bool computeDelayedExtents(const OdGiDrawable *pDrawable, OdGeExtents3d &extents)
virtual void nullMaterialStub()
virtual bool loadMaterialCache(OdGsMaterialNode *pNode, OdGsFiler *pFiler)
virtual OdRxObjectPtr loadClientMaterialCache(OdGsFiler *pFiler, OdGiMaterialItem *pMatItem)
virtual void endViewVectorization()
virtual bool saveMaterialCache(const OdGsMaterialNode *pNode, OdGsFiler *pFiler)
static bool saveMaterialTexture(const OdGiMaterialTexture *pTexture, OdGsFiler *pFiler)
bool isMapperAvailable() const
bool isMaterialEnabled() const
virtual void mapperChangedForDelayCache()
OdGiMaterialItemPtr m_pCurrentMaterialItem
OdGiMaterialItemPtr loadMaterialItem(OdGsFiler *pFiler)
void resetCurrentMapper(OdGiMapperItemPtr pMapper)
bool isMaterialAvailable() const
virtual void renderMaterialCache(OdGiMaterialItemPtr pCache, OdDbStub *materialId)
static bool saveMaterialTextureManager(const OdGiMaterialTextureManager *pManager, OdGsFiler *pFiler, OdGsMaterialTextureDataFiler *pSaver)
virtual void processMaterialNode(OdDbStub *materialId, OdGsMaterialNode *node)
virtual OdGiMaterialItemPtr fillMaterialCache(OdGiMaterialItemPtr prevCache, OdDbStub *materialId, const OdGiMaterialTraitsData &materialData)
virtual bool computeDrawableExtents(const OdGiDrawable *pDrawable, OdGeExtents3d &extents)
virtual bool doDraw(OdUInt32 drawableFlags, const OdGiDrawable *pDrawable)
OdGiMapperItemPtr m_pCurrentMapperItem
OdGiMapperItemPtr _itlCreateMapperItem() const
virtual void endMetafile(OdRxObject *pMetafile)
static bool loadMaterialTextureManager(OdGiMaterialTextureManager *pManager, OdGsFiler *pFiler, OdGsMaterialTextureDataFiler *pSaver)
OdGiMapperItemPtr currentMapper(bool bForCoords=true) const
virtual bool skipMaterialProcess(OdDbStub *materialId) const
OdGiMaterialItemPtr _itlCreateMaterialItem() const
OdGsBaseMaterialView(OdUInt32 uMaterialViewFlags=kProcessMappersAndMaterials)
OdGsBaseMaterialViewMT(OdUInt32 uMaterialViewFlags=kProcessMappersAndMaterials)
void resetConstructorFlags(OdUInt32 uMaterialViewFlags)
DelayCacheEntry()
DelayCacheEntry * nextEntry()
virtual ~DelayCacheEntry()
virtual void play(OdGsBaseMaterialVectorizer &mView) const
virtual DelayCacheEntryType internalType() const
void setNextEntry(DelayCacheEntry *pNext)
DelayCacheEntry * m_pNext
virtual OdGiMaterialTextureDataPtr loadClientMaterialTextureData(OdGsFiler *)
virtual bool saveClientMaterialTextureData(const OdGiMaterialTextureData *, OdGsFiler *)