/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // // HoopCommon.h - Open Design Hoops Export definitions // /////////////////////////////////////////////////////////////////////////////// #ifndef _HOOPS_COMMON_INCLUDED_ #define _HOOPS_COMMON_INCLUDED_ #include "HoopsExportCommon.h" #include "Gs/GsBaseVectorizer.h" #include "BoolArray.h" #include "HoopsExportImpl.h" #include "HoopsStringsDef.h" #include "Gi/GiLinetype.h" #include "Gi/GiGeometrySimplifier.h" #include "Gi/GiRasterImage.h" #include "Ge/GeLine3d.h" #include "Ge/GeCircArc3d.h" #include "Ge/GeEllipArc3d.h" #include "Ge/GeNurbCurve3d.h" ////////////////////////////////////////////////////////////////////// /** \details This namespace represents structures, classes and functions, that implement functionality for exporting to a hoops file. */ namespace TD_HOOPS_COMMON_EXPORT { /** \details This structure implements the hoops three-dimensional point. */ struct HoopsPoint { float x; //!< Coordinate X of the three-dimensional point. float y; //!< Coordinate Y of the three-dimensional point. float z; //!< Coordinate Z of the three-dimensional point. }; /** \details This structure implements the hoops two-dimensional point. */ struct Hoops2dPoint { float x; //!< Coordinate X of the two-dimensional point. float y; //!< Coordinate Y of the two-dimensional point. }; /** \details This structure implements the hoops two-dimensional point. */ struct HoopsD2dPoint { double x; //!< Coordinate X of the two-dimensional point. double y; //!< Coordinate Y of the two-dimensional point. }; /** \details This structure implements the three-dimensional glyph geometry information. */ struct CGlyphGeometryInfo { OdGePoint3dArray pVertices; //!< Array of vertices. bool bFillMode; //!< Fill flag of the geometry. }; /** \details This structure implements the two-dimensional glyph geometry information. */ struct CGlyph2dGeometryInfo { OdGePoint2dArray pVertices; //!< Array of vertices. bool bFillMode; //!< Fill flag of the geometry. }; /** \details This class implements the two-dimensional glyph geometry. */ class CGlyph2dGeometry { public: /** \details Creates an instance of two-dimensional glyph geometry. */ CGlyph2dGeometry(); /** \details Destroys an instance of two-dimensional glyph geometry. */ virtual ~CGlyph2dGeometry(); /** \details Sets a new maximum size value. \param iSize [in] A new maximum size value to be set. */ void setMaxSize( OdInt32 iSize ); /** \details Returns the current maximum size value. */ OdInt32 maxSize(); /** \details Returns the current region length. */ double getRegionLength(); /** \details Returns the current region height. */ double getRegionHeight(); /** \details Returns the current maximum Y coordinate of the region. */ double getMaxY(); /** \details Returns the current minimum Y coordinate of the region. */ double getMinY(); /** \details Sets a new length value through minimum and maximum coordinates at the X axis. \param dXMin [in] A minimum X coordinate value. \param dXMax [in] A maximum X coordinate value. */ void setLength( double dXMin, double dXMax ); /** \details Sets a new height value through minimum and maximum coordinates at the Y axis. \param dYMin [in] A minimum Y coordinate value. \param dYMax [in] A maximum Y coordinate value. */ void setHeight( double dYMin, double dYMax ); /** \details Adds a new three-dimensional geometry item. \param pInfo [in] A new geometry item to be added. \param bKeepXY [in] A flag that determines whether coordinates are kept. */ void Add3dGeometryItem( CGlyphGeometryInfo pInfo, bool bKeepXY = false); /** \details Returns minimum and maximum points of the region. \param ptMin [out] A reference to an OdGePoint2d object used to return the minimum point. \param ptMax [out] A reference to an OdGePoint2d object used to return the maximum point. */ void getMinMax( OdGePoint2d& ptMin, OdGePoint2d& ptMax ); /** \details Rotates the geometry object using a specified angle. \param dAngle [in] A rotation angle. \param bUpdateExtents [in] A flag that determines whether extents should be updated after the rotation (if true, extents are updated after rotation). */ void rotateByAngle( double dAngle, bool bUpdateExtents = true ); /** \details Fixes the center of the glyph geometry object. */ void fixGlyphCenter(); /** \details Returns the current glyph geometry object center. */ OdGePoint2d getGlyphCenter(); /** \details Clips the glyph geometry object to a region specified with its size. \param dSize [in] A clip region size. \param bMoveCenterToZero [in] A flag that determines whether the center is moved to the origin. \param bUpdateExtents [in] A flag that determines whether extents should be updated before clipping. \returns Returns the scale value to be implemented for clipped geometry. \remarks The values of the dSize parameter determines the scale. If bMoveCenterToZero is true, the clipped rectangle is centered around the origin of the coordinate system. Otherwise the mininum point of the region is moved to the coordinate system origin. The returned scale value also depends on the bMoveCenterToZero flag value. If the flag is false, the scale value is determined as the result of dividing dSize by the maximum length of the region's side. If the flag is true, the scale value is equal to the result of dSize multiplicated by 2 divided by the maximum length of the region's side. */ double ClipToRegion( double dSize, bool bMoveCenterToZero = true, bool bUpdateExtents = true ); /** \details Returns the character's quantity used for glyph definition. */ OdUInt32 getnCharsForGlyphDefine(); /** \details Returns the current item's quantity in the glyph geometry object. */ OdInt32 getnItems(); /** \details Returns the specified item from the glyph geometry object. \param iNum [in] A number (index) of an item to retrieve the information about. \param p2dInfo [out] A reference to a CGlyph2dGeometryInfo structure instance to store and return the specified item information. \returns Returns true if the information has been successfully returned, otherwise returns false. */ bool getItem( OdUInt32 iNum, CGlyph2dGeometryInfo& p2dInfo ); //DOM-IGNORE-BEGIN private: double m_dXMin; double m_dXMax; double m_dYMin; double m_dYMax; OdInt32 m_iMaxSize; OdGePoint2d m_ptCenter; bool m_bFixedCenter; OdArray m_arrVerticesData; void Convert3dPtArrayForGlyphDefine( OdGePoint3dArray arr3dPts, OdGePoint2dArray& arr2dPts, bool bKeepXY = false ); void reducePolylinePoints( OdGePoint2dArray& arr2dPts ); //DOM-IGNORE-END }; /** \details This class implements the hoops glyph writer. */ class CHoopsGlyphWriter : public OdGiGeometrySimplifier { public: /** \details Creates an instance of a hoops glyph writer. */ CHoopsGlyphWriter() { dScale = 1; bTTF = false; dXOffset = dYOffset = 0; }; /** \details Destroys the hoops glyph writer object. */ virtual ~CHoopsGlyphWriter(){}; OdArray arrGlyphGeometry; //!< An array of glyph geometry information. double dScale; //!< A scale value used for geometry. double dXOffset; //!< An offset from the origin at the X-axis. double dYOffset; //!< An offset from the origin at the Y-axis. bool bTTF; //!< A flag that determines whether glyph geometry uses true type fonts (TTF). If TTFs are used, the value is equal to true, otherwise equal to false. /////////////////////////////////////////////////////////////////// /** \details Resets the glyph writer parameters: sets the scale value to 1, sets the offset to zero, and clears the array of geometry information. */ void reset() { dXOffset = 0; dYOffset = 0; dScale = 1; for( OdUInt32 i = 0; i < arrGlyphGeometry.size(); i++) arrGlyphGeometry[i].pVertices.clear(); arrGlyphGeometry.clear(); } /////////////////////////////////////////////////////////////////// /** \details Adds a polyline to the glyph geometry. \param nbPoints [in] A number of polyline vertices. \param pVertexList [in] An array of three-dimensional points, which are the polyline vertices. */ virtual void polylineOut( OdInt32 nbPoints, const OdGePoint3d* pVertexList ) { bool bFillMode = drawContext()->effectiveTraits().fillType()==kOdGiFillAlways; CGlyphGeometryInfo tmpRecord; if( bTTF && giCtx().fillTtf()) tmpRecord.bFillMode = true; else tmpRecord.bFillMode = bFillMode; tmpRecord.bFillMode = false; for( OdInt32 i = 0; i