/////////////////////////////////////////////////////////////////////////////// // 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 _EXGIGDIVIEWPORTCLIPPER_H_INCLUDED_ #define _EXGIGDIVIEWPORTCLIPPER_H_INCLUDED_ #include "TD_PackPush.h" #define GDI_USE_ENHANCED_CLIPPER #ifndef GDI_USE_ENHANCED_CLIPPER #include "Gs/GsExtAccum.h" #include "Gi/GiOrthoPrismIntersector.h" #include "Gi/GiConveyorEntryPoint.h" #else // GDI_USE_ENHANCED_CLIPPER #include "Gi/GiOrthoClipperEx.h" #endif // GDI_USE_ENHANCED_CLIPPER #ifndef GDI_USE_ENHANCED_CLIPPER /** \details This class implements Viewport Clipping entry for GDI Vectorizer Device objects. */ class OdGiGDIViewportClippingEntry : public OdGiConveyorNode, public OdGsConveyorNodeBase, public OdGiConveyorGeometry { OdGiOrthoPrismIntersectorPtr m_pClipper; OdGiConveyorEntryPoint m_clipperEntryPoint; OdGiConveyorContext *m_pDrawContext; protected: OdGiGDIViewportClippingEntry(); public: /** \details Creates an instance of the OdGiGDIViewportClippingEntry class. */ static OdSmartPtr createObject(); /** \details Returns optional geometry. \returns Pointer to optional geometry. */ OdGiConveyorGeometry* optionalGeometry(); /** \details Sets a clipping region. \param points [in] Array of points. \param pointCounts [in] Number of points in the array. \param numPolygons [in] Number of polygons. Not used. */ void set(const OdGsDCPoint* points, const int *pointCounts, int numPolygons); /** \details Sets a clipping region. \param min [in] Minimum point. \param max [in] Maximum point. */ void set(const OdGsDCPoint& min, const OdGsDCPoint& max); /** \details Sets the draw context object (to access traits, etc). \param pDrawContext [in] Pointer to the draw context. */ void setDrawContext(OdGiConveyorContext* pDrawContext); /** \details Returns the OdGiConveyorGeometry object associated with this object. \returns a reference to the OdGiConveyorGeometry instance. \remarks This instance contains the functions that can be used by an entity to vectorize itself. */ OdGiConveyorGeometry& geometry(); /** \details Sets max deviation for curve tessellation. \param deviations [in] Array with deviation values. */ void setDeviation(const OdGeDoubleArray& deviations); /** \details Sets deviation object to obtain max deviation for curve tessellation. \param pDeviation [in] Pointer to the deviation object. */ void setDeviation(const OdGiDeviation* pDeviation); // OdGiConveyorNode methods /** \details Returns an input node of the clipper. \returns Reference to the input node of the clipper. */ virtual OdGiConveyorInput& input(); /** \details Returns an output node of the clipper. \returns Reference to the output node of the clipper. */ virtual OdGiConveyorOutput& output(); // OdGiConveyorGeometry functions /** \details Processes OdGiPolyline data. \param polyline [in] Polyline data to be processed. \param pXfm [in] Pointer to a transformation matrix. \param fromIndex [in] Index of the first segment to be processed. \param numSegs [in] Number of segments to be processed. \remarks numSegs == 0 indicates all segments starting at fromIndex are to be processed. \sa */ virtual void plineProc(const OdGiPolyline& polyline, const OdGeMatrix3d* pXfm = 0, OdUInt32 fromIndex = 0, OdUInt32 numSegs = 0); /** \details Processes simple polyline data. \param numPoints [in] Number of points. \param vertexList [in] Array of vertices. \param pNormal [in] Pointer to the normal vector. \param pExtrusion [in] Pointer to the extrusion vector. \param baseSubEntMarker [in] Currently unused. \remarks The extrusion vector specifies the direction and distance of the extrusion. \sa */ virtual void polylineProc(OdInt32 numPoints, const OdGePoint3d* vertexList, const OdGeVector3d* pNormal = 0, const OdGeVector3d* pExtrusion = 0, OdGsMarker baseSubEntMarker = -1); /** \details Processes polygon data. \param numPoints [in] Number of points. \param vertexList [in] Array of vertices. \param pNormal [in] Pointer to the normal vector. \param pExtrusion [in] Pointer to the extrusion vector. \remarks The extrusion vector specifies the direction and distance of the extrusion. \sa */ virtual void polygonProc(OdInt32 numPoints, const OdGePoint3d* vertexList, const OdGeVector3d* pNormal = 0, const OdGeVector3d* pExtrusion = 0); /** \details Processes Xline data. \param firstPoint [in] First point. \param secondPoint [in] Second point. \remarks An Xline is an infinite line passing through the specified points. \sa */ virtual void xlineProc(const OdGePoint3d& firstPoint, const OdGePoint3d& secondPoint); /** \details Processes Ray data. \param basePoint [in] Base point. \param throughPoint [in] Through point. \remarks A Ray is a semi-infinite line that starts at the basePoint, and passes through the throughPoint. \sa */ virtual void rayProc(const OdGePoint3d& basePoint, const OdGePoint3d& throughPoint); /** \details Processes mesh data. \param numRows [in] Number of rows. \param numColumns [in] Number of columns. \param vertexList [in] Array of vertices. \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 */ virtual void meshProc(OdInt32 numRows, OdInt32 numColumns, const OdGePoint3d* vertexList, const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0); /** \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 */ virtual void shellProc(OdInt32 numVertices, const OdGePoint3d* vertexList, OdInt32 faceListSize, const OdInt32* faceList, const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0); /** \details Process circle data. \param center [in] Center point. \param radius [in] Radius. \param normal [in] Normal vector. \param pExtrusion [in] Pointer to the extrusion vector. \remarks The extrusion vector specifies the direction and distance of the extrusion. \sa */ virtual void circleProc(const OdGePoint3d& center, double radius, const OdGeVector3d& normal, const OdGeVector3d* pExtrusion = 0); /** \details Process circle data. \param firstPoint [in] First point of a 3-point circle. \param secondPoint [in] Second point of a 3-point circle. \param thirdPoint [in] Third point of a 3-point circle. \param pExtrusion [in] Pointer to the extrusion vector. \remarks If firstPoint, secondPoint, and thirdPoint are specified, they cannot be colinear and no two can be coincident. \sa */ virtual void circleProc(const OdGePoint3d& firstPoint, const OdGePoint3d& secondPoint, const OdGePoint3d& thirdPoint, const OdGeVector3d* pExtrusion = 0); /** \details Processes circular arc data. \param center [in] Center point. \param radius [in] Radius. \param normal [in] Normal vector. \param startVector [in] Defines the start of this arc. \param sweepAngle [in] Angle that defines the arc. \param arcType [in] Arc type. \param pExtrusion [in] Pointer to the extrusion vector. \remarks arcType must be one of the following: NameValueDescription kOdGiArcSimple 0 Unfilled kOdGiArcSector 1 Filled area bounded by the arc and its center kOdGiArcChord 2 Filled area bounded by the arc and its end points
The extrusion vector specifies the direction and distance of the extrusion. \remarks All angles are expressed in radians. \sa */ virtual void circularArcProc(const OdGePoint3d& center, double radius, const OdGeVector3d& normal, const OdGeVector3d& startVector, double sweepAngle, OdGiArcType arcType = kOdGiArcSimple, const OdGeVector3d* pExtrusion = 0); /** \details Processes circular arc data. \param firstPoint [in] First point of a 3-point arc. \param secondPoint [in] Second point of a 3-point arc. \param thirdPoint [in] Third point of a 3-point arc. \param arcType [in] Arc type. \param pExtrusion [in] Pointer to the extrusion vector. \remarks If firstPoint, secondPoint, and thirdPoint are specified, they cannot be colinear and no two can be coincident. \sa */ virtual void circularArcProc(const OdGePoint3d& firstPoint, const OdGePoint3d& secondPoint, const OdGePoint3d& thirdPoint, OdGiArcType arcType = kOdGiArcSimple, const OdGeVector3d* pExtrusion = 0); /** \details Processes OdGeEllipArc3d data. \param ellipArc [in] Elliptical arc. \param endPointOverrides [in] Array of points to be used as the first and last points of the vectorized arc. \param arcType [in] Arc type. \param pExtrusion [in] Pointer to the extrusion vector. \remarks arcType must be one of the following: NameValueDescription kOdGiArcSimple 0 Unfilled kOdGiArcSector 1 Filled area bounded by the arc and its center kOdGiArcChord 2 Filled area bounded by the arc and its end points
The extrusion vector specifies the direction and distance of the extrusion. \sa */ virtual void ellipArcProc(const OdGeEllipArc3d& ellipArc, const OdGePoint3d* endPointOverrides = 0, OdGiArcType arcType = kOdGiArcSimple, const OdGeVector3d* pExtrusion = 0); /** \details Processes OdGeNurbCurve3d data. \param nurbsCurve [in] NURBS curve data. \sa */ virtual void nurbsProc(const OdGeNurbCurve3d& nurbsCurve); /** \details Processes text data. \param position [in] Position of the text. \param direction [in] Baseline direction of the text. \param upVector [in] Up vector for the text. \param msg [in] Text string. \param numBytes [in] Number of bytes in msg. \param raw [in] If and only if true, escape sequences, such as %%P, are not converted to special characters. \param pTextStyle [in] Pointer to the TextStyle for the text. \param pExtrusion [in] Pointer to the extrusion vector. \remarks The extrusion vector specifies the direction and distance of the extrusion. \sa */ virtual void textProc(const OdGePoint3d& position, const OdGeVector3d& direction, const OdGeVector3d& upVector, const OdChar* msg, OdInt32 numBytes, bool raw, const OdGiTextStyle* pTextStyle, const OdGeVector3d* pExtrusion = 0); /** \details Processes text data. \param position [in] Position of the text. \param direction [in] Baseline direction of the text. \param upVector [in] Up vector for the text. \param msg [in] Text string. \param numBytes [in] Number of bytes in msg. \param raw [in] Flag that specifies whether escape sequences, such as %%P, are not converted to special characters. \param pTextStyle [in] Pointer to the TextStyle for the text. \param pExtrusion [in] Pointer to the extrusion vector. \remarks The extrusion vector specifies the direction and distance of the extrusion. \sa */ virtual void textProc2(const OdGePoint3d& position, const OdGeVector3d& direction, const OdGeVector3d& upVector, const OdChar* msg, OdInt32 numBytes, bool raw, const OdGiTextStyle* pTextStyle, const OdGeVector3d* pExtrusion = 0, const OdGeExtents3d* extentsBox = 0); /** \details Processes shape data. \param position [in] Position of the shape. \param direction [in] Baseline direction of the shape. \param upVector [in] Up vector for the shape. \param shapeNumber [in] Shape number. \param pTextStyle [in] Pointer to the TextStyle for the shape. \param pExtrusion [in] Pointer to the extrusion vector. \remarks The extrusion vector specifies the direction and distance of the extrusion. */ virtual void shapeProc(const OdGePoint3d& position, const OdGeVector3d& direction, const OdGeVector3d& upVector, int shapeNumber, const OdGiTextStyle* pTextStyle, const OdGeVector3d* pExtrusion = 0); /** \details Processes raster images data. \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 uvBoundary [in] Array of image boundary points (may not be null). \param numBoundPts [in] Number of boundary points. \param transparency [in] True if and only if 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]. \sa */ virtual void rasterImageProc(const OdGePoint3d& origin, const OdGeVector3d& u, const OdGeVector3d& v, const OdGiRasterImage* pImage, const OdGePoint2d* uvBoundary, OdUInt32 numBoundPts, bool transparency = false, double brightness = 50.0, double contrast = 50.0, double fade = 0.0); /** \details Processes metafile data. \param origin [in] Metafile origin. \param u [in] Metafile width vector. \param v [in] Metafile height vector. \param pMetafile [in] Pointer to the metafile object. \param dcAligned [in] Reserved. \param allowClipping [in] Reserved. */ virtual void metafileProc(const OdGePoint3d& origin, const OdGeVector3d& u, const OdGeVector3d& v, const OdGiMetafile* pMetafile, bool dcAligned = true, bool allowClipping = false); /** \details Processes xline data. \param basePoint [in] Base point. \param direction [in] Direction vector. \remarks An Xline is an infinite line passing through the specified point at the specified direction. */ virtual void xlineProc2(const OdGePoint3d& basePoint, const OdGeVector3d& direction); /** \details Processes ray data. \param basePoint [in] Base point. \param direction [in] Through point. \remarks A ray is a semi-infinite line that starts at the base point, and oriented towards the specified direction. \sa */ virtual void rayProc2(const OdGePoint3d& basePoint, const OdGeVector3d& direction); virtual void setExtentsProc(const OdGePoint3d *pPoints, bool bTransform = true); /** \details Retrieves TrueType fonts character processing flags. \returns TrueType fonts character processing flags as integer value. */ virtual int ttfCharProcFlags() const; /** \details Processes a character with TTF font. \param character [in] Character to process. \param position [in] Character position. \param pBoundBlock [in] Pointer to a bounding block representing character extents. */ virtual bool ttfCharProc(OdChar character, const OdGePoint3d& position, const OdGeBoundBlock3d* pBoundBlock); /** \details Processes TrueType font characters in dynamic polyDraw mode which is similar to shellProc() method, except here additional information about bezier data is passed for processing. \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 pBezierTypes [in] Bezier types. \param pFaceData [in] Pointer to additional face data. */ virtual void ttfPolyDrawProc(OdInt32 numVertices, const OdGePoint3d* vertexList, OdInt32 faceListSize, const OdInt32* faceList, const OdUInt8* pBezierTypes, const OdGiFaceData* pFaceData = 0); virtual void conveyorBoundaryInfoProc(const OdGeBoundBlock3d &boundBlock, OdUInt32 &outputFlags); /** \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 pExtrusions [in] Array of vectors defining extrusions. \param pSubEntMarkers [in] Array of sub-entity markers. \param nPointSize [in] Points size. */ virtual 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 Processes a row of points. \param numPoints [in] Number of points. \param startPoint [in] First point to draw. \param dirToNextPoint [in] Offset to next point. */ virtual void rowOfDotsProc(OdInt32 numPoints, const OdGePoint3d& startPoint, const OdGeVector3d& dirToNextPoint); }; /** \details This template class is a specialization of the OdSmartPtr class for OdGiGDIViewportClippingEntry object pointers. */ typedef OdSmartPtr OdGiGDIViewportClippingEntryPtr; /** \details This class implements Viewport Clipping list entry. */ struct OdGiGDIViewportClippingListEntry { /** Smart pointer to a viewport clipping entry. */ OdGiGDIViewportClippingEntryPtr m_pEntry; /** Pointer to the next list of the clipping entries. */ OdGiGDIViewportClippingListEntry *m_pNext; /** \details Default constructor for the OdGiGDIViewportClippingListEntry structure. */ OdGiGDIViewportClippingListEntry() : m_pEntry(OdGiGDIViewportClippingEntry::createObject()) , m_pNext(NULL) { } }; /** \details This class implements storage container for temporary conveyor node elements. */ struct OdGiGDIConvCtxStorage { /** A set of flags that represent a state of the node. */ enum Flags { /** Draw context is set. */ kContextSet = 1, /** Array of deviation values is set. */ kDevArraySet = 2, /** Global deviation object is set. */ kDeviationSet = 4 }; /** A set of flags that represent a state of the node. */ OdUInt8 m_flags; /** Draw context. */ OdGiConveyorContext *m_pDrawContext; /** An array of deviation values for curve tessellation for each geometry type. */ OdGeDoubleArray m_deviations; /** Global deviation object that defines curve tessellation. */ const OdGiDeviation *m_pDeviation; /** \details Default constructor for the OdGiGDIConvCtxStorage structure. */ OdGiGDIConvCtxStorage() : m_flags(0), m_pDrawContext(NULL), m_pDeviation(NULL) { } /** \details Sets the draw context object (to access to traits, etc). \param pDrawContext [in] Pointer to the draw context. \param pEntry [in] Pointer to the viewport clipping list entry. */ void setDrawContext(OdGiConveyorContext* pDrawContext, OdGiGDIViewportClippingListEntry *pEntry); /** \details Sets max deviation for curve tessellation to the list of viewport entry entries. \param deviations [in] Array with deviation values. \param pEntry [in] Pointer to the a list of viewport clipping entries. */ void setDeviation(const OdGeDoubleArray& deviations, OdGiGDIViewportClippingListEntry *pEntry); /** \details Sets deviation object to obtain max deviation for curve tessellation to the list of viewport entry entries. \param pDeviation [in] Pointer to the deviation object. \param pEntry [in] Pointer to the a list of viewport clipping entries. */ void setDeviation(const OdGiDeviation* pDeviation, OdGiGDIViewportClippingListEntry *pEntry); /** \details Initializes the list of viewport entry entries with the draw context, global deviation object and deviation values for curve tesselation. \param pEntry [in] Pointer to the a list of viewport clipping entries. */ void init(OdGiGDIViewportClippingListEntry *pEntry); }; #endif // GDI_USE_ENHANCED_CLIPPER /** \details This class implements Viewport Clipping manager for GDI Vectorizer Device objects. */ class OdGiGDIViewportClipping : public OdGiConveyorNode #ifndef GDI_USE_ENHANCED_CLIPPER , public OdGsConveyorNodeBase #endif // GDI_USE_ENHANCED_CLIPPER { #ifndef GDI_USE_ENHANCED_CLIPPER OdGiGDIConvCtxStorage m_ctxStorage; OdGiGDIViewportClippingListEntry *m_pClipList; OdGiGDIViewportClippingListEntry *m_pClipListTail; #else // GDI_USE_ENHANCED_CLIPPER OdGiOrthoClipperExPtr m_pClipper; #endif // GDI_USE_ENHANCED_CLIPPER protected: OdGiGDIViewportClipping(); public: /** \details Creates an instance of the OdGiGDIViewportClipping class. \returns Smart pointer to the created instance. */ static OdSmartPtr createObject(); #ifndef GDI_USE_ENHANCED_CLIPPER /** \details Retrieves a pointer to optional geometry. */ OdGiConveyorGeometry* optionalGeometry(); #else // GDI_USE_ENHANCED_CLIPPER /** \details Checks whether clipping stage chain is not empty. \returns true if clipping stage chain is not empty, false otherwise. */ bool isClipping() const { return !m_pClipper->isEmpty(); } #endif // GDI_USE_ENHANCED_CLIPPER /** \details Checks whether the specified clipping region is valid. \param points [in] Pointer to an array of points. \param pointCounts [in] Count of points. \param numPolygons [in] Number of polygons. Not used. \returns true if the region is valid, false otherwise. */ static bool acceptable(const OdGsDCPoint* points, const int *pointCounts, int numPolygons); /** \details Accepts the specified clipping region. \param points [in] Pointer to an array of points. \param pointCounts [in] Count of points. \param numPolygons [in] Number of polygons. Not used. \returns true if the region is valid, false otherwise. \remarks By default calls OdGiGDIViewportClipping::acceptable(const OdGsDCPoint* points, const int * pointCounts, int numPolygons) */ bool accept(const OdGsDCPoint* points, const int *pointCounts, int numPolygons) const; /** \details Pushes the clipping stage for a clipper using the specified parameters. \param points [in] Pointer to an array of points. \param pointCounts [in] Count of points. \param numPolygons [in] Number of polygons. Not used. \returns true if successful, false otherwise. */ bool push(const OdGsDCPoint* points, const int *pointCounts, int numPolygons); /** \details Checks whether the specified clipping region is valid. \param min [in] Minimum point. \param max [in] Maximum point. \returns true if the region is valid, false otherwise. */ static bool acceptable(const OdGsDCPoint& min, const OdGsDCPoint& max); /** \details Accepts the specified clipping region. \param min [in] Minimum point. \param max [in] Maximum point. \returns true if the region is valid, false otherwise. \remarks By default calls OdGiGDIViewportClipping::acceptable(const OdGsDCPoint& min, const OdGsDCPoint& max). */ bool accept(const OdGsDCPoint& min, const OdGsDCPoint& max) const; /** \details Pushes the clipping stage for a clipper using the specified parameters. \param min [in] Minimum point. \param max [in] Maximum point. \returns true if successful, false otherwise. */ bool push(const OdGsDCPoint& min, const OdGsDCPoint& max); /** \details Pops a clipping stage from a clipper. \returns true if successful, false otherwise. */ bool pop(); /** \details Sets the draw context associated with this object. \param pDrawContext [in] Pointer to the draw context. */ void setDrawContext(OdGiConveyorContext* pDrawContext); /** \details Sets max deviation for curve tessellation. \param deviations [in] Deviation values for curve tessellation. */ void setDeviation(const OdGeDoubleArray& deviations); /** \details Sets deviation object to obtain max deviation for curve tessellation. \param pDeviation [in] Pointer to the deviation object. */ void setDeviation(const OdGiDeviation* pDeviation); // OdGiConveyorNode methods /** \details Returns the input from the conveyor node. */ OdGiConveyorInput& input() override; /** \details Returns the output from the conveyor node. */ OdGiConveyorOutput& output() override; }; /** \details This template class is a specialization of the OdSmartPtr class for OdGiGDIViewportClipping object pointers. */ typedef OdSmartPtr OdGiGDIViewportClippingPtr; #include "TD_PackPop.h" #endif // _EXGIGDIVIEWPORTCLIPPER_H_INCLUDED_