/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef __OD_EX_GI_DIRECT_X_GEOMETRY__ #define __OD_EX_GI_DIRECT_X_GEOMETRY__ #include "TD_PackPush.h" #if defined(__BORLANDC__) #include // CComPtr<> #include "D3DInclude.h" #else #include #include "D3DInclude.h" #endif #define STL_USING_MAP #define STL_USING_LIST #include "OdaSTL.h" #include "UInt16Array.h" #include "OdList.h" #include "Gi/GiGeometrySimplifier.h" #include "Ge/GeMatrix3d.h" #include "Ps/PlotStyles.h" #include "Gi/GiPlotStyleDefs.h" #include "Gi/GiMaterialItem.h" #include "Gi/GiMapperItem.h" #include "ChunkAllocator.h" #include "Gs/GsHighlightData.h" #include "Gs/GsBaseVectorizer.h" #include "D3DStateManager.h" #include "../TtfFontsCache.h" #include "../ExColorConverterCallback.h" #define SWAPBYTES(a) ODRGB(ODGETBLUE(a), ODGETGREEN(a), ODGETRED(a)) // Enables dynamic subentity highlighting mode (should be optimized #7706) //#define OD_D3D_DYNAMICSUBENTHLT // (moved to device properties #12382) // Maximum vertices for line cap #define OD_D3D_MAXLINECAPVERTS 15 // Keep temporary lwd buffer not larger this limit #define OD_D3D_LWDBUFKEEPLIMIT 256 class ExGiDirectXGeometry; class OdGiVisualStyle; struct OdGiMaterialTraitsData; class OdGsMaterialNode; class OdGsBaseDeviceMTHelpers; // A structure for our vertexes (vertex+color) /** \details This structure represents vertices with color for ExGiDirectXGeometry classes. */ struct OdD3DVertexCol { /** Transformed position of the vertex. */ FLOAT x, y, z; /** Color of the vertex. */ DWORD color; }; /** \details Represents an array of structures. */ typedef OdArray > OdD3DVertexColArray; /** \details This structure represents vertices with texture coordinates for ExGiDirectXGeometry classes. */ struct OdD3DVertexTexCol { /** Position of the vertex. */ D3DXVECTOR3 position; /** Color of the vertex. */ DWORD color; /** Texture coordinates. */ FLOAT s, t; }; /** \details Represents an array of structures. */ typedef OdArray > OdD3DVertexTexColArray; /** \details This structure represents vertices with normals for ExGiDirectXGeometry classes. */ struct OdD3DVertexNormalCol { /** Position of the vertex. */ D3DXVECTOR3 position; /** Surface normal at the vertex. */ D3DXVECTOR3 normal; /** Color of the vertex. */ DWORD color; }; /** \details Represents an array of structures. */ typedef OdArray > OdD3DVertexNormalColArray; /** \details This structure represents vertices with normals and texture coordinates for ExGiDirectXGeometry classes. */ struct OdD3DVertexNormalTexCol { /** Position of the vertex. */ D3DXVECTOR3 position; /** Surface normal at the vertex. */ D3DXVECTOR3 normal; /** Color of the vertex. */ DWORD color; /** Texture coordinates. */ FLOAT s, t; }; /** \details Represents an array of structures. */ typedef OdArray > OdD3DVertexNormalTexColArray; /** \details */ union OdD3DVertexUnionPtr { const OdD3DVertexCol *m_pVC; const OdD3DVertexNormalCol *m_pVNC; const OdD3DVertexNormalTexCol *m_pVNTC; }; /** \details */ struct OdD3DSelMark { OdGsMarker gsMark; OdUInt32 uFrom; }; /** \details Represents an array of structures. */ typedef OdArray > OdD3DSelMarkArray; /** \details This class store resources which must be recreated after D3D device lost state reset. Library: Source code provided. */ class D3dLostStateManager //: public OdRxObject { public: class D3dLostStateEntry { public: /** \details Default constructor for the D3dLostStateEntry class. */ D3dLostStateEntry() { } /** \details Destructor for the D3dLostStateEntry class. */ virtual ~D3dLostStateEntry() { } virtual void recreate(D3dLostStateManager *pManager) = 0; virtual void onManagerDestroy(D3dLostStateManager * /*pManager*/) { } }; public: //ODRX_USING_HEAP_OPERATORS(OdRxObject); /** \details Default constructor for the D3dLostStateManager class. */ D3dLostStateManager(); /** \details Destructor for the D3dLostStateManager class. */ ~D3dLostStateManager(); void clearEntriesList(); bool isManagerEnabled() const; void enableManager(bool bEnable); void setD3DDevice(IDirect3DDevice* pD3Ddevice); IDirect3DDevice* d3dDevice() const; void appendEntry(D3dLostStateEntry *pNewEntry); void removeEntry(D3dLostStateEntry *pEntry); void executeRecreation(); protected: bool m_bEnableManager; CComPtr m_pD3Ddevice; OdList m_entries; }; /** \details This class provides texture resources sharing between DX devices. Library: Source code provided. */ class D3dResourceSharingProvider : public D3dLostStateManager::D3dLostStateEntry { public: struct D3dResourceShareRef; protected: struct D3dResourceShareEntry { IDirect3DTexture *m_pBasePtr; CComPtr m_pEntry; OdList m_refs; D3dResourceSharingProvider *m_pProv; bool operator ==(const D3dResourceShareEntry& e2) const { return m_pBasePtr == e2.m_pBasePtr; } }; typedef OdList shareEntries; shareEntries m_sharedEntries; public: /** \details Default constructor for the D3dResourceSharingProvider class. */ D3dResourceSharingProvider() { } /** \details Destructor for the D3dResourceSharingProvider class. */ ~D3dResourceSharingProvider() { onManagerDestroy(NULL); } struct D3dResourceShareRef { typedef std::map sharedDefs; mutable sharedDefs m_sharedDefs; /** \details Default constructor for the D3dResourceShareRef struct. */ D3dResourceShareRef() { } /** \details Destructor for the D3dResourceShareRef struct. */ ~D3dResourceShareRef() { unlinkShared(); } IDirect3DTexture *getShared(IDirect3DDevice* pCurDevice) const; IDirect3DTexture *createShared(IDirect3DDevice* pCurDevice, IDirect3DTexture* pBaseResource, D3dResourceSharingProvider *pProv) const; void unlinkShared(IDirect3DDevice* pDevice); void unlinkShared(); }; // D3dLostStateManager::D3dLostStateEntry interface void recreate(D3dLostStateManager *pManager); void onManagerDestroy(D3dLostStateManager *pManager); // Managing methods D3dResourceShareEntry *appendEntry(D3dResourceShareRef *pRef, IDirect3DDevice* pCurDevice, IDirect3DTexture* pBaseResource); void unlinkEntry(D3dResourceShareRef *pRef, IDirect3DDevice* pCurDevice, D3dResourceShareEntry *pEntry); }; /** \details This class redirects current OdGsBaseMaterialView functions to geometry. Library: Source code provided. */ class D3dMaterialViewRedirect { public: /** \details Returns current material item. \returns Smart pointer to the material item. */ virtual OdGiMaterialItemPtr geometryCurrentMaterial() const = 0; /** \details Resets current material. \param pMaterial [in] Smart pointer to the material item to set. */ virtual void geometryResetCurrentMaterial(OdGiMaterialItemPtr pMaterial) = 0; /** \details Checks whether material is enabled. \returns true if material is enabled, false otherwise. */ virtual bool geometryIsMaterialEnabled() const = 0; /** \details Checks whether material is available. \returns true if material is available, false otherwise. */ virtual bool geometryIsMaterialAvailable() const = 0; /** \details Resets current material. */ virtual void geometryResetCurrentMaterial() = 0; /** \details Returns current material mapper item. \param bForCoords [in] If true mapper item is used for texture coordinates calculations. \returns Smart pointer to the current mapper item. */ virtual OdGiMapperItemPtr geometryCurrentMapper(bool bForCoords = true) const = 0; /** \details Resets current mapper. \param pMapper [in] Smart pointer to the mapper item to set. */ virtual void geometryResetCurrentMapper(OdGiMapperItemPtr pMapper) = 0; /** \details Checks whether mapper is enabled. \returns true if mapper is enabled, false otherwise. */ virtual bool geometryIsMapperEnabled() const = 0; /** \details Checks whether mapper is available. \returns true if mapper is available, false otherwise. */ virtual bool geometryIsMapperAvailable() const = 0; virtual bool geometryIsMappingDelayed() const = 0; virtual void geometryAppendDelayCacheEntry(void *pEntry) = 0; struct RasterImageRef { CComPtr m_pTexture; int m_nTexLut; CComPtr m_pPalette; }; /** \details Searches a raster image in the cache. \param pImg [in] Pointer to a raster image. \param bTransparency [in] Flag that specifies whether transparency is used. \param fgColor [in] Foreground color. \param bSecColor [in] Flag that specifies whether secondary color is used. \param bkColor [in] Background color. \param fBrightness [in] Image brightness value in range [0..100]. \param fContrast [in] Image contrast value in range [0..100]. \param fFade [in] Image fade value in range [0..100]. \returns Index of an entry in cache if found, otherwise returns 0xFFFFFFFF. The entry needs to have all parameters equal to the provided parameters. */ virtual OdUInt32 findRasterImage(const OdGiRasterImage *pImg, bool bTransparency, ODCOLORREF fgColor, bool bSecColor, ODCOLORREF bkColor, double fBrightness, double fContrast, double fFade) const = 0; /** \details Adds a raster image to the cache. \param pTexture [in] Texture definition. \param pImg [in] Pointer to a raster image. \param bTransparency [in] Flag that specifies whether transparency is used. \param fgColor [in] Foreground color. \param bSecColor [in] Flag that specifies whether secondary color is used. \param bkColor [in] Background color. \param fBrightness [in] Image brightness value in range [0..100]. \param fContrast [in] Image contrast value in range [0..100]. \param fFade [in] Image fade value in range [0..100]. \param bIncrement [in] Flag that specifies whether to increment reference counter. \returns Index of an added entry. */ virtual OdUInt32 addRasterImage(RasterImageRef &pTexture, const OdGiRasterImage *pImg, bool bTransparency, ODCOLORREF fgColor, bool bSecColor, ODCOLORREF bkColor, double fBrightness, double fContrast, double fFade, bool bIncrement = true) = 0; /** \details Increments a reference counter for a cache entry at the specified index. \param uNum [in] Entry number. \returns Image texture at the specified index. */ virtual RasterImageRef incrementRasterImageRef(OdUInt32 uNum) = 0; /** \details Increments a reference counter for a cache entry that has the specified texture. \param pTexture [in] Texture. \returns true if successful, false otherwise. */ virtual bool incrementRasterImageRef(CComPtr pTexture) = 0; /** \details Decrements a reference counter for a cache entry at the specified index. \param uNum [in] Entry number. \returns true if the entry gets removed due to reaching to 0 reference count, false otherwise. */ virtual bool decrementRasterImageRef(OdUInt32 uNum) = 0; /** \details Increments a reference counter for a cache entry that has the specified texture. \param pTexture [in] Texture. \returns true if the entry gets removed due to reaching to 0 reference count, false otherwise. */ virtual bool decrementRasterImageRef(CComPtr pTexture) = 0; virtual bool isSecondaryColorNeed() const = 0; virtual ODCOLORREF getSecondaryColor() const = 0; virtual bool metafileTransformOverrided() const = 0; virtual const OdGeMatrix3d &metafileToWorldMatrix() const = 0; virtual const OdGeMatrix3d &worldToMetafileMatrix() const = 0; virtual const OdGeMatrix3d &viewportToOutputMatrix() const = 0; virtual const OdGeMatrix3d &outputToViewportMatrix() const = 0; virtual void xformByMetafileTransform(OdGeMatrix3d &mtx, bool bInverse = true) const = 0; virtual void xformByMetafileTransform(OdGeVector3d &vec, bool bInverse = true) const = 0; /** \details Returns material textures cache. \returns Pointer to material texture manager. */ virtual OdGiMaterialTextureManager *materialTextureManager() = 0; /** \details Returns resource sharing provider. \returns Pointer to resource sharing provider. */ virtual D3dResourceSharingProvider *sharingProvider() = 0; /** \details Returns MT synchronization helpers. \returns Reference to the OdGsBaseDeviceMTHelpers instance representing multithreading helpers. */ virtual OdGsBaseDeviceMTHelpers *mtDeviceSync() = 0; /** \details Returns TTF fonts cache. \returns Pointer to the OdTtfFontsCache instance containing information about character cache and other font-related data. */ virtual OdTtfFontsCache *getTtfFontsCache() = 0; /** \details Returns color converter used by the device. \returns Pointer to the OdColorConverterCallback object. \remarks For more information, see */ virtual OdColorConverterCallback *getColorConverter() = 0; /** \details Returns background color. \returns DirectX background color. */ virtual DWORD getBackgroundColor() = 0; /** \details Returns current vectorizer state branch by type. \param branchType [in] Branch type. \returns Pointer to current highlight branch. */ virtual const OdGsStateBranch *getCurrentStateBranch(OdGsStateBranch::BranchType branchType = OdGsStateBranch::kHighlightingBranch) const = 0; /** \details Returns true in case if any of state branch types is active. */ virtual bool isAnyStateBranchActive() const = 0; /** \details Returns the dynamic subentities highlighting mode. \returns true if the dynamic subentities highlighting is used, false otherwise. */ virtual bool dynamicSubEntHlt() const = 0; virtual bool useLutPaletteMonochrome() const = 0; virtual bool useLutPaletteColor() const = 0; virtual int checkLineTopology(const OdGePoint3d &pt1, const OdGePoint3d &pt2) const = 0; }; // Material caching data /** \details */ struct D3dMaterialRecordData { /** Contains material characteristics and color values for material channels. */ D3DMATERIAL m_d3dMat; /** Flag that indicates whether diffuse material channel is used. */ bool m_bUseDiffuseMat; /** Flag that indicates whether ambient material channel is used. */ bool m_bUseAmbientMat; /** Flag that indicates whether specular material channel is used. */ bool m_bUseSpecularMat; /** Material opacity percentage in range [0..1]. */ double m_fOpacityPercentage; /** Blend factor of the diffuse map in range [0..1]. 0 - no diffuse map, 1 - opaque diffuse map */ double m_fDiffuseBlendFactor; /** Tiling for U and V parameters. */ OdGiMapper::Tiling m_uTiling, m_vTiling; }; // Material cache entry /** \details This class defines the material cache for DirectX 3D devices. */ class ExD3dMaterialCacheEntry : public OdRxObject { public: //Contains cached material information for a DirectX device. D3dMaterialRecordData m_mat; ODRX_DECLARE_MEMBERS(ExD3dMaterialCacheEntry); public: /** \details Default constructor for the ExD3dMaterialCacheEntry class. */ ExD3dMaterialCacheEntry() { //m_entry = OdGiMaterialItem::createObject(); } /** \details Destructor for the ExD3dMaterialCacheEntry class. */ virtual ~ExD3dMaterialCacheEntry() { } }; /** \details A data type that represents a smart pointer to an object. */ typedef OdSmartPtr ExD3dMaterialCacheEntryPtr; // Material texture data container for D3D device class D3dMetafilePlayContext; /** \details This class defines the material texture data for DirectX 3D devices. */ class ExGiD3dMaterialTextureData : public OdGiMaterialTextureData, protected D3dLostStateManager::D3dLostStateEntry, protected D3dResourceSharingProvider::D3dResourceShareRef { protected: CComPtr m_pTexture; OdGiPixelBGRA32Array m_pLSBits; OdUInt32 m_uLSWidth, m_uLSHeight; D3dLostStateManager *m_pLSManager; public: /** \details Default constructor for the ExGiD3dMaterialTextureData struct. */ ExGiD3dMaterialTextureData(); /** \details Destructor for the ExGiD3dMaterialTextureData struct. */ ~ExGiD3dMaterialTextureData(); ODRX_DECLARE_MEMBERS(ExGiD3dMaterialTextureData); /** \details Set texture pixels from RGBA array. \param pDeviceInfo [in] Optional external device information. \param image [in] Input BGRA image. */ void setTextureData(OdGiMaterialTextureData::DevDataVariant pDeviceInfo, const OdGiImageBGRA32 &image); /** \details Returns texture pixels as array of RGBA colors. \param data [out] Output BGRA colors array. \param width [out] Width of texture. \param width [out] Height of texture. */ void textureData(OdGiPixelBGRA32Array &data, OdUInt32 &width, OdUInt32 &height) const; /** \details Checks whether texture data was previously initialized. \returns true if texture data is initialized, false otherwise. */ bool haveData() const; CComPtr deviceTexture() const; CComPtr deviceTexture(const D3dMetafilePlayContext &ctx) const; protected: void recreate(D3dLostStateManager *pManager); void onManagerDestroy(D3dLostStateManager *pManager); }; /** \details A data type that represents a smart pointer to an object. */ typedef OdSmartPtr ExGiD3dMaterialTextureDataPtr; // //typedef HRESULT (CALLBACK*D3DXCreateMeshFVF_PROC)(DWORD, DWORD, DWORD, DWORD, // LPDIRECT3DDEVICE8, LPD3DXMESH*); /** \details Lineweight style parameters. */ struct D3dLwdStyle { bool m_bPointsLwd; bool m_bCurLwdDef; bool m_bCurLwdUsesDef; OdPs::LineEndStyle m_curLwdLes; OdPs::LineJoinStyle m_curLwdLjs; bool m_bDefLwdDef; OdPs::LineEndStyle m_defLwdLes; OdPs::LineJoinStyle m_defLwdLjs; D3dLwdStyle() : m_bPointsLwd(true) , m_bCurLwdDef(true) , m_bCurLwdUsesDef(true) , m_curLwdLes(OdPs::kLesRound) , m_curLwdLjs(OdPs::kLjsRound) , m_bDefLwdDef(true) , m_defLwdLes(OdPs::kLesRound) , m_defLwdLjs(OdPs::kLjsRound) { } }; /** \details Lineweight settings. */ struct D3dLwdSetting { enum LwdType { kModel = 0, kPlot, kPoint, kAbsolute }; OdUInt8 m_type; void setType(LwdType typ) { m_type = (OdUInt8)typ; } LwdType type() const { return (LwdType)m_type; } bool isForcedLineweight() const { return m_type == kPoint; } union { double m_dLineWeight; OdDb::LineWeight m_lwLineWeight; OdInt32 m_pixLineWeight; } m_val; D3dLwdSetting() : m_type(0) { m_val.m_dLineWeight = 0.0; } bool operator ==(const D3dLwdSetting &sec) const { if (m_type == sec.m_type) { switch (m_type) { case kModel: return m_val.m_lwLineWeight == sec.m_val.m_lwLineWeight; case kAbsolute: case kPlot: return OdEqual(m_val.m_dLineWeight, sec.m_val.m_dLineWeight); case kPoint: return m_val.m_pixLineWeight == sec.m_val.m_pixLineWeight; } } return false; } bool operator !=(const D3dLwdSetting &sec) const { if (m_type == sec.m_type) { switch (m_type) { case kModel: return m_val.m_lwLineWeight != sec.m_val.m_lwLineWeight; case kAbsolute: case kPlot: return !OdEqual(m_val.m_dLineWeight, sec.m_val.m_dLineWeight); case kPoint: return m_val.m_pixLineWeight != sec.m_val.m_pixLineWeight; } } return true; } bool hasLineweight() const { switch (m_type) { case kModel: return m_val.m_lwLineWeight != OdDb::kLnWt000; case kAbsolute: case kPlot: return OdNonZero(m_val.m_dLineWeight); case kPoint: return m_val.m_pixLineWeight > 1; } return false; } OdInt32 toPixels(const OdGsViewImpl &view) const { switch (m_type) { case kModel: return view.lineweightToPixels(m_val.m_lwLineWeight); case kPlot: return OdInt32(OdTruncateToLong(view.lineweightToPixels(m_val.m_dLineWeight))); case kPoint: return m_val.m_pixLineWeight; case kAbsolute: { OdGePoint2d pt; view.getNumPixelsInUnitSquare(OdGePoint3d::kOrigin, pt, false); return OdInt32(OdTruncateToLong(m_val.m_dLineWeight * pt.y)); } } return 1; } }; class OdGsBaseVectorizeView; /** \details This class implements D3d Metafile PlayContext objects. Library: Source code provided. */ class D3dMetafilePlayContext { IDirect3DDevice* m_pDev; mutable OdD3DStateManager* m_pDevSM; OdGsBaseVectorizer* m_pVectorizer; D3dMaterialViewRedirect* m_pMVRedirect; bool m_bReverseNormals; bool m_bForceFill; bool m_bDynamicSubEntHlt; bool m_bImageHighlight; //mutable std::map > m_linePattTextures; mutable CComPtr m_linePattTexture; //mutable std::map > m_fillPattTextures; mutable CComPtr m_fillPattTexture; // Lines highlighting mutable std::map > m_bkgndPattTexture; mutable OdD3DVertexTexColArray m_lineHltMutation; // Line caps mutable OdArray m_lineCaps; mutable OdD3DVertexColArray m_capRender; // Transparency textures mutable OdArray< CComPtr > m_transpTexture; mutable bool m_bTextureEnabled, m_bSkipHLT; mutable OdUInt8 m_transparency[4]; // Vertex arrays OdD3DVertexUnionPtr m_vPtr1, m_vPtr2; // Selection markers const OdD3DSelMark *m_pSelMarks; // Lineweight styles mutable D3dLwdStyle m_lwdStyle; mutable OdGePoint3dArray m_lwdBuffer; // Contains pointer to ExGiDirectXGeometry::m_intMapper element; used internally for rendering process optimization. OdGiMaterialItemPtr *m_pIntMtlPtr; // Lineweight override mutable bool m_bLwdOverride; mutable D3dLwdSetting m_overLineWeight; // Color override mutable bool m_bColorOverride; mutable DWORD m_nColorOverride; mutable OdArray m_colorMutation; mutable bool m_bNoColorMod; bool m_bProcessBackgroundColors; OdColorConverterCallbackCaching m_colorConverter; // Shaders #ifdef OD_USE_DIRECT3D9 mutable int m_bPaletteShaderState; mutable CComPtr< IDirect3DPixelShader9> m_paletteImageShader; #endif mutable OdUInt8 m_subSelectionFlags; bool m_bSuppressHighlighted; bool m_bSuppressUnhighlighted; bool m_bContextModified; bool m_bMarker4Selection; public: bool isContextModified() const { return m_bContextModified; } void setContextModified( bool m ) { m_bContextModified = m; } public: /** \details Default constructor for the D3dMetafilePlayContext class. */ D3dMetafilePlayContext() : m_pDev(0) , m_pDevSM(0) , m_pVectorizer(0) , m_pMVRedirect(NULL) , m_bReverseNormals(false) , m_bForceFill(false) , m_bDynamicSubEntHlt(false) , m_bImageHighlight(false) , m_bTextureEnabled(false) , m_bSkipHLT(false) , m_pSelMarks(NULL) , m_pIntMtlPtr(NULL) , m_bLwdOverride(false) , m_bColorOverride(false) , m_nColorOverride(0) , m_bNoColorMod(false) , m_bProcessBackgroundColors(true) #ifdef OD_USE_DIRECT3D9 , m_bPaletteShaderState(0) #endif , m_subSelectionFlags(0) , m_bSuppressHighlighted(false) , m_bSuppressUnhighlighted(false) , m_bContextModified(false) , m_bMarker4Selection(false) { m_vPtr1.m_pVC = NULL; m_vPtr2.m_pVC = NULL; m_transparency[0] = m_transparency[1] = m_transparency[2] = m_transparency[3] = 0; } /** \details Constructor for the D3dMetafilePlayContext class. \param pDevice [in] Pointer to the device. \param pDevSM [in] Pointer to the state manager. \param pVectorizer [in] Pointer to the vectorizer. */ D3dMetafilePlayContext(IDirect3DDevice* pDevice, OdD3DStateManager* pDevSM, OdGsBaseVectorizer* pVectorizer) : m_pDev(pDevice) , m_pDevSM(pDevSM) , m_pVectorizer(pVectorizer) , m_pMVRedirect(NULL) , m_bReverseNormals(false) , m_bForceFill(false) , m_bDynamicSubEntHlt(false) , m_bImageHighlight(false) , m_bTextureEnabled(false) , m_bSkipHLT(false) , m_pSelMarks(NULL) , m_pIntMtlPtr(NULL) , m_bLwdOverride(false) , m_bColorOverride(false) , m_nColorOverride(0) , m_bNoColorMod(false) , m_bProcessBackgroundColors(true) #ifdef OD_USE_DIRECT3D9 , m_bPaletteShaderState(0) #endif , m_subSelectionFlags(0) , m_bSuppressHighlighted(false) , m_bSuppressUnhighlighted(false) , m_bContextModified(false) , m_bMarker4Selection(false) { m_vPtr1.m_pVC = NULL; m_vPtr2.m_pVC = NULL; m_transparency[0] = m_transparency[1] = m_transparency[2] = m_transparency[3] = 0; } /** \details Returns the device associated with this PlayContext object. \returns Pointer to the device. */ IDirect3DDevice* device() const { return m_pDev; } /** \details Returns the state manager associated with this PlayContext object. \returns Reference to the state manager. */ OdD3DStateManager &stateManager() const { return *m_pDevSM; } /** \details Sets the device associated with this PlayContext object. \param pDevice [in] Pointer to the device. */ void setDevice(IDirect3DDevice* pDevice) { m_pDev = pDevice; } /** \details Sets the state manager associated with this PlayContext object. \param pDevSM [in] Pointer to the state manager. */ void setStateManager(OdD3DStateManager* pDevSM) { m_pDevSM = pDevSM; } /** \details Sets the vectorizer associated with this PlayContext object. \param pVectorizer [in] Pointer to the vectorizer. \param bUpdateVectorizationContext [in] If true, calls update of vectorization context. */ void setVectorizer(OdGsBaseVectorizer* pVectorizer, bool bUpdateVectorizationContext = true) { m_pVectorizer = pVectorizer; if (bUpdateVectorizationContext) updateVectorizerContext(); } /** \details Returns the vectorizer associated with this PlayContext object. \returns Pointer to the vectorizer. */ OdGsBaseVectorizer* vectorizer() const { return m_pVectorizer; } /** \details Returns the view associated with this PlayContext object. \returns Reference to the view. */ OdGsViewImpl& view() const { return m_pVectorizer->view(); } /** \details Sets vectorizer interface for material/mapper functionality. \param pVPRedirect [in] Pointer to D3dMaterialViewRedirect interface. */ void setMaterialViewRedirect(D3dMaterialViewRedirect *pMVRedirect); /** \details Returns vectorizer interface for material/mapper functionality. \returns Pointer to the interface for material/mapper functionality. */ D3dMaterialViewRedirect *materialViewRedirect() const { return m_pMVRedirect; } /** \details Returns the render mode associated with this PlayContext object. \returns Render mode that can be one of the following: NameValueDescription k2DOptimized 0 Standard *display*. Optimized for 2D kWireframe 1 Standard *display*. Uses 3D pipeline kHiddenLine 2 Wireframe *display*. Hidden lines removed kFlatShaded 3 Faceted *display*. One *color* per face kGouraudShaded 4 Smooth shaded *display*. Colors interpolated between *vertices* kFlatShadedWithWireframe 5 Faceted *display* with wireframe overlay kGouraudShadedWithWireframe 6 Smooth shaded *display* with wireframe overlay
*/ OdGsView::RenderMode renderMode() const; /** \details Returns the eye to world transformation matrix of this PlayContext object. \returns Eye to world matrix. */ OdGeMatrix3d eyeToWorld() const; /** \details Returns the reverse normals flag of this PlayContext object. \returns true if normals should be reversed, false otherwise. */ bool reverseNormals() const { return m_bReverseNormals; } /** \details Sets the reverse normals flag of this PlayContext object. \param reverseNormals [in] Contols flag. */ void setReverseNormals(bool reverseNormals) { m_bReverseNormals = reverseNormals; } /** \details Checks whether the force fill flag is used for this PlayContext object. \returns true if the force fill flag is enabled, false otherwise. */ bool forceFill() const { return m_bForceFill; } /** \details Sets the force fill flag of this PlayContext object. \param forceFill [in] The force fill flag. */ void setForceFill(bool forceFill) { m_bForceFill = forceFill; } /** \details Returns raster image contexts highlighting setting. \returns true if the setting is enabled, false otherwise. */ bool imageContentsHlt() const { return m_bImageHighlight; } /** \details Sets the highlighting pass in this PlayContext object. \param nPass [in] Highlighting pass. */ void setHighlightingPass(int nPass) { m_bSuppressHighlighted = GETBIT(nPass, 1); m_bSuppressUnhighlighted = GETBIT(nPass, 2); } /** \details Returns highlighting suppression flag by current highlighting state. \param bHighlight [in] Current highlighting state. \returns The "suppress status" according to the highlight state. */ bool highlightingSuppressed(bool bHighlight) const { return (bHighlight) ? m_bSuppressHighlighted : m_bSuppressUnhighlighted; } /** \details Clears the pattern texture cache of this PlayContext object. */ void clearPattTextureCache() const; /** \details Returns the line pattern texture associated with the specified color for this PlayContext Object. \param textureStage [in] Texture channel to set blending parameters. \param bSetChan [in] Flag that specifies whether to set blending parameters to a channel. \returns Pointer to the line pattern texture. */ IDirect3DTexture* linePattTexture(DWORD textureStage = 0, bool bSetChan = true) const; /** \details Returns the fill pattern texture associated with the specified color for this PlayContext Object. \param textureStage [in] Texture channel to set blending parameters. \param bSetChan [in] Flag that specifies whether to set blending parameters to a channel. \returns Pointer to the fill pattern texture. */ IDirect3DTexture* fillPattTexture(DWORD textureStage = 0, bool bSetChan = true) const; /** \details Returns the background fill pattern texture assicuated with the specified color of background. \param textureStage [in] Texture channel to set blending parameters. \param bSetChan [in] Flag that specifies whether to set blending parameters to a channel. \returns Pointer to the background pattern texture. */ IDirect3DTexture* lineBkgndTexture(DWORD textureStage = 0, bool bSetChan = true) const; /** \details Stop's using of highlighting pattern. \param textureStage [in] Texture channel to set blending parameters. \param bSetChan [in] Flag that specifies whether to set blending parameters to a channel. */ void closePattTextureUsage(DWORD textureStage = 0, bool bSetChan = true) const; /** \details Render wide line with rounded end-caps. \param iPx [in] Line width in pixels. \param origin [in] Start line point. \param fwd [in] Line direction vector multiplied by line length. \param side [in] Line perpendicular vector, defines line plane with direction vector. */ void renderLineCap(int iPx, const OdD3DVertexCol *origin, const OdGeVector3d &fwd, const OdGeVector3d &side) const; /** \details Clears array with pregenerated line end-caps. */ void clearLineCaps() const; /** \details Gets pointer to texture of specified transparency level. \param alpha [in] Alpha level. \returns Pointer to the line pattern texture. */ IDirect3DTexture *getTransparencyLevelTexture(OdUInt8 alpha) const; /** \details Clears array of transparency textures. */ void clearTransparencyLevels() const; /** \details Renders simple 1px line with background color. \param points [in] Line vertices array. \param nPoints [in] Count of points into points array. \param bLines [in] If true, points in points array defines not linked lines list (2 points for each line), otherwise points array defines linked line vertices list (end vertex of previous line is equal to start vertex of the next line). */ void renderBkgndLine(const OdD3DVertexCol *points, OdUInt32 nPoints, bool bLines = false) const; /** \details Renders highlighted lines using mutation array. \param points [in] Line vertices array. \param nPoints [in] Count of points into points array. \param bBackFill [in] Enables back filling. \param bLines [in] If true, points in points array defines not linked lines list (2 points for each line), otherwise points array defines linked line vertices list (end vertex of previous line is equal to start vertex of the next line). */ void renderHighlightedLine(const OdD3DVertexCol *points, OdUInt32 nPoints, bool bBackFill = false, bool bLines = false) const; /** \details Renders highlighted triangles. \param PrimitiveType [in] Type of primitive. \param PrimitiveCount [in] Count of primitives. \param pVertexStreamZeroData [in] Primitive array pointer. \param VertexStreamZeroStride [in] Size of primitive array entry. \param textureStage [in] Texture channel to set blending parameters. */ void renderHighlightedTriangle(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, const void* pVertexStreamZeroData, UINT VertexStreamZeroStride, DWORD textureStage = 0) const; /** \details Updates material texture set. \param bSet [in] Flag. */ void updateMaterialTexture(bool bSet, bool bSkipHLT = false) const; enum TransparencySet { Transparency_Material = 0, Transparency_Color, Transparency_PSel, Transparency_LSel, Transparency_Force, Transparency_Reset }; /** \details Updates transparency state. \param nSet [in] Transparency entry. \param nVal [in] New state. */ void updateTransparencyState(TransparencySet nSet, OdUInt8 nVal) const; /** \details Safely resets current texture. */ void resetTextureState() const; /** \details Sets pointer to vertex array (1-st slot). */ inline void setVPtr1(const OdD3DVertexUnionPtr &vtPtr) { m_vPtr1 = vtPtr; } /** \details Sets pointer to vertex array (2-nd slot). */ inline void setVPtr2(const OdD3DVertexUnionPtr &vtPtr) { m_vPtr2 = vtPtr; } /** \details Returns pointer to vertex array (1-st slot). */ inline const OdD3DVertexUnionPtr &vtPtr1() const { return m_vPtr1; } /** \details Returns pointer to vertex array (2-nd slot). */ inline const OdD3DVertexUnionPtr &vtPtr2() const { return m_vPtr2; } /** \details Sets selection markers array. */ inline void setSelMarks(const OdD3DSelMark *pSM, bool b4Selection = false) { m_pSelMarks = pSM; m_bMarker4Selection = b4Selection; } /** \details Returns selection markers array. */ inline const OdD3DSelMark *selMarks() const { return m_pSelMarks; } /** \details Changes current selection marker. */ void setSelectionMarker(OdGsMarker gsMarker) const; /** \details Checks is selection markers check is required. */ bool isSubselectionRequired() const; /** \details Returns current lineweight style state. */ inline D3dLwdStyle &lwdStyle() const { return m_lwdStyle; } /** \details Temporary lineweights generator buffer. */ inline OdGePoint3dArray &lwdBuf() const { return m_lwdBuffer; } /** \details Link with geometry for some optimization purposes. */ inline void setIntMtlPtr(OdGiMaterialItemPtr* pIntMtlPtr) { m_pIntMtlPtr = pIntMtlPtr; } /** \details Link with geometry for some optimization purposes. */ inline OdGiMaterialItemPtr* intMtlPtr() const { return m_pIntMtlPtr; } /** \details Returns dynamic subentities highlighting mode. */ inline bool dynamicSubEntHlt() const { return m_bDynamicSubEntHlt; } /** \details Sets lineweight override mode. */ inline void setLineweightOverride(bool bSet) const { m_bLwdOverride = bSet; } /** \details Sets lineweight override mode settings. */ inline void setLineweightOverride(const D3dLwdSetting &set) const { m_bLwdOverride = true; m_overLineWeight = set; } /** \details Returns lineweight override mode. */ inline bool isLineweightOverride() const { return m_bLwdOverride; } /** \details Applies lineweight overrides. */ inline bool applyLineweightOverride(D3dLwdSetting &lwd) const { if (m_overLineWeight != lwd) { lwd = m_overLineWeight; return true; } return false; } /** \details Sets color override mode. */ inline void setColorOverride(bool bSet) const { m_bColorOverride = bSet; } /** \details Sets color override mode settings. */ inline void setColorOverride(DWORD nColor) const { m_nColorOverride = nColor; m_bColorOverride = true; } /** \details Returns color override mode. */ inline bool isColorOverride() const { return m_bColorOverride; } /** \details Returns current color override. */ inline DWORD colorOverride() const { return m_nColorOverride; } /** \details Returns true if and only if requested color must be overriden. */ inline bool isNeedOverride(DWORD color) const { return (m_bColorOverride && (m_nColorOverride != color)) || (m_colorConverter.colorConverterCallback() && (m_bProcessBackgroundColors || !m_bNoColorMod)); } /** \details Applies color override for single color. */ inline DWORD makeColorOverride(DWORD color, bool bIfNeed = true) const; /** \details Applies color override for data array. */ const void* makeColorOverride(const void *pInData, OdUInt32 nOffsetToClr, OdUInt32 nEntrySize, OdUInt32 nEntries) const; /** \details Sets "no color modification" mode. */ inline void setNoColorModificationMode(bool bSet) const { m_bNoColorMod = bSet; } #ifdef OD_USE_DIRECT3D9 /** \details Requests for palette shader. */ IDirect3DPixelShader9 *paletteImageShader() const; #endif void setSubselectionFlags( OdUInt8 flags ) const { m_subSelectionFlags = flags; } OdUInt8 getSubselectionFlags() const { return m_subSelectionFlags; } bool isDisplayHighlighted() const; bool isDisplayUnhighlighted() const; bool isSelectHighlighted() const; bool isSelectUnhighlighted() const; bool isDisplayWithHighlight() const; bool isSelectWithHighlight() const; protected: void updateVectorizerContext(); }; //A structure for play4Select parameters /** \details This structure contains parameters for play4Select. */ struct D3dPlay4SelectContext { OdGiConveyorGeometry* pGeometry; OdGiConveyorContext* pGeometryContext; bool bCheckMarkFlag; OdGePoint3dArray ptsArray; }; /** \details This class is the base class for D3dRecord objects. Library: Source code provided. \remarks Record objects are linked to form a Record List. */ class D3dRecord { protected: D3dRecord* m_pTail; ODCA_HEAP_ALLOCATOR(); public: //DOM-IGNORE-BEGIN ODCA_HEAP_OPERATORS(); //DOM-IGNORE-END /** \details Default constructor for the D3dRecord class. */ D3dRecord() : m_pTail(0) {} /** \details Destructor for the D3dRecord class. */ virtual ~D3dRecord() {} /** \details Destroys this Record object and all Record objects linked to it. */ void destroy(); /** \details Adds the specified Record to the tail of this Record object. \param pTail [in] Pointer to the new tail. */ void setTail(D3dRecord* pTail) { m_pTail = pTail; } /** \details Returns or references the tail of this Record object. */ const D3dRecord* tail() const { return m_pTail; } /** \details Returns or references the tail of this Record object. */ D3dRecord* tail() { return m_pTail; } /** \details Renders this Record object. \param pContext [in] Pointer to the Play context. */ virtual void play(const D3dMetafilePlayContext& pContext) const = 0; virtual void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const = 0; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements D3d Head Record objects. Library: Source code provided. */ class D3dHeadRecord : public D3dRecord { public: void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Deletes the Record objects linked to this HeaderRecord object. */ void deleteList(); /** \details Destructor for the D3dHeadRecord class. */ ~D3dHeadRecord(); virtual OdUInt64 recordSize() const; }; /** \details This class is implements D3d Point Record objects. Library: Source code provided. */ class D3dPointRecord : public D3dRecord { OdD3DVertexCol m_pos; public: /** \details Constructor for the D3dPointRecord class. \param position [in] Position of the point. \param color [in] Color of the point. */ D3dPointRecord(const OdGePoint3d& position, DWORD color); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified PointRecord object. \param position [in] Position of the point. \param color [in] Color of the point. \remarks Returns a pointer to the newly created object. */ static D3dPointRecord* createObject(const OdGePoint3d& position, DWORD color); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements packed D3d Point Record objects. Library: Source code provided. */ class D3dPackedPointRecord : public D3dRecord { protected: OdInt32 m_nInitialID; OdInt32 m_nbPoints; public: /** \details Constructor for the D3dPackedPointRecord class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numPoints [in] Number of points. */ D3dPackedPointRecord(OdInt32 nInitialID, OdInt32 numPoints); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified D3dPackedPointRecord object. \param nInitialID [in] Index of first vertex in vertex buffer. \param numPoints [in] Number of points. \remarks Returns a pointer to the newly created object. */ static D3dPackedPointRecord* createObject(OdInt32 nInitialID, OdInt32 numPoints); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details Extends D3dPackedPointRecord by selection markers array processing. Library: Source code provided. */ class D3dPackedPointRecordWSel : public D3dPackedPointRecord { OdInt32 m_nInitialSelMark; OdInt32 m_nbSelMarks; public: /** \details Constructor for the D3dPackedPointRecordWSel class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numPoints [in] Number of points. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. */ D3dPackedPointRecordWSel(OdInt32 nInitialID, OdInt32 numPoints, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified D3dPackedPointRecordWSel object. \param nInitialID [in] Index of first vertex in vertex buffer. \param numPoints [in] Number of points. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. \remarks Returns a pointer to the newly created object. */ static D3dPackedPointRecordWSel* createObject(OdInt32 nInitialID, OdInt32 numPoints, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements D3d Polyline Record objects. Library: Source code provided. */ class D3dPolylineRecord : public D3dRecord { OdInt32 m_nPoints; OdD3DVertexCol m_points[1]; public: /** \details Constructor for the D3dPolylineRecord class. \param numPoints [in] Number of points. \param points [in] Array of points. \param color [in] Color of the polyline. */ D3dPolylineRecord(OdInt32 numPoints, const OdGePoint3d* points, DWORD color); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified PolylineRecord object. \param numPoints [in] Number of points. \param points [in] Array of points. \param color [in] Color of the polyline. \remarks Returns a pointer to the newly created object. */ static D3dPolylineRecord* createObject(OdInt32 numPoints, const OdGePoint3d* points, DWORD color); virtual OdUInt64 recordSize() const; }; /** \details This class is implements packed D3d Polyline Record objects. Library: Source code provided. */ class D3dPackedPolylineRecord : public D3dRecord { protected: OdInt32 m_nInitialID; OdInt32 m_nbLines; public: /** \details Constructor for the D3dPackedPolylineRecord class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numLines [in] Number of line segments. */ D3dPackedPolylineRecord(OdInt32 nInitialID, OdInt32 numLines); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified D3dPackedPolylineRecord object. \param nInitialID [in] Index of first vertex in vertex buffer. \param numLines [in] Number of line segments. \remarks Returns a pointer to the newly created object. */ static D3dPackedPolylineRecord* createObject(OdInt32 nInitialID, OdInt32 numLines); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details Extends D3dPackedPolylineRecord by selection markers array processing. Library: Source code provided. */ class D3dPackedPolylineRecordWSel : public D3dPackedPolylineRecord { OdInt32 m_nInitialSelMark; OdInt32 m_nbSelMarks; public: /** \details Constructor for the D3dPackedPolylineRecordWSel class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numLines [in] Number of line segments. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. */ D3dPackedPolylineRecordWSel(OdInt32 nInitialID, OdInt32 numLines, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified D3dPackedPolylineRecordWSel object. \param nInitialID [in] Index of first vertex in vertex buffer. \param numLines [in] Number of line segments. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. \remarks Returns a pointer to the newly created object. */ static D3dPackedPolylineRecordWSel* createObject(OdInt32 nInitialID, OdInt32 numLines, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements packed D3d Polyline Strip Record objects. Library: Source code provided. */ class D3dPackedPolylineStripRecord : public D3dRecord { OdInt32 m_nInitialID; OdInt32 m_nbVertices; public: /** \details Constructor for the D3dPackedPolylineStripRecord class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numVertices [in] Number of vertices. */ D3dPackedPolylineStripRecord(OdInt32 nInitialID, OdInt32 numVertices); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified D3dPackedPolylineStripRecord object. \param nInitialID [in] Index of first line. \param numLines [in] Number of lines. \remarks Returns a pointer to the newly created object. */ static D3dPackedPolylineStripRecord* createObject(OdInt32 nInitialID, OdInt32 numLines); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; #ifndef OD_USE_DIRECT3D9 /** \details This class is implements D3d Polyline with Linetype Record objects. Library: Source code provided. */ class D3dLtpPolylineRecord : public D3dRecord { OdInt32 m_nbPoints; WORD m_wLinePattern, m_wRepeatFactor; OdD3DVertexCol m_pPts[1]; public: /** \details Constructor for the D3dLtpPolylineRecord class. \param numPoints [in] Number of points. \param points [in] Array of points. \param color [in] Color of the polyline. \param linePattern [in] Line pattern of the polyline. \param repeatFactor [in] Repeat factor of the linetype. */ D3dLtpPolylineRecord(OdInt32 numPoints, const OdGePoint3d* points, DWORD color, WORD linePattern, WORD repeatFactor); void play(const D3dMetafilePlayContext& pContext) const; /** \details Creates the specified LtpPolylineRecord object. \param numPoints [in] Number of points. \param points [in] Array of points. \param color [in] Color of the polyline. \param linePattern [in] Line pattern of the polyline. \param repeatFactor [in] Repeat factor of the polyline. \remarks Returns a pointer to the newly created object. */ static D3dLtpPolylineRecord* createObject(OdInt32 numPoints, const OdGePoint3d* points, DWORD color, WORD linePattern, WORD repeatFactor); /** \details Returns the number of points in this LtpPolylineRecord object. \returns Number of points. */ OdInt32 pointsNum() const { return m_nbPoints; } /** \details Returns a pointer to the point array of this LtpPolylineRecord object. \returns Pointer to the point array. */ const OdD3DVertexCol* pPoints() const { return m_pPts; } /** \details Returns the line pattern of this LtpPolylineRecord object. */ WORD linePattern() const { return m_wLinePattern; } /** \details Returns the repeat factor of this LtpPolylineRecord object. */ WORD repeatFactor() const { return m_wRepeatFactor; } }; #endif /** \details This class is implements D3d Polyline with Linewidth Record objects. Library: Source code provided. */ class D3dLwdPolylineRecord : public D3dRecord { OdInt32 m_nbPoints, m_nbRPoints; // WORD m_wLinePattern, m_wRepeatFactor; // May be used in future for patterned lines mutable OdGePoint3d m_vcn[2]; double m_lwd; OdD3DVertexCol m_pPts[1]; public: /** \details Constructor for the D3dLwdPolylineRecord class. \param numPoints [in] Number of points. \param points [in] Array of points. \param color [in] Color of the polyline. \param lwd [in] Width of the polyline. */ D3dLwdPolylineRecord(OdInt32 numPoints, const OdGePoint3d* points, DWORD color, double lwd); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified LwdPolylineRecord object. \param numPoints [in] Number of points. \param points [in] Array of points. \param color [in] Color of the polyline. \param lwd [in] Width of the polyline. \remarks Returns a pointer to the newly created object. */ static D3dLwdPolylineRecord* createObject(OdInt32 numPoints, const OdGePoint3d* points, DWORD color, double lwd); virtual OdUInt64 recordSize() const; protected: static OdInt32 calculateVerticesCount(OdInt32 numPoints, int nprec); static int calculateCapsSize(double lwd); void regeneratePrimitive(OdInt32 numPoints, DWORD color, const OdGeVector3d &vcn, double lwd, int nprec); void generateMesh(OdD3DVertexCol *verts, const OdD3DVertexCol *p1, const OdD3DVertexCol *p2, DWORD color, const OdGeVector3d &vcn, double lwd, int nprec); bool isNeedRebuild(const D3dMetafilePlayContext& pContext) const; }; /** \details This class is implements packed D3d Polyline with Lineweight Record objects. Library: Source code provided. */ class D3dPackedLwdPolylineRecord : public D3dRecord { protected: bool m_bPoints; OdInt32 m_nInitialID; OdInt32 m_nbLines; D3dLwdSetting m_lineWeight; mutable OdGeVector3d m_viewDirection; // Differ instructs to recalc line cache mutable OdInt32 m_nPxSize; mutable OdUInt32 m_nView; mutable double m_dSize; // Size in depth / 2 mutable double m_dSize2; // Size in depth mutable double m_lwScaleCoef; // Used to detect MS or PS lineweights vectorization style mutable double m_lwCoef; // MS coefficient mutable float m_pixelAspect; // Num pixels in unit square mutable OdUInt32 m_flags; struct LwdCache { //double len; // Size in depth OdGeVector3d dir; // Direction * len OdGeVector3d side; // Side * len }; mutable LwdCache m_pCache[1]; // Cache of line data public: /** \details Constructor for the D3dPackedLwdPolylineRecord class. \param bPoints [in] Render as points or as lines. \param nInitialID [in] Index of first vertex in vertex buffer. \param numLines [in] Number of line segments. \param lineWeight [in] Lineweight settings. */ D3dPackedLwdPolylineRecord(bool bPoints, OdInt32 nInitialID, OdInt32 numLines, const D3dLwdSetting &lineWeight); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified D3dPackedLwdPolylineRecord object. \param bPoints [in] Render as points or as lines. \param nInitialID [in] Index of first vertex in vertex buffer. \param numLines [in] Number of line segments. \param lineWeight [in] Lineweight settings. \remarks Returns a pointer to the newly created object. */ static D3dPackedLwdPolylineRecord* createObject(bool bPoints, OdInt32 nInitialID, OdInt32 numLines, const D3dLwdSetting &lineWeight); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } protected: OdInt32 computePxSize(const D3dMetafilePlayContext& pContext) const; bool isNeedCacheRebuilding(const D3dMetafilePlayContext& ctx) const; void regenCache(const D3dMetafilePlayContext& ctx) const; void regenLine(LwdCache *outCache, const OdD3DVertexCol *inVerts, const OdGeVector3d &vcn) const; }; /** \details Helper reservation place for D3dPackedLwdPolylineRecordWSel objects. Library: Source code provided. */ struct D3dPackedLwdPolylineRecordDataReservation // #VIS-1699 { OdInt32 m_nInitialSelMark; OdInt32 m_nbSelMarks; D3dPackedLwdPolylineRecordDataReservation(OdInt32 nInitialSelMark, OdInt32 nbSelMarks) : m_nInitialSelMark(nInitialSelMark), m_nbSelMarks(nbSelMarks) { } }; /** \details Extends D3dPackedLwdPolylineRecord by selection markers array processing. Library: Source code provided. */ class D3dPackedLwdPolylineRecordWSel : public D3dPackedLwdPolylineRecord { D3dPackedLwdPolylineRecordDataReservation &selData() const { return *(D3dPackedLwdPolylineRecordDataReservation*)(m_pCache + m_nbLines); } public: /** \details Constructor for the D3dLwdPolylineRecord class. \param bPoints [in] Render as points or as lines. \param nInitialID [in] Index of first vertex in vertex buffer. \param numLines [in] Number of line segments. \param lineWeight [in] Lineweight settings. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. */ D3dPackedLwdPolylineRecordWSel(bool bPoints, OdInt32 nInitialID, OdInt32 numLines, const D3dLwdSetting &lineWeight, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified D3dPackedLwdPolylineRecordWSel object. \param bPoints [in] Render as points or as lines. \param nInitialID [in] Index of first vertex in vertex buffer. \param numLines [in] Number of line segments. \param lineWeight [in] Lineweight settings. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. \remarks Returns a pointer to the newly created object. */ static D3dPackedLwdPolylineRecordWSel* createObject(bool bPoints, OdInt32 nInitialID, OdInt32 numLines, const D3dLwdSetting &lineWeight, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements D3d Triangle Record objects. Library: Source code provided. */ class D3dTriangleRecord : public D3dRecord { OdD3DVertexCol m_points[3]; public: /** \details Creates the specified D3dTriangleRecord object. \param points [in] Array of three points. */ D3dTriangleRecord(const OdD3DVertexCol* points); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements D3d Triangle with Normals Record objects. Library: Source code provided. */ class D3dTriangleNormalRecord : public D3dRecord { mutable OdD3DVertexNormalCol points[3]; // in case bReverseNormals we have to modify this field public: /** \details Constructor for the D3dTriangleNormalRecord class. \param points [in] Array of three points. */ D3dTriangleNormalRecord(OdD3DVertexNormalCol* points); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements D3d Triangle Texture with Normals Record objects. Library: Source code provided. */ class D3dTriangleNormalTextureRecord : public D3dRecord { mutable OdD3DVertexNormalTexCol points[3]; // in case bReverseNormals we have to modify this field public: /** \details Constructor for the D3dTriangleNormalTextureRecord class. \param points [in] Array of three points. */ D3dTriangleNormalTextureRecord(OdD3DVertexNormalTexCol* points); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements packed D3d Triangle Record objects. Library: Source code provided. */ class D3dPackedTriangleRecord : public D3dRecord { protected: OdInt32 m_nInitialID; OdInt32 m_nbTriangles; public: /** \details Constructor for the D3dPackedTriangleRecord class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. */ D3dPackedTriangleRecord(OdInt32 nInitialID, OdInt32 numTriangles); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified PackedTriangleRecord object. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. \remarks Returns a pointer to the newly created object. */ static D3dPackedTriangleRecord* createObject(OdInt32 nInitialID, OdInt32 numTriangles); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details Extends D3dPackedTriangleRecord by selection markers array processing. Library: Source code provided. */ class D3dPackedTriangleRecordWSel : public D3dPackedTriangleRecord { OdInt32 m_nInitialSelMark; OdInt32 m_nbSelMarks; public: /** \details Constructor for the D3dPackedTriangleRecordWSel class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. */ D3dPackedTriangleRecordWSel(OdInt32 nInitialID, OdInt32 numTriangles, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified PackedTriangleRecordWSel object. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. \remarks Returns a pointer to the newly created object. */ static D3dPackedTriangleRecordWSel* createObject(OdInt32 nInitialID, OdInt32 numTriangles, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements packed D3d Triangle with Normals Record objects. Library: Source code provided. */ class D3dPackedTriangleNormalRecord : public D3dRecord { protected: OdInt32 m_nInitialID; OdInt32 m_nbTriangles; public: /** \details Constructor for the D3dPackedTriangleNormalRecord class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. */ D3dPackedTriangleNormalRecord(OdInt32 nInitialID, OdInt32 numTriangles); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified PackedTriangleNormalRecord object. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. \remarks Returns a pointer to the newly created object. */ static D3dPackedTriangleNormalRecord* createObject(OdInt32 nInitialID, OdInt32 numTriangles); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details Extends D3dPackedTriangleNormalRecord by selection markers array processing. Library: Source code provided. */ class D3dPackedTriangleNormalRecordWSel : public D3dPackedTriangleNormalRecord { OdInt32 m_nInitialSelMark; OdInt32 m_nbSelMarks; public: /** \details Constructor for the D3dPackedTriangleNormalRecordWSel class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. */ D3dPackedTriangleNormalRecordWSel(OdInt32 nInitialID, OdInt32 numTriangles, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified PackedTriangleNormalRecordWSel object. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. \remarks Returns a pointer to the newly created object. */ static D3dPackedTriangleNormalRecordWSel* createObject(OdInt32 nInitialID, OdInt32 numTriangles, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements packed D3d Triangle Texture with Normals Record objects. Library: Source code provided. */ class D3dPackedTriangleNormalTextureRecord : public D3dRecord { protected: OdInt32 m_nInitialID; OdInt32 m_nbTriangles; public: /** \details Constructor for the D3dPackedTriangleNormalTextureRecord class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. */ D3dPackedTriangleNormalTextureRecord(OdInt32 nInitialID, OdInt32 numTriangles); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified PackedTriangleNormalTextureRecord object. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. \remarks Returns a pointer to the newly created object. */ static D3dPackedTriangleNormalTextureRecord* createObject(OdInt32 nInitialID, OdInt32 numTriangles); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details Extends D3dPackedTriangleNormalTextureRecord by selection markers array processing. Library: Source code provided. */ class D3dPackedTriangleNormalTextureRecordWSel : public D3dPackedTriangleNormalTextureRecord { OdInt32 m_nInitialSelMark; OdInt32 m_nbSelMarks; public: /** \details Constructor for the D3dPackedTriangleNormalTextureRecordWSel class. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. */ D3dPackedTriangleNormalTextureRecordWSel(OdInt32 nInitialID, OdInt32 numTriangles, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Creates the specified PackedTriangleNormalTextureRecordWSel object. \param nInitialID [in] Index of first vertex in vertex buffer. \param numTriangles [in] Number of triangles. \param nInitialSelMark [in] Index of first selection marker in selection markers array. \param nbSelMarks [in] Count of selection markers in selection markers array. \remarks Returns a pointer to the newly created object. */ static D3dPackedTriangleNormalTextureRecordWSel* createObject(OdInt32 nInitialID, OdInt32 numTriangles, OdInt32 nInitialSelMark, OdInt32 nbSelMarks); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class is implements D3d Initialized Texture Record objects. Library: Source code provided. */ class D3dInitTextureRecord : public D3dRecord, protected D3dLostStateManager::D3dLostStateEntry, protected D3dResourceSharingProvider::D3dResourceShareRef { D3dMaterialViewRedirect::RasterImageRef m_texture; D3dResourceSharingProvider::D3dResourceShareRef m_palRef; OdGeMatrix3d m_w2TxXform; enum ITFlags { kTransp = 1, // True for transparent kBitonal = 2, // True for bitonal kDraft = 4, // True for draft quality kAlpha1 = 8, // True if transparency mode 1bit kAlpha8 = 16 // True if transparency mode 8bit }; OdUInt8 m_uFlags; D3dMaterialViewRedirect *m_pUninitIface; D3dLostStateManager *m_pLSManager; public: /** \details Constructor for the D3dInitTextureRecord class. \param pTexture [in] Pointer to the texture. \param w2TxXform [in] World to texture transformation matrix. \param transparency [in] If true texture is transparent. \param bitonal [in] If true texture is bitonal. \param draft [in] If true texture has draft quality. \param bAlpha1Bit [in] If true 32bit image has 1bit transparency mode. \param bAlpha8Bit [in] If true 32bit image has 8bit transparency mode. \param pUninitIface [in] Raster image cache uninitialization interface. \param pLSManager [in] Resources recovering interface. */ D3dInitTextureRecord(D3dMaterialViewRedirect::RasterImageRef &pTexture, const OdGeMatrix3d& w2TxXform, bool transparency, bool bitonal, bool draft, bool bAlpha1Bit, bool bAlpha8Bit, D3dMaterialViewRedirect *pUninitIface, D3dLostStateManager *pLSManager); /** \details Destructor for the D3dInitTextureRecord class. */ ~D3dInitTextureRecord(); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const; protected: void recreate(D3dLostStateManager *pManager); void onManagerDestroy(D3dLostStateManager *pManager); }; /** \details This class implements D3d Uninitialized Texture Record objects. Library: Source code provided. */ class D3dUninitTextureRecord : public D3dRecord { public: /** \details Default constructor for the D3dUninitTextureRecord class. */ D3dUninitTextureRecord(); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements base class for empty D3d Record which represent Begin or End for some functionality. Library: Source code provided. */ class D3dBaseBeginOrEndRecord : public D3dRecord { public: /** \details Default constructor. */ D3dBaseBeginOrEndRecord(); /** \details Returns true if and only if this record is begin highlighting record. */ virtual bool isBegin() const = 0; /** \details Returns true if and only if this record is end highlighting record. */ virtual bool isEnd() const { return !isBegin(); } virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements base class for Begin and End Highlighting Record objects. Library: Source code provided. */ class D3dBaseHighlightingRecord : public D3dBaseBeginOrEndRecord { public: /** \details Default constructor. */ D3dBaseHighlightingRecord(); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements D3d Begin Highlighting Record object. Library: Source code provided. */ class D3dBeginHighlightingRecord : public D3dBaseHighlightingRecord { public: /** \details Default constructor. */ D3dBeginHighlightingRecord(); /** \details Returns true if and only if this record is begin highlighting record. */ bool isBegin() const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements D3d End Highlighting Record object. Library: Source code provided. */ class D3dEndHighlightingRecord : public D3dBaseHighlightingRecord { public: /** \details Default constructor. */ D3dEndHighlightingRecord(); /** \details Returns true if and only if this record is begin highlighting record. */ bool isBegin() const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements base class for Begin and End Hiding Record objects. Library: Source code provided. */ class D3dBaseHideRecord : public D3dBaseBeginOrEndRecord { public: /** \details Default constructor. */ D3dBaseHideRecord(); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements D3d Begin Hiding Record object. Library: Source code provided. */ class D3dBeginHideRecord : public D3dBaseHideRecord { public: /** \details Default constructor. */ D3dBeginHideRecord(); /** \details Returns true if and only if this record is begin highlighting record. */ bool isBegin() const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements D3d End Hiding Record object. Library: Source code provided. */ class D3dEndHideRecord : public D3dBaseHideRecord { public: /** \details Default constructor. */ D3dEndHideRecord(); /** \details Returns true if and only if this record is begin highlighting record. */ bool isBegin() const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements Selection Marker Record object. Library: Source code provided. */ class D3dSelectionMarkerRecord : public D3dRecord { OdGsMarker m_gsMarker; // Subentity selection marker public: /** \details Constructor. Creates a new D3dSelectionMarkerRecord object by the input OdGsMarker object. */ D3dSelectionMarkerRecord(OdGsMarker gsMarker); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements Transparency Record object. Library: Source code provided. */ class D3dTransparencyRecord : public D3dRecord { OdUInt8 m_transparency; // inverted alpha public: D3dTransparencyRecord(OdUInt8 invAlpha); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements Lineweight Style Record object. Library: Source code provided. */ class D3dLwdStyleRecord : public D3dRecord { OdUInt8 m_lwdStyle[3]; public: /** \details Default constructor. */ D3dLwdStyleRecord(); // for def D3dLwdStyleRecord(OdPs::LineEndStyle lesStyle, OdPs::LineJoinStyle ljsStyle); // for non-def void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements base class for Begin and End No Color Modification Record objects. Library: Source code provided. */ class D3dBaseNoColorModRecord : public D3dBaseBeginOrEndRecord { public: /** \details Default constructor. */ D3dBaseNoColorModRecord(); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements D3d Begin Highlighting Record object. Library: Source code provided. */ class D3dBeginNoColorModRecord : public D3dBaseNoColorModRecord { public: /** \details Default constructor. */ D3dBeginNoColorModRecord(); /** \details Returns true if and only if this record is begin highlighting record. */ bool isBegin() const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements D3d End Highlighting Record object. Library: Source code provided. */ class D3dEndNoColorModRecord : public D3dBaseNoColorModRecord { public: /** \details Default constructor. */ D3dEndNoColorModRecord(); /** \details Returns true if and only if this record is begin highlighting record. */ bool isBegin() const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class added to disable faces culling for subsequent geometry. Library: Source code provided. */ class D3dKillFaceCullingRecord : public D3dRecord { public: /** \details Default constructor. */ D3dKillFaceCullingRecord(); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details This class implements TTF Text Record object. Library: Source code provided. */ class D3dTtfTextRecord : public D3dRecord { OdTtfFontsCache::TextInfo m_textInfo; D3dLwdSetting m_lineWeight; DWORD m_nColor; public: /** \details Constructor for the D3dTtfTextRecord class. \param textInfo [in] Cache text info. \param lineWeight [in] Lineweight settings. \param m_nColor [in] Color value. */ D3dTtfTextRecord(const OdTtfFontsCache::TextInfo &textInfo, const D3dLwdSetting &lineWeight, DWORD m_nColor); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; // Material record for enabled/disabled GsModel /** \details This class implements D3d Material Record objects. */ class D3dMaterialRecord : public D3dRecord { OdGiMaterialItemPtr m_pMatItem; // Material data pointer public: /** \details Constructor for the D3dMaterialRecord class. \param pMatItem [in] Material item. */ D3dMaterialRecord(OdGiMaterialItemPtr pMatItem); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; static D3dMaterialRecord* createObject(OdGiMaterialItemPtr pMatItem); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details */ enum OdDirectXSelectionFlags { OdDirectXSelFlag_DontDisplayUnhighlighted = (1 << 0), OdDirectXSelFlag_DontSelectUnhighlighted = (1 << 1), OdDirectXSelFlag_DontDisplayHighlighted = (1 << 2), OdDirectXSelFlag_DontSelectHighlighted = (1 << 3), OdDirectXSelFlag_FlagsMask = 15 }; /** \details This class implements D3d Selection Mode Record objects. */ class D3dSelectionModeRecord : public D3dRecord { OdUInt8 m_flags; public: /** \details Constructor for the D3dSelectionModeRecord class. \param flags [in] A set of selection flags. See OdDirectXSelectionFlags enumeration for more information. */ D3dSelectionModeRecord( OdUInt8 flags ); void play(const D3dMetafilePlayContext& pContext) const; void play4Select( const D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; static D3dSelectionModeRecord* createObject( OdUInt8 flags ); virtual OdUInt64 recordSize() const { return (OdUInt64)sizeof(*this); } }; /** \details Sometimes object mapping may be delayed up to object will be completely cached. This structure defines coordinates set for one mapper texture coordinates recalculation. Library: Source code provided. */ struct ExGsDelayedMappingEntry; /** \details This class is implements DirectX Metafile objects. Library: Source code provided. */ class ExGiDirectXMetafile : public OdRxObject { // line segments D3dHeadRecord m_lineSegsCache; D3dRecord* m_pLineSegsTail; // no light triangles D3dHeadRecord m_noLightCache; D3dRecord* m_pNoLightTail; // light triangles D3dHeadRecord m_lightCache; D3dRecord* m_pLightTail; OdD3DVertexColArray m_LineSegArray; // Array of line segment vertices. OdD3DVertexColArray m_NoLightTriArray; // Array of no-light vertices. OdD3DVertexNormalColArray m_LightTriArray; // Vertices with normals. OdD3DVertexNormalTexColArray m_TexturedTriArray; // Vertices with normals and texture coordinates. OdD3DSelMarkArray m_SelMarks; // Selection markers array. ODRX_DECLARE_MEMBERS(ExGiDirectXMetafile); public: /** \details Default constructor. */ ExGiDirectXMetafile(); /** \details Virtual destructor. */ virtual ~ExGiDirectXMetafile(); /** \details Begins vectorization of this Metafile object. */ void begin(); /** \details Clear Metafile object. */ void clear(); /** \details Appends the specified record chain to the line segments cache of this Metafile object. \param pRecord [in] Pointer to the record chain. */ void appendLineSegsRecord(D3dRecord* pRecord) { m_pLineSegsTail->setTail(pRecord); m_pLineSegsTail = pRecord; } /** \details Appends the specified record chain to the no-light cache of this Metafile object. \param pRecord [in] Pointer to the record chain. */ void appendNoLightRecord(D3dRecord* pRecord) { m_pNoLightTail->setTail(pRecord); m_pNoLightTail = pRecord; } /** \details Appends the specified record chain to the light triangles cache of this Metafile object. \param pRecord [in] Pointer to the record chain. */ void prependLightRecord(D3dRecord* pRecord) { pRecord->setTail(m_lightCache.tail()); m_lightCache.setTail(pRecord); } /** \details Prepends the specified record chain to the light triangles cache of this Metafile object. \param pRecord [in] Pointer to the record chain. */ void appendLightRecord(D3dRecord *pRecord) { m_pLightTail->setTail(pRecord); m_pLightTail = pRecord; } void setLineSegArray(const OdD3DVertexColArray &vertices) { m_LineSegArray = vertices; m_LineSegArray.setPhysicalLength(vertices.size()); } OdD3DVertexColArray &getLineSegArray() { return m_LineSegArray; } const OdD3DVertexColArray &getLineSegArray() const { return m_LineSegArray; } void setNoLightTriArray(const OdD3DVertexColArray &vertices) { m_NoLightTriArray = vertices; m_NoLightTriArray.setPhysicalLength(vertices.size()); } OdD3DVertexColArray &getNoLightTriArray() { return m_NoLightTriArray; } const OdD3DVertexColArray &getNoLightTriArray() const { return m_NoLightTriArray; } void setLightTriArray(const OdD3DVertexNormalColArray &vertices) { m_LightTriArray = vertices; m_LightTriArray.setPhysicalLength(vertices.size()); } OdD3DVertexNormalColArray &getLightTriArray() { return m_LightTriArray; } const OdD3DVertexNormalColArray &getLightTriArray() const { return m_LightTriArray; } void setTexturedTriArray(const OdD3DVertexNormalTexColArray &vertices) { m_TexturedTriArray = vertices; m_TexturedTriArray.setPhysicalLength(vertices.size()); } OdD3DVertexNormalTexColArray &getTexturedTriArray() { return m_TexturedTriArray; } const OdD3DVertexNormalTexColArray &getTexturedTriArray() const { return m_TexturedTriArray; } void setSelMarksArray(const OdD3DSelMarkArray &selMarks) { m_SelMarks = selMarks; m_SelMarks.setPhysicalLength(selMarks.size()); } OdD3DSelMarkArray &getSelMarksArray() { return m_SelMarks; } const OdD3DSelMarkArray &getSelMarksArray() const { return m_SelMarks; } /** \details Renders this Metafile object. \param pContext [in] Pointer to the Play context. */ void play(D3dMetafilePlayContext& pContext) const; /** \details Caclulate metafile size. \param bExact [in] Calculate exact size if set, elsewhere return 0 if empty or 1 if data available. */ virtual OdUInt64 metafileSize(bool bExact) const; /** \details Play this Metafile into geometry conveyor \param pContext [in] Pointer to the Play context. */ void play4Select( D3dMetafilePlayContext& pContext, D3dPlay4SelectContext& ctx ) const; /** \details Ends vectorization of this Metafile object. \param pGeometry [in] Receives a pointer to the vectorized geometry. \remarks The default implementaion of this function does nothing. */ void end(ExGiDirectXGeometry* pGeometry); }; /** \details A data type that represents a smart pointer to an object. */ typedef OdSmartPtr ExGiDirectXMetafilePtr; /** \details Metafile packager. Initializes vertex arrays for all metafile types and manages metafile records creation. Library: Source code provided. */ class D3dMetafilePackager { public: /** \details Types of metafile arrays. */ enum ArrayType { kUnassignedArray = -1, // Array type is not assigned kLSArray = 0, // Line segments (1 step) kVCArray, // No-light triangles (2 step) kVNCArray, // Light triangles (3 step) kVNTCArray // Light triangles with textures (3 step) }; /** \details Special record types (not produceable by metafile packager). \remarks Each of them stops current packaging process (calls flush() internally). */ enum RecordType { kPointRec = 0, // Single point record kPolylineRec, // Independent stripped polyline record kLtpPolylineRec, // Polyline with template record kLwdPolylineRec, // Polyline with width record kTriangleRec, // Single triangle record kTriangleNormalRec, // Single triangle with normal record kTriangleNormalTexRec, // Single triangle with normal and texture coordinates record kInitTextureRec, // Initialize texture record (called before raster image triangles) kUninitTextureRec, // Uninitialize texture record (called after raster image triangles) kMaterialRec, // Material record kBeginHighlightingRec, // Begin highlighting record (called for selection mark of subentities) kEndHighlightingRec, // End highlighting record (called for end subentity selection mark) kSelectionMarkerRec, // Selection marker record kTransparencyRec, // Transparency level kLwdStyleRec, // Lineweight style kTtfTextRec, // TTF text kBeginNoColorModRec, // Begin "no color modification" mode. kSelectionModeRec, //Selection mode record kEndNoColorModRec, // End "no color modification" mode. kBeginHideRec, // Begin hiding record (called for selection mark of subentities) kEndHideRec // End hiding record (called for end subentity selection mark) }; /** \details Type of packaging primitive. */ enum PackPrimitive { kRecordPrim = -1, // Unassigned or record primitive (packaging skipped) kPointPrim = 0, // Points primitive kPolylinePrim, // Polylines primitive kTrianglePrim, // Triangles primitive kLwdPointPrim, // Points with lineweight kLwdPolylinePrim // Polylines with lineweight }; /** \details Packager entry type. \remarks Don't change entry identifiers - this is array indices. */ enum PackEntryType { kLSEntry = 0, // Line segment entry kNLEntry = 1, // No-light entry kLTEntry = 2, // Light&&Textured entry kLastPackEntry // Number of separated entry arrays }; public: // Constants /** Maximum vertices in polyline to add into array without stripping. Default: 12. 12 * 2 - 2 == 22pls, 10 verts added. */ static const OdInt32 MaxPolylineNoStrip; /** Default: 32. */ static const OdInt32 MaxPolylineNoStripPack; protected: bool m_bInitialized; // true between beginMetafile()/endMetafile() calls bool m_bDynamicSubEntHlt; // Dynamic subentities highlighting enabled bool m_bNestingMode; // Nested metafiles processing (reuse same registers) OdGsBaseVectorizer* m_pVectorizer; // Current render view IDirect3DDevice* m_d3dDevice; // Current D3D device ExGiDirectXMetafilePtr m_pMetafile; // Current recording metafile // SubEnts highlighting bool m_bControlHLT; // Enable subentities highlighting support bool m_bLastHLT; // Last highlighting state (summary for all entries) bool m_bControlHidden;// Enable subentities hiding support bool m_bLastHidden; // Last hidden state (summary for all entries) // Dynamic subentities highlighting OdGsMarker m_gsLastMarker; // Last highlighting marker (summary for all entries) // OdUInt8 m_transparency; // Current transparency level D3dLwdStyle m_lwdStyle; // Lineweight style bool m_bNoColorMod; // "no color modification" mode state OdUInt8 m_selectionFlag; // Selection flag struct PackEntry { ArrayType m_arrayType; // Type of packaging array PackPrimitive m_packPrimitive; // Type of currently pack primitive OdInt32 m_nInitialID; // Initial index for current packaging primitive OdInt32 m_nVertices; // Count of packed vertices for current primitive // Lineweights D3dLwdSetting m_lineWeight; // Current lineweight // SubEnts highlighting bool m_bLastHLTState; // Last highlight state in entry bool m_bLastHiddenState; //Last hidden state in entry // Dynamic SubEnts highlighting OdGsMarker m_gsPrevMarker; // Last selection marker in entry OdD3DSelMarkArray m_SelMarks; // Selection markers array // OdUInt8 m_transparency; // Last transparency level D3dLwdStyle m_lwdStyle; // Last lineweight style bool m_bNoColorMod; // "no color modification" mode OdUInt32 m_uMtfCount; // Count of metafiles, added to metafile entry OdUInt8 m_selectionFlag; // Last selection flag PackEntry() : m_arrayType(kUnassignedArray) , m_packPrimitive(kRecordPrim) , m_nInitialID(0) , m_nVertices(0) , m_bLastHLTState(false) , m_bLastHiddenState( false ) , m_gsPrevMarker(kNullSubentIndex) , m_uMtfCount(0) , m_selectionFlag( 0 ) { } } m_packEntry[kLastPackEntry]; OdD3DVertexColArray m_LSArray; // Array of line segments vertices. OdD3DVertexColArray m_VCArray; // Array of no-light vertices. OdD3DVertexNormalColArray m_VNCArray; // Vertices with normals. OdD3DVertexNormalTexColArray m_VNTCArray; // Vertices with normals and texture coordinates. ExGsDelayedMappingEntry *m_pCurDelMapEntry; // Current entry for delayed mapping. public: /** \details Default constructor. */ D3dMetafilePackager(); /** \details Destructor. */ ~D3dMetafilePackager(); /** \details Starts packaging for specified metafile. \param renderMode [in] Metafile render mode. \param d3dDevice [in] Pointer to IDirect3DDevice. \param pMetafile [in] Pointer to active metafile. */ void beginMetafile(OdGsBaseVectorizer* pVectorizer, IDirect3DDevice *d3dDevice, ExGiDirectXMetafilePtr pMetafile); /** \details End packaging for specified metafile. */ void endMetafile(); /** \details Returns currently processing metafile. */ ExGiDirectXMetafilePtr &metafile() { return m_pMetafile; } const ExGiDirectXMetafilePtr &metafile() const { return m_pMetafile; } /** \details Starts nested metafiles packaging mode. */ void runNestingMode(); /** \details Ends nested metafiles packaging mode. */ void stopNestingMode(); /** \details Checks does nested metafiles packaging mode enabled. */ bool isNestingMode() const { return m_bNestingMode; } /** \details Manual data flush (called automaticly in addRecord() and endMetafile()). \param entryType [in] Specifies entry to be flushed. */ void flush(PackEntryType entryType); /** \details Add's new record to metafile entry. \param entryType [in] Entry type for which specified record will be added. \param recType [in] Specifies record type. \param pRecord [in] Pointer to newly created metafile record. */ void addRecord(PackEntryType entryType, RecordType recType, D3dRecord* pRecord); /** \details Pack point into specified metafile entry. \param entryType [in] Metafile entry type. \param pos [in] Point position. \param color [in] Point color. \remarks entryType can be only kLSEntry or kNLEntry. */ void addPoint(PackEntryType entryType, const OdGePoint3d& pos, DWORD color); /** \details Pack polyline into specified metafile entry. \param entryType [in] Metafile entry type. \param nPoint [in] Count of points into points array. \param points [in] Pointer to polyline points array. \param color [in] Polyline color for all points. \remarks entryType can be only kLSEntry or kNLEntry. */ void addPolyline(PackEntryType entryType, OdInt32 nPoints, const OdGePoint3d* points, DWORD color); /** \details Packs a triangle into metafile. \param pVertices [in] Pointer to three triangle vertices. \remarks Entry type depends on pVertices type. */ void addTriangle(const OdD3DVertexCol *pVertices); /** \details Packs a triangle into metafile. \param bTwoSidesMode [in] If true, two sides mode is enabled (add's one additional triangle in opposite vertices order). \param pVertices [in] Pointer to three triangle vertices. \remarks Entry type depend from pVertices type. */ void addTriangle(bool bTwoSidesMode, const OdD3DVertexNormalCol *pVertices); /** \details Pack triangle into metafile. \param bTwoSidesMode [in] If true, two sides mode is enabled (add's one additional triangle in opposite vertices order). \param pVertices [in] Pointer to three triangle vertices. \remarks Entry type depend from pVertices type. */ void addTriangle(bool bTwoSidesMode, const OdD3DVertexNormalTexCol *pVertices); /** \details Pack polyline with lineweight into specified metafile entry. \param entryType [in] Metafile entry type. \param bPoint [in] Flag that specifies whether points with lineweight are packed. If false, polylines with lineweight are packed. \param nPoints [in] Count of points into points array. \param points [in] Pointer to polyline points array. \param color [in] Polyline color for all points. \param lineWeight [in] Lineweight settings. \remarks entryType can be only kLSEntry or kNLEntry. */ void addLwdPolyline(PackEntryType entryType, bool bPoint, OdInt32 nPoints, const OdGePoint3d* points, DWORD color, const D3dLwdSetting &lineWeight); /** \details Returns current highlight state for specified metafile entry type. \param entryType [in] Metafile entry type. */ bool curHLTState(PackEntryType entryType) const; /** \details Returns current hidden state for specified metafile entry type. \param entryType [in] Metafile entry type. */ bool curHiddenState(PackEntryType entryType) const; /** \details Returns current selection marker specified metafile entry type. \param entryType [in] Metafile entry type. */ OdGsMarker curSelectionMarker(PackEntryType entryType) const; /** \details Resets current value of transparency level. \param alpha [in] Inverted opacity (transparency). */ inline void setTransparency(OdUInt8 alpha) { m_transparency = alpha; } /** \details Resets current value of selection flag. \param flag [in] Selection flag. */ inline void setSelectionFlag( OdUInt8 flag ) { m_selectionFlag = flag; } /** \details Resets current lineweight style. \param bUseDef [in] Use default style. \param lesStyle [in] Line end style. \param ljsStyle [in] Line join style. */ inline void setLwdStyle(bool bUseDef, OdPs::LineEndStyle lesStyle = OdPs::kLesRound, OdPs::LineJoinStyle ljsStyle = OdPs::kLjsRound) { m_lwdStyle.m_bCurLwdUsesDef = bUseDef; m_lwdStyle.m_curLwdLes = lesStyle; m_lwdStyle.m_curLwdLjs = ljsStyle; } /** \details Resets "no color modification" mode. \param bState [in] New state for "no color modification" mode. */ inline void setNoColorMod(bool bState) { m_bNoColorMod = bState; } /** \details Returns true if specified entry is a last entry with data into entries array. \param entryType [in] Metafile entry type. */ bool isLastDataEntry(PackEntryType entryType) const; /** \details Returns last entry type with data into entries array. \param entryType [out] Metafile entry type. */ bool lastDataEntry(PackEntryType &entryType) const; /** \details Returns OdGsBaseVectorizeView for current metafile. */ const OdGsBaseVectorizer *metafileVectorizer() const; /** \details Starts delay cache entry construction. \param pEntry [in] Delay cache entry. */ void startDelayMapping(void *pEntry); /** \details Add's triangle to delay mapping cache entry. \param bTwoSidesMode [in] true if two sides mode enabled (add's one additional triangle in opposite vertices order). */ void addTriangleToDelayMapping(bool bTwoSidesMode); /** \details Stops delay cache entry construction. */ void flushDelayMapping(); inline OdD3DVertexColArray &getLSArray() { return m_LSArray; } inline OdD3DVertexColArray &getVCArray() { return m_VCArray; } inline OdD3DVertexNormalColArray &getVNCArray() { return m_VNCArray; } inline OdD3DVertexNormalTexColArray &getVNTCArray() { return m_VNTCArray; } inline const OdD3DVertexColArray &getLSArray() const { return m_LSArray; } inline const OdD3DVertexColArray &getVCArray() const { return m_VCArray; } inline const OdD3DVertexNormalColArray &getVNCArray() const { return m_VNCArray; } inline const OdD3DVertexNormalTexColArray &getVNTCArray() const { return m_VNTCArray; } /** \details Returns true after beginMetafile() call, and before endMetafile(). */ bool isInitialized() const; #ifdef DEBUG // Statistical information struct Stats { OdUInt32 m_nLSVertices; OdUInt32 m_nVCVertices; OdUInt32 m_nVNCVertices; OdUInt32 m_nVNTCVertices; OdUInt32 m_nLSMetafiles; OdUInt32 m_nNLMetafiles; OdUInt32 m_nLTMetafiles; }; Stats statInfo() const; #endif /** \details Enable dynamic sub-entities highlighting. \param bSet [in] New flag. */ void enableDynamicSubEntHlt(bool bSet) { m_bDynamicSubEntHlt = bSet; } /** \details Setups appropriate array parameters for current rendering options. \param b4Cache [in] Enables arrays setup for cache. */ void setupArrays(bool b4Cache); protected: void clear(); void testHLTState(PackEntryType entryType); }; /** \details This class provides tessellation functionality for the ODA vectorization framework Library: Source code provided. */ class ExGiDirectXGeometry : public OdGiGeometrySimplifier , public OdRxObject { bool m_bIsVertsNormals; bool m_bIsFaceNormals; bool m_bIsVertsColors; bool m_bFaceNormalsRequired; DWORD m_bgColor; bool m_bDoubleBufferEnabled; bool m_bTwoSidesMode; bool m_bShmClipped; bool m_bPlineProc; DWORD m_color; int m_pixLineWeight; D3dLwdSetting m_lineWeight; OdPs::LineType m_linetype; CComPtr m_pD3Ddevice; OdD3DStateManager* m_pD3DSM; const ODCOLORREF* m_paletteColors; OdUInt16 m_numPaletteColors; enum { eNotInit = 0, eMaterialWay = 1, eNotMaterialWay = 2 } m_MaterialWay; CComPtr d3dDevice(); OdD3DStateManager &d3dStateManager(); ExGiDirectXMetafilePtr m_pMetafile; D3dMetafilePlayContext m_mfPlayCtx; D3dMetafilePackager m_rPackager; void prepareShMFacesGeneration(const OdGiFaceData* pFaceData); const OdGiPsLinetypes::PsLinetypeOGL *m_psLinetypeDefs; OdGiMaterialItemPtr m_pIntMtl; // Material rendering optimization D3dMaterialViewRedirect *m_pMViewRedirect; public: /** \details Default constructor for the ExGiDirectXGeometry class. */ ExGiDirectXGeometry(); /** \details Destructor for the ExGiDirectXGeometry class. */ virtual ~ExGiDirectXGeometry(); bool m_bProcessingTTF; bool m_bShadingDisabled; bool m_bPlayMetafile; ODRX_DECLARE_MEMBERS(ExGiDirectXGeometry); /** \details Creates a new GsMetafile (cache) object. \remarks Returns a SmartPointer to the newly created object. */ OdRxObjectPtr newGsMetafile(); /** \details Begins vectorization to the specified GsMetafile (cache) object. \param pMetafile [in] Pointer to the metafile. */ void beginMetafile(OdRxObject* pMetafile, OdGsBaseVectorizer *pVectorizer); /** \details Ends vectorization to the specified GsMetafile (cache) object. \param pMetafile [in] Pointer to the metafile. \param uMetafileSize [in] Reference to the storage for metafile size. \param bExactSize [in] If true, if exact metafile size need to be calculated, otherwise 1 is set if metafile is not empty. */ void endMetafile(OdRxObject* pMetafile, OdUInt64 &uMetafileSize, bool bExactSize = false); /** \details Plays (draws) the specified Metafile (cache) object. \param pMetafile [in] Pointer to the metafile. \param hltPass [in] Current highlighting pass. */ void playMetafile(const OdRxObject* pMetafile, int hltPass = 0); /** \details Plays (draws) the specified Metafile (cache) object for Select or Extent */ void play4Select(const OdRxObject* pMetafile, D3dPlay4SelectContext& context );// OdGiConveyorGeometry *pGeom, OdGiConveyorContext *pCtx, bool bCheckMark = true); /** \details Clears Metafile (cache) object. \param pMetafile [in] Pointer to the metafile. */ void clearMetafile(OdRxObject* pMetafile); /** \details Causes the data from the back buffer to appear on the front buffer. */ void present(); // graphics data // required by simplifier /** \details Outputs a polyline. \param numPoints [in] Number of points in the polyline. \param vertexList [in] Array of vertices that make up the polyline. \sa */ void polylineOut(OdInt32 numPoints, const OdGePoint3d* points); /** \details Outputs a triangle. \param vertices [in] List of 3 numbers that define the vertices in the triangle. \param pNormal [in] Normal vector for this triangle. */ void triangleOut( const OdInt32* vertices, const OdGeVector3d* pNormal ); /** \details Processes shell data. \param numVertices [in] Number of vertices. \param vertexList [in] Array of vertices. \param faceListSize [in] Number of entries in faceList. \param faceList [in] Array of numbers that define the faces. \param pEdgeData [in] Pointer to additional edge data. \param pFaceData [in] Pointer to additional face data. \param pVertexData [in] Pointer to additional vertex data. \sa */ void shellProc(OdInt32 nbVertex, const OdGePoint3d* pVertexList, OdInt32 faceListSize, const OdInt32* pFaceList, const OdGiEdgeData* pEdgeData, const OdGiFaceData* pFaceData, const OdGiVertexData* pVertexData); /** \details Tessellates a filled wireframe shell. \param faceListSize [in] Number of entries in faceList. \param faceList [in] List of numbers that define the faces in the shell. \param pEdgeData [in] Pointer to additional edge data. \param pFaceData [in] Pointer to additional face data. */ void generateShellFaces(OdInt32 faceListSize, const OdInt32* faceList, const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0); /** \details Tessellates a filled mesh. \param numRows [in] Number of rows in the mesh. \param numColumns [in] Number of columns in the mesh. \param pFaceData [in] Pointer to additional face data. */ void generateMeshFaces(OdInt32 rows, OdInt32 columns, const OdGiFaceData* pFaceData); /** \details Outputs a face of a tessilated mesh. \param faceList [in] Array of numbers that define the face. \param pNormal [in] Pointer to the normal to the face. */ void meshFaceOut(const OdInt32* faceList, const OdGeVector3d* pNormal); /** \details Outputs the face of a tessellated shell. \param faceListSize [in] Number of entries in faceList. \param faceList [in] List of numbers that define the face. \param pNormal [in] Normal vector for this face. */ void shellFaceOut(OdInt32 faceListSize, const OdInt32* faceList, const OdGeVector3d* pNormal); /** \details Tessellates a wireframe. \param faceListSize [in] Number of entries in faceList. Used when bPline = false. \param pFaceList [in] List of numbers that define the faces in the shell. Used when bPline = false. \param pEdgeData [in] Pointer to additional edge data. Used when bPline = false. \param pFaceData [in] Pointer to additional face data. Used when bPline = false. */ void generateThinWires(OdInt32 faceListSize = 0, const OdInt32 *pFaceList = NULL, const OdGiEdgeData *pEdgeData = NULL, const OdGiFaceData *pFaceData = NULL); /** \details Initializes a texture map. \param origin [in] Lower-left corner. \param u [in] Image width vector. \param v [in] Image height vector. \param pImage [in] Pointer to the RasterImage object. \param transparency [in] If true, image transparency is on. \param brightness [in] Image brightness [0.0 .. 100.0]. \param contrast [in] Image contrast [0.0 .. 100.0]. \param fade [in] Image fade value [0.0 .. 100.0]. */ void initTexture(const OdGePoint3d& origin, const OdGeVector3d& u, const OdGeVector3d& v, const OdGiRasterImage* pImage, bool transparency, double brightness, double contrast, double fade); /** \details Releases a texture map. */ void uninitTexture(); /** \details Processes text data. \param position [in] Position of the text. \param u [in] U parameter of the text. \param v [in] V parameter of the text. \param msg [in] Message string. \param nLength [in] Message length. \param raw [in] Flag that specifies whether escape sequences, such as %%P, are not converted to special characters. \param pTextStyle [in] Pointer to a text style. \param pExtrusion [in] Extrusion vector. \sa */ void textProc(const OdGePoint3d& position, const OdGeVector3d& u, const OdGeVector3d& v, const OdChar* msg, OdInt32 nLength, bool raw, const OdGiTextStyle* pStyle, const OdGeVector3d* pExtrusion); /** \details Processes polypoint data. \param numPoints [in] Number of points. \param vertexList [in] Pointer to an array of vertices. \param pColors [in] Pointer to point colors. \param pTransparency [in] Pointer to point transparency. \param pNormals [in] Array of normal vectors. \param pSubEntMarkers [in] Array of vectors that defines extrusions. \param nPointSize [in] Points size. */ void polypointProc(OdInt32 numPoints, const OdGePoint3d* vertexList, const OdCmEntityColor* pColors, const OdCmTransparency* pTransparency = 0, const OdGeVector3d* pNormals = 0, const OdGeVector3d* pExtrusions = 0, const OdGsMarker* pSubEntMarkers = 0, OdInt32 nPointSize = 0); /** \details Returns the DirectX color corresponding to the specified color. \param color [in] Color. */ DWORD getD3DColor(const OdCmEntityColor& color); /** \details Returns the DirectX color corresponding to the specified color. \param color [in] Color. */ static DWORD getD3DColor(ODCOLORREF color); static ODCOLORREF getGDIColor(DWORD color); /** \details Sets the logical palette to be used by this Geometry object. \param logicalPalette [in] Logical palette. \param numColors [in] Number of colors in palette. */ void setLogicalPalette(const ODCOLORREF* logicalPalette, OdUInt16 numColors); // traits /** \details Sets the draw color for this Geometry object. \param color [in] Color. */ void draw_color(DWORD color); /** \details Sets the draw lineweight for this Geometry object. \param lwLineWeight [in] Lineweight as enum. \param iLineWeight [in] Lineweight in pixels. */ void draw_lineweight(OdDb::LineWeight lwLineWeight, int iLineWeight); /** \details Sets the draw lineweight for this Geometry object. \param dLineWeight [in] Plot styles lineweight. \param iLineWeight [in] Lineweight in pixels. */ void draw_lineweight(double dLineWeight, int iLineWeight); /** \details Sets the draw lineweight for this Geometry object. \param dLineWeight [in] Lineweight in geometry coordinates system. \param iLineWeight [in] Lineweight in pixels. */ void draw_lineweightOverride(double dLineWeight, int iLineWeight); /** \details Sets the draw fillstyle for this Geometry object. \param fillStyle [in] Fillstyle. */ void draw_fillStyle(OdPs::FillStyle fillStyle); /** \details Sets the draw linetype for this Geometry object. \param lineType [in] Linetype. \param isAdaptive [in] Controls if linetype is adaptive. \param linePatSize [in] Line pattern size. */ void draw_linetype(OdPs::LineType lineType, bool isAdaptive, double linePatSize); /** \details Sets the draw transparency for this Geometry object. \param alpha [in] Transparency level. */ void draw_transparency(OdUInt8 alpha); /** \details Sets the draw line style for this Geometry object. \param bUseDef [in] Use default lineweight style. \param lesStyle [in] Line end style. \param ljsStyle [in] Line join style. */ void draw_lineStyle(bool bUseDef, OdPs::LineEndStyle lesStyle = OdPs::kLesRound, OdPs::LineJoinStyle ljsStyle = OdPs::kLjsRound); /** \details Sets "no color modification" mode for this Geometry object. \param bSet [in] Enable "no color modification" mode. */ void draw_noColorMod(bool bSet); /** \details Controls the TwoSidesMode flag for this Geometry object. \param twoSidesMode [in] Controls flag. */ void setTwoSidesMode(bool twoSidesMode); /** \details Returns the TwoSidesMode flag from this Geometry object. \return True in case if TwoSideMode enabled or false otherwise. */ bool twoSidesMode() const { return m_bTwoSidesMode; } /** \details Sets ShmClipped flag for this Geometry object. \param shmClipped [in] New state for ShmClipped flag. */ void setShmClipped(bool shmClipped) { m_bShmClipped = shmClipped; } /** \details Sets PlineProc flag for this Geometry object. \param bPlineProc [in] New state for PlineProc flag. */ void setPlineProc(bool bPlineProc) { m_bPlineProc = bPlineProc; } /** \details Controls the DoubleBufferEnabled flag for this Geometry object. \param doubleBufferEnabled [in] Controls flag. */ void setDoubleBufferEnabled(bool doubleBufferEnabled); /** \details Sets the D3DDevice for this Geometry object. \param pD3Ddevice [in] Pointer to the D3Ddevice. */ void setD3DDevice(IDirect3DDevice* pD3Ddevice); /** \details Sets the D3D device state manager for this Geometry object. \param pD3DSM [in] Pointer to the D3D device state manager. */ void setD3DStateManager(OdD3DStateManager* pD3DSM); // for internal use only /** \details Sets the vectorizer for this Geometry object. \param pView [in] Pointer to the vectorizer. \remarks This function is for internal use only. */ void setVectorizer(OdGsBaseVectorizer* pView); /** \details Sets vectorizer interface for material/mapper functionality. \param pMViewRedirect [in] Pointer to D3dMaterialViewRedirect interface. \param pView [in] Optional pointer to the vectorizer */ void setMaterialViewRedirect(D3dMaterialViewRedirect *pMViewRedirect, OdGsBaseVectorizer* pView = NULL); /** \details Sets array parameters optimized for rendering state. \param b4Cache [in] Enables optimized parameters for cache. */ void setupIntermediateArrays(bool b4Cache); /** \details Sets the ForceFill flag for this Geometry object. \param forceFill [in] Controls flag. */ void setForceFill(bool forceFill) { m_mfPlayCtx.setForceFill(forceFill); } /** \details Sets the draw visual style for this Geometry object. \param visualStyle [in] Visual style. \remarks This function is not implemented currently. */ void draw_visualStyle(const OdGiVisualStyle &visualStyle); // Materials support /** \details Checks whether the specifed material needs to be skipped. \param materialId [in] Material identifier. \returns true if material needs to be skipped, false otherwise. */ bool skipMaterialProcess(OdDbStub *materialId); /** \details Initializes/reinitializes material cache. \param prevCache [in] Previous cache, if available. \param materialId [in] Material identifier. \param materialData [in] Current material traits. \returns Smart pointer to the material item. */ OdGiMaterialItemPtr fillMaterialCache(OdGiMaterialItemPtr prevCache, OdDbStub *materialId, const OdGiMaterialTraitsData &materialData); /** \details Renders material cache. \param prevCache [in] Material cache. \param materialId [in] Material identifier. */ void renderMaterial(OdGiMaterialItemPtr pCache, OdDbStub *materialId); /** \details This method is called by delay cache entry as default handler. \param pEntry [in] Pointer to the caller entry. */ void playDelayCacheEntry(const void *pEntry); /** \details Links cache markers with texture coordinates which must be recalculated after extents are calculated. */ void mapperChangedForDelayCache(); /** \details Returns current material item. \returns Smart pointer to the material item. */ OdGiMaterialItemPtr currentMaterial() const; /** \details Resets current material. \param pMaterial [in] Smart pointer to the material item to set. */ void resetCurrentMaterial(OdGiMaterialItemPtr pMaterial); /** \details Checks whether material is enabled. \returns true if material is enabled, false otherwise. */ bool isMaterialEnabled() const; /** \details Checks whether material is available. \returns true if material is available, false otherwise. */ bool isMaterialAvailable() const; /** \details Resets current material. */ void resetCurrentMaterial(); /** \details Returns current material mapper item. \param bForCoords [in] If true, mapper item is used for texture coordinates calculations. \returns Smart pointer to the current mapper item. */ OdGiMapperItemPtr currentMapper(bool bForCoords = true) const; /** \details Resets current mapper. \param pMapper [in] Smart pointer to the mapper item to set. */ void resetCurrentMapper(OdGiMapperItemPtr pMapper); /** \details Checks whether mapper is enabled. \returns true if mapper is enabled, false otherwise. */ bool isMapperEnabled() const; /** \details Checks whether mapper is available. \returns true if mapper is available, false otherwise. */ bool isMapperAvailable() const; bool isMappingDelayed() const; void appendDelayCacheEntry(void *pEntry); OdGiMaterialTextureManager *materialTextureManager(); void d3dSelectionFlags(OdUInt8 selFlags); }; /** \details A data type that represents a smart pointer to an object. */ typedef OdSmartPtr ExGiDirectXGeometryPtr; #include "TD_PackPop.h" #endif // __OD_EX_GI_DIRECT_X_GEOMETRY__