/////////////////////////////////////////////////////////////////////////////// // 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_SR_TRANSFORMATION_HOLDER_H #define OD_SR_TRANSFORMATION_HOLDER_H #include class OdSrTransformationHolder { OdGeMatrix3d m_worldToDeviceMatrix; OdGeMatrix3d m_worldToEyeMatrix; OdGeMatrix3d m_eyeToDeviceMatrix; public: void setMatrixWorldToDevice(const OdGeMatrix3d& worldToDevice) { m_worldToDeviceMatrix = worldToDevice; } void setMatrixWorldToEye(const OdGeMatrix3d& worldToEye) { m_worldToEyeMatrix = worldToEye; } void setMatrixEyeToDevice(const OdGeMatrix3d& eyeToDevice) { m_eyeToDeviceMatrix = eyeToDevice; } const OdGeMatrix3d& worldToDevice() const { return m_worldToDeviceMatrix; } const OdGeMatrix3d& worldToEye() const { return m_worldToEyeMatrix; } const OdGeMatrix3d& eyeToDevice() const { return m_eyeToDeviceMatrix; } OdGePoint2d transformPoint2d(const OdGePoint2d& point) { return OdGePoint3d(point.x, point.y, 0).transformBy(m_worldToDeviceMatrix).convert2d(); } OdGePoint2d transformToDevice(const OdGePoint2d& point) { return OdGePoint3d(point.x, point.y, 0).transformBy(m_worldToDeviceMatrix).convert2d(); } OdGeVector2d transformToDevice(const OdGeVector2d& point) { return OdGeVector3d(point.x, point.y, 0).transformBy(m_worldToDeviceMatrix).convert2d(); } OdGePoint2d transformVectorToDevice(const OdGePoint2d& point) { return OdGePoint3d(point.x, point.y, 0).transformBy(m_worldToDeviceMatrix).convert2d(); } OdGeVector2d transformBy(const OdGeVector2d& point, const OdGeMatrix3d& matrix) { return OdGeVector3d(point.x, point.y, 0).transformBy(matrix).convert2d(); } OdGePoint2d transformPoint3d(const OdGePoint3d& point) { double dividerInv = 1.0 / (m_worldToDeviceMatrix[3][0] * point.x + m_worldToDeviceMatrix[3][1] * point.y + m_worldToDeviceMatrix[3][2] * point.z + m_worldToDeviceMatrix[3][3]); return OdGePoint2d( (m_worldToDeviceMatrix[0][0] * point.x + m_worldToDeviceMatrix[0][1] * point.y + m_worldToDeviceMatrix[0][2] * point.z + m_worldToDeviceMatrix[0][3]) * dividerInv, (m_worldToDeviceMatrix[1][0] * point.x + m_worldToDeviceMatrix[1][1] * point.y + m_worldToDeviceMatrix[1][2] * point.z + m_worldToDeviceMatrix[1][3]) * dividerInv); } OdGeVector2d transformVector2d(const OdGeVector2d& vector) { return OdGeVector3d(vector.x, vector.y, 0).transformBy(m_worldToDeviceMatrix).convert2d(); } inline void transformTwoPoints3dTo4ints(const OdGePoint3d* points, OdInt32& x0, OdInt32& y0, OdInt32& x1, OdInt32& y1) { //double dividerInv = ((*m_worldToDeviceMatrix)[3][0] * points->x + (*m_worldToDeviceMatrix)[3][1] * points->y + (*m_worldToDeviceMatrix)[3][2] * points->z + (*m_worldToDeviceMatrix)[3][3]); const OdGePoint3d* pNext = points + 1; x0 = static_cast( OdRound((m_worldToDeviceMatrix[0][0] * points->x + m_worldToDeviceMatrix[0][1] * points->y + m_worldToDeviceMatrix[0][2] * points->z + m_worldToDeviceMatrix[0][3]))); // * dividerInv)); y0 = static_cast( OdRound((m_worldToDeviceMatrix[1][0] * points->x + m_worldToDeviceMatrix[1][1] * points->y + m_worldToDeviceMatrix[1][2] * points->z + m_worldToDeviceMatrix[1][3]))); // * dividerInv)); x1 = static_cast( OdRound((m_worldToDeviceMatrix[0][0] * pNext->x + m_worldToDeviceMatrix[0][1] * pNext->y + m_worldToDeviceMatrix[0][2] * pNext->z + m_worldToDeviceMatrix[0][3]))); // * dividerInv)); y1 = static_cast( OdRound((m_worldToDeviceMatrix[1][0] * pNext->x + m_worldToDeviceMatrix[1][1] * pNext->y + m_worldToDeviceMatrix[1][2] * pNext->z + m_worldToDeviceMatrix[1][3]))); // * dividerInv)); } }; #endif // OD_SR_TRANSFORMATION_HOLDER_H