/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// #include "StdAfx.h" #include "RxObjectImpl.h" #include "DgAutoplantDomeImpl.h" #include "DgAutoplantDome.h" #include "DgXAttribute.h" #include "DgAutoplantEntityProperties.h" #include "Ge/GePlane.h" #include "Ge/GeLine3d.h" //============================================================================================== // // OdDgAutoplantDomeExtraData // //============================================================================================== OdDgAutoplantDomeExtraData::OdDgAutoplantDomeExtraData() { m_pointValues[0] = OdGePoint3d::kOrigin; m_pointValues[1] = OdGePoint3d::kOrigin; m_pointValues[2] = OdGePoint3d::kOrigin; m_pointValues[3] = OdGePoint3d::kOrigin; m_vectorValues[0] = OdGeVector3d::kZAxis; m_vectorValues[1] = OdGeVector3d::kZAxis; m_doubleValues[0] = 0.0; m_doubleValues[1] = 0.0; } //============================================================================================== // // OdDgAutoplantDome // //============================================================================================== ODRX_CONS_DEFINE_MEMBERS(OdDgAutoplantDome, OdDgProxyGraphicsElement, DGELEMENT_CONSTR) //============================================================================================== OdDgAutoplantDome::OdDgAutoplantDome() { set3dFormatFlag(true); setElementType(OdDgElement::kTypeExtraGraphicsElement); } //============================================================================================== OdUInt32 OdDgAutoplantDome::subSetAttributes(OdGiDrawableTraits* pTraits) const { OdUInt32 uRet = OdDgGraphicsElement::subSetAttributes(pTraits); OdGiSubEntityTraitsPtr pSubEntityTraits = OdGiSubEntityTraits::cast(pTraits); if (!pSubEntityTraits.isNull()) { pSubEntityTraits->setLineType(0); pSubEntityTraits->setLineWeight(OdDb::kLnWt000); } return uRet; } //============================================================================================== void OdDgAutoplantDome::scaleDataAfterWorkingUnitsChange(double dScale) { return m_impl.scaleData(dScale); } //============================================================================================== bool OdDgAutoplantDome::subWorldDraw(OdGiWorldDraw* pWd) const { return m_impl.subWorldDraw(pWd, this); } //============================================================================================== void OdDgAutoplantDome::subViewportDraw(OdGiViewportDraw *pVd) const { return m_impl.subViewportDraw(pVd, this); } //============================================================================================== OdResult OdDgAutoplantDome::subGetGeomExtents(OdGeExtents3d& extents) const { return m_impl.subGetGeomExtents(extents, this); } //============================================================================================== OdResult OdDgAutoplantDome::subGetGeomExtents(const OdDgElementId& idView, OdGeExtents3d& extents) const { return m_impl.subGetGeomExtents(idView, extents, this); } //============================================================================================== OdResult OdDgAutoplantDome::subExplode(OdRxObjectPtrArray& entitySet) const { return m_impl.subExplode(entitySet, this); } //============================================================================================== OdResult OdDgAutoplantDome::transformBy(const OdGeMatrix3d& xfm) { assertWriteEnabled(); return m_impl.transformBy(xfm); } //============================================================================================== bool OdDgAutoplantDome::allowToConvertFromElement(OdDgElement* pBaseElement) const { if (pBaseElement && (pBaseElement->getElementType() == OdDgElement::kTypeExtraGraphicsElement) && (OdDgElement::getElementExtendedType(pBaseElement) == (OdUInt64)(OdDgAutoplantDome::kType)) ) { return true; } return false; } //============================================================================================== void OdDgAutoplantDome::decomposeForSave() { OdRxObjectPtrArray arrXAttrs; getXAttributes(OdDgExtendedElementTypeXAttribute::kType, arrXAttrs); bool bAddXAttr = true; if( !arrXAttrs.isEmpty() ) { OdDgExtendedElementTypeXAttributePtr pXAttr = arrXAttrs[0]; if( !pXAttr.isNull() ) { bAddXAttr = pXAttr->getElementType() != (OdDgExtendedElementTypeXAttribute::OdDgExtendedElementType)(kType); if (bAddXAttr) removeXAttributes(OdDgExtendedElementTypeXAttribute::kType); } } if (bAddXAttr) { OdDgExtendedElementTypeXAttributePtr pXAttr = OdDgExtendedElementTypeXAttribute::createObject(); pXAttr->setElementType((OdDgExtendedElementTypeXAttribute::OdDgExtendedElementType)(kType)); pXAttr->setFlags(0); pXAttr->setXAttrId(1); addXAttribute(OdDgExtendedElementTypeXAttribute::kType, pXAttr); } } //============================================================================================== OdResult OdDgAutoplantDome::dgnInFields(OdDgFiler* pFiler) { return m_impl.dgnInFields(pFiler); } //============================================================================================== void OdDgAutoplantDome::dgnOutFields(OdDgFiler* pFiler) const { m_impl.dgnOutFields(pFiler); } //============================================================================================== OdUInt64 OdDgAutoplantDome::getFlags() const { return m_impl.getFlags(); } //============================================================================================== void OdDgAutoplantDome::setFlags(OdUInt64 uFlags) { assertWriteEnabled(); m_impl.setFlags(uFlags); } //============================================================================================== OdGePoint3d OdDgAutoplantDome::getOrigin() const { return m_impl.getOrigin(); } //============================================================================================== void OdDgAutoplantDome::setOrigin(const OdGePoint3d& ptOrigin) { assertWriteEnabled(); m_impl.setOrigin(ptOrigin); } //============================================================================================== OdGeVector3d OdDgAutoplantDome::getDirection() const { return m_impl.getDirection(); } //============================================================================================== void OdDgAutoplantDome::setDirection(const OdGeVector3d& vrDirection) { assertWriteEnabled(); m_impl.setDirection(vrDirection); } //============================================================================================== double OdDgAutoplantDome::getRadius() const { return m_impl.getRadius(); } //============================================================================================== void OdDgAutoplantDome::setRadius(double dRadius) { assertWriteEnabled(); m_impl.setRadius(dRadius); } //============================================================================================== double OdDgAutoplantDome::getHeight() const { return m_impl.getHeight(); } //============================================================================================== void OdDgAutoplantDome::setHeight(double dHeight) { assertWriteEnabled(); m_impl.setHeight(dHeight); } //============================================================================================== OdDgAutoplantDomeExtraData OdDgAutoplantDome::getExtraData() const { return m_impl.getExtraData(); } //============================================================================================== void OdDgAutoplantDome::setExtraData(const OdDgAutoplantDomeExtraData& extraData) { assertWriteEnabled(); m_impl.setExtraData(extraData); } //============================================================================================== // CDA Properties for OdDgAutoplantDome //============================================================================================== //----------------------------------------------------------------------------------------------------------------------- // property: Origin //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantDomeOriginProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantDomePtr pObj = OdDgAutoplantDome::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getOrigin(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantDomeOriginProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantDomePtr pObj = OdDgAutoplantDome::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setOrigin(*rxvalue_cast(&value)); return eOk; } //----------------------------------------------------------------------------------------------------------------------- // property: Direction //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantDomeDirectionProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantDomePtr pObj = OdDgAutoplantDome::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getDirection(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantDomeDirectionProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantDomePtr pObj = OdDgAutoplantDome::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setDirection(*rxvalue_cast(&value)); return eOk; } //----------------------------------------------------------------------------------------------------------------------- // property: Radius //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantDomeRadiusProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantDomePtr pObj = OdDgAutoplantDome::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getRadius(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantDomeRadiusProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantDomePtr pObj = OdDgAutoplantDome::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setRadius(*rxvalue_cast(&value)); return eOk; } //----------------------------------------------------------------------------------------------------------------------- // property: Height //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantDomeHeightProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantDomePtr pObj = OdDgAutoplantDome::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getHeight(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantDomeHeightProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantDomePtr pObj = OdDgAutoplantDome::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setHeight(*rxvalue_cast(&value)); return eOk; } //----------------------------------------------------------------------------------------------------------------------- // property: Flags //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantDomeFlagsProperty::subGetValue(const OdRxObject* pO, OdRxValue& value) const { OdDgAutoplantDomePtr pObj = OdDgAutoplantDome::cast(pO); if (pObj.isNull()) return eNotApplicable; value = pObj->getFlags(); return eOk; } //----------------------------------------------------------------------------------------------------------------------- OdResult OdDgAutoplantDomeFlagsProperty::subSetValue(OdRxObject* pO, const OdRxValue& value) const { OdDgAutoplantDomePtr pObj = OdDgAutoplantDome::cast(pO); if (pObj.isNull()) return eNotApplicable; pObj->setFlags(*rxvalue_cast(&value)); return eOk; } //============================================================================================== // Grip and snap points for OdDgAutoplantDome //============================================================================================== OdResult OdDgAutoplantDomeGripPointsPE::getGripPoints(const OdDgElement* pEnt, OdGePoint3dArray& gripPoints)const { unsigned int size = gripPoints.size(); gripPoints.resize(size + 3); OdDgAutoplantDomePtr pDome = pEnt; OdGeVector3d vrZDir = pDome->getDirection(); if (vrZDir.isZeroLength()) vrZDir = OdGeVector3d::kZAxis; else vrZDir.normalize(); gripPoints[size] = pDome->getOrigin(); gripPoints[size + 1] = pDome->getOrigin() + vrZDir * pDome->getHeight(); gripPoints[size + 2] = pDome->getOrigin() + vrZDir.perpVector() * pDome->getRadius(); return eOk; } //============================================================================================== OdResult OdDgAutoplantDomeGripPointsPE::moveGripPointsAt(OdDgElement* pEnt, const OdIntArray& indices, const OdGeVector3d& offset) { unsigned size = indices.size(); if (size == 0) return eOk; OdDgAutoplantDomePtr pDome = pEnt; OdGeVector3d vrZDir = pDome->getDirection(); if (vrZDir.isZeroLength()) vrZDir = OdGeVector3d::kZAxis; else vrZDir.normalize(); if (size > 1 || indices[0] == 3) { pDome->transformBy(OdGeMatrix3d::translation(offset)); } else if (indices[0] == 0) { pDome->setOrigin(pDome->getOrigin() + offset); } else if (indices[0] == 1) { OdGePoint3d ptNewDir = pDome->getOrigin() + vrZDir * pDome->getHeight() + offset; OdGeVector3d vrNewDir = ptNewDir - pDome->getOrigin(); if( !vrNewDir.isZeroLength() ) { pDome->setHeight(vrNewDir.length()); vrNewDir.normalize(); pDome->setDirection(vrNewDir); } } else { OdGePoint3d ptRadius = pDome->getOrigin() + vrZDir.perpVector() * pDome->getRadius(); OdGePoint3d ptRadiusNew = ptRadius + offset; OdGePlane planeRadius(ptRadius, vrZDir); ptRadiusNew = ptRadiusNew.project(planeRadius, vrZDir); pDome->setRadius(pDome->getOrigin().distanceTo(ptRadiusNew)); } return eOk; } //============================================================================================== OdResult OdDgAutoplantDomeGripPointsPE::getStretchPoints(const OdDgElement* pEnt, OdGePoint3dArray& stretchPoints) const { OdResult res = getGripPoints(pEnt, stretchPoints); if (res == eOk) { stretchPoints.resize(stretchPoints.size() - 1); } return res; } //============================================================================================== OdResult OdDgAutoplantDomeGripPointsPE::moveStretchPointsAt(OdDgElement* pEnt, const OdIntArray& indices, const OdGeVector3d& offset) { return moveGripPointsAt(pEnt, indices, offset); } //============================================================================================== OdResult OdDgAutoplantDomeGripPointsPE::getOsnapPoints(const OdDgElement* pEnt, OdDgElement::OsnapMode osnapMode, OdGsMarker gsSelectionMark, const OdGePoint3d& pickPoint, const OdGePoint3d& lastPoint, const OdGeMatrix3d& xWorldToEye, OdGePoint3dArray& snapPoints) const { OdDgAutoplantDomePtr pDome = pEnt; OdGeVector3d vrZDir = pDome->getDirection(); if (vrZDir.isZeroLength()) vrZDir = OdGeVector3d::kZAxis; else vrZDir.normalize(); switch (osnapMode) { case OdDgElement::kOsModeCen: { snapPoints.append(pDome->getOrigin()); snapPoints.append(pDome->getOrigin() + vrZDir * pDome->getHeight()); } break; case OdDgElement::kOsModeEnd: { OdGeVector3d vrRadius = vrZDir.perpVector(); for (OdUInt32 i = 0; i < 8; i++) { snapPoints.append(pDome->getOrigin() + vrRadius * pDome->getRadius()); vrRadius.rotateBy(OdaPI4, vrZDir); } } break; default: { } break; } return eOk; } //==============================================================================================