/////////////////////////////////////////////////////////////////////////////// // 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 "OdaCommon.h" #include "DbAssocActionParam.h" #include "DbImpAssocActionParam.h" #include "DbAssocDependency.h" #include "DbAssocGeomDependency.h" #include "GeDwgIO.h" #include "GeDxfIO.h" #include "DbFiler.h" #include "Ge/GeKnotVector.h" #include "Ge/GeCurveCurveInt3d.h" #include #include "ModelerGeometry.h" #include "DbAcisIO.h" #include "DbDimAssoc.h" #include "OdDbAssocCurvePersSubentIdPE.h" #include "ShHistory/DbAssocPersSubentManager.h" #include "DbCircle.h" #include "DbArc.h" OdGeTol getOsnapPointTol(OdDb::OsnapMode osnapMode) { OdGeTol tol; if (osnapMode == OdDb::kOsModePerp) { tol.setEqualPoint(0.0001); tol.setEqualVector(0.01); } else { tol.setEqualPoint(1.0e-10); tol.setEqualVector(0.000001); } return tol; } OdSharedPtr getUnboundedCurveFrom(const OdGeEntity3d* pGeEntity) { if (!pGeEntity) return nullptr; // If the curve is closed, just return a copy const OdGeCurve3d* pCurve = static_cast(pGeEntity); if (pCurve && pCurve->isClosed()) return static_cast(pGeEntity->copy()); OdSharedPtr result; // Handle different entity types switch (pGeEntity->type()) { case OdGe::kCircArc3d: { OdGeCircArc3d* pCircArc = static_cast(pGeEntity->copy()); pCircArc->setAngles(0.0, Oda2PI); // Make full circle result.reset(pCircArc); } break; case OdGe::kEllipArc3d: { OdGeEllipArc3d* pEllipArc = static_cast(pGeEntity->copy()); pEllipArc->setAngles(0.0, Oda2PI); // Make full ellipse result.reset(pEllipArc); } break; case OdGe::kLineSeg3d: { // Convert line segment to infinite line const OdGeLineSeg3d* lineSeg = static_cast(pGeEntity); OdGeVector3d lineDir = lineSeg->direction(); OdGePoint3d pointOnLine = lineSeg->pointOnLine(); result.reset(new OdGeLine3d(lineSeg->pointOnLine(), lineSeg->direction())); } break; } return result; } OdResult calcTanOrPerpPoint( OdDb::OsnapMode snapMode, const OdGeCurve3d* pCurve, const OdGePoint3d& referencePoint, const OdGePoint3d& otherPoint, OdGePoint3d& pnt) { if (!pCurve) return eNullEdgeCurve; OdDbCurve* dbCurve = nullptr; OdDbCurve::createFromOdGeCurve(*pCurve, dbCurve); if (!dbCurve) return eNotApplicable; OdDbCurvePtr pDbCurve; pDbCurve.attach(dbCurve); OdGePoint3dArray snapPoints; OdGeMatrix3d viewTransform; // Get the appropriate snap points from the curve OdResult res = pDbCurve->getOsnapPoints( snapMode, 0, referencePoint, otherPoint, viewTransform, snapPoints); if (res != eOk || snapPoints.isEmpty()) return res; // Find the closest snap point to the reference point int closestIndex = 0; double minDistance = referencePoint.distanceTo(snapPoints[0]); for (unsigned int i = 1; i < snapPoints.length(); i++) { double currentDistance = referencePoint.distanceTo(snapPoints[i]); if (currentDistance < minDistance) { minDistance = currentDistance; closestIndex = i; } } // Store the result pnt = snapPoints[closestIndex]; return res; } OdDbImpAssocActionParam::OdDbImpAssocActionParam() : m_status(kIsUpToDateAssocStatus) { } OdDbImpAssocActionParam::~OdDbImpAssocActionParam() { } OdDbImpAssocActionParam* OdDbImpAssocActionParam::getImpObject(OdDbAssocActionParam *actionParam) { return static_cast(actionParam->m_pImpObj); } OdResult OdDbImpAssocActionParam::getDependencies(bool , bool , OdDbObjectIdArray& ) const { return eNotImplemented; } OdResult OdDbImpAssocActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId /*objectId*/) { OdUInt16 ver = pFiler->rdInt16(); ODA_ASSERT_ONCE(ver == (pFiler->dwgVersion() > OdDb::vAC24 ? 1 : 0)); if (ver > 1) return eMakeMeProxy; if (ver) { m_status = OdDbAssocStatus(pFiler->rdInt32()); if (m_status < 0 || m_status > kUnresolvedAssocStatus) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } } else m_status = kIsUpToDateAssocStatus; m_sName = pFiler->rdString(); return eOk; } void OdDbImpAssocActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId /*objectId*/) const { OdUInt16 ver = (pFiler->dwgVersion() > OdDb::vAC24) ? 1 : 0; pFiler->wrInt16(ver); if (ver) pFiler->wrInt32(m_status); pFiler->wrString(m_sName); } OdResult OdDbImpAssocActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId /*objectId*/) { if (!pFiler->atSubclassData(OdDbAssocActionParam::desc()->name())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) OdInt32 ver = pFiler->rdInt32(); ODA_ASSERT_ONCE(ver == (pFiler->dwgVersion() > OdDb::vAC24 ? 1 : 0)); if (ver > 1) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } if (ver) { NEXT_CODE(90) m_status = OdDbAssocStatus(pFiler->rdInt32()); } else m_status = kIsUpToDateAssocStatus; NEXT_CODE(1) m_sName = pFiler->rdString(); ODA_ASSERT_ONCE(pFiler->atEOF()); // TODO return eOk; } void OdDbImpAssocActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId /*objectId*/) const { pFiler->wrSubclassMarker(OdDbAssocActionParam::desc()->name()); OdInt32 ver = (pFiler->dwgVersion() > OdDb::vAC24) ? 1 : 0; pFiler->wrInt32(90, ver); if (ver) pFiler->wrInt32(90, 0); pFiler->wrString(1, m_sName); } OdStringArray OdDbImpAssocActionParam::compareWith(OdDbImpAssocActionParam *paramIDToCompare, OdDb::DwgVersion /*filerVersion*/ /*OdDb::kDHL_CURRENT*/) const { OdStringArray retArr; if (m_sName.compare(paramIDToCompare->m_sName) != 0) retArr.append(CS_PARAM_NAME); return retArr; } ////////////////////////////////////////////////////////////////////////// OdDbImpAssocSingleDependencyActionParam::OdDbImpAssocSingleDependencyActionParam() { m_DependencyId = NULL; } OdDbImpAssocSingleDependencyActionParam::~OdDbImpAssocSingleDependencyActionParam() { } OdResult OdDbImpAssocSingleDependencyActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { OdResult res = eNotImplemented; res = OdDbImpAssocActionParam::dwgInFields(pFiler, objectId); if (res != eOk) return res; OdUInt16 ver = pFiler->rdInt16(); if (ver) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } m_DependencyId = pFiler->rdSoftPointerId(); return eOk; } void OdDbImpAssocSingleDependencyActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocActionParam::dwgOutFields(pFiler, objectId); OdUInt16 ver = 0; pFiler->wrInt16(ver); pFiler->wrSoftPointerId(m_DependencyId); } OdResult OdDbImpAssocSingleDependencyActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { OdResult res = eNotImplemented; res = OdDbImpAssocActionParam::dxfInFields(pFiler, objectId); if (res != eOk) return res; if (!pFiler->atSubclassData(L"AcDbAssocSingleDependencyActionParam")) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) OdInt32 ver = pFiler->rdInt32(); if (ver) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } NEXT_CODE(330) m_DependencyId = pFiler->rdObjectId(); ODA_ASSERT_ONCE(pFiler->atEOF()); // TODO return eOk; } void OdDbImpAssocSingleDependencyActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocActionParam::dxfOutFields(pFiler, objectId); pFiler->wrSubclassMarker(L"AcDbAssocSingleDependencyActionParam"); OdInt32 ver = 0; pFiler->wrInt32(90, ver); pFiler->wrObjectId(330, m_DependencyId); } OdStringArray OdDbImpAssocSingleDependencyActionParam::compareWith(OdDbImpAssocActionParam *paramIDToCompare, OdDb::DwgVersion filerVersion /*OdDb::kDHL_CURRENT*/) const { OdStringArray retArr; OdDbImpAssocSingleDependencyActionParam* pComparedParam = static_cast(paramIDToCompare); ODA_ASSERT(pComparedParam != NULL); if (NULL != pComparedParam) { retArr = OdDbImpAssocActionParam::compareWith(paramIDToCompare, filerVersion /*OdDb::kDHL_CURRENT*/); OdDbObject* dependencyObject = m_DependencyId.openObject().get(); OdDbObject* dependencyUnknownObject = pComparedParam->m_DependencyId.openObject().get(); if (typeid(*dependencyObject) != typeid(*dependencyUnknownObject)) { retArr.append(CS_DIFFERENT_OBJECTS); } } return retArr; } OdDbObjectId OdDbImpAssocSingleDependencyActionParam::dependentOnObjectId() const { OdDbObjectId idRes; OdDbAssocDependencyPtr pDep = OdDbAssocDependency::cast(m_DependencyId.openObject()); if (!pDep.isNull()) { idRes = pDep->dependentOnObject(); } return idRes; } OdResult OdDbImpAssocSingleDependencyActionParam::detachDependencies( OdDbObjectId parentActionId ) { OdDbAssocActionPtr pAction = parentActionId.openObject( OdDb::kForWrite ); pAction->removeDependency( m_DependencyId, true ); m_DependencyId.setNull(); return eOk; } OdResult OdDbImpAssocSingleDependencyActionParam::getDependencies( bool readDependenciesWanted, bool writeDependenciesWanted, OdDbObjectIdArray& dependencyIds) const { if (m_DependencyId.isNull()) return eOk; OdDbAssocDependencyPtr pDep = OdDbAssocDependency::cast(m_DependencyId.openObject(OdDb::kForRead, true)); if (pDep.isNull()) return eOk; if ((readDependenciesWanted && pDep->isReadDependency()) || (writeDependenciesWanted && pDep->isWriteDependency())) dependencyIds.append(m_DependencyId); return eOk; } OdResult OdDbImpAssocSingleDependencyActionParam::setObject(OdDbObjectId actionId, const OdDbCompoundObjectId& object, bool isReadDependency /*= true*/, bool isWriteDependency /*= false*/) { ODA_ASSERT_ONCE(!actionId.isNull()); if (isReadDependency || isWriteDependency) { OdDbAssocActionPtr pAction = OdDbAssocAction::cast( actionId.openObject( OdDb::kForWrite ) ); OdDbAssocDependencyPtr pDependency = OdDbAssocDependency::createObject(); actionId.database()->addOdDbObject( pDependency ); pDependency->setIsReadDependency( isReadDependency ); pDependency->setIsWriteDependency( isWriteDependency ); pAction->addDependency( pDependency->objectId(), true ); pDependency->attachToObject( object ); m_DependencyId = pDependency->objectId(); } return eOk; } OdResult OdDbImpAssocSingleDependencyActionParam::setObjectOnly(OdDbObjectId actionId, const OdDbCompoundObjectId& object, bool isReadDependency /*= true*/, bool isWriteDependency /*= false*/) { ODA_VERIFY_ONCE(!actionId.isNull()); if (isReadDependency || isWriteDependency) { m_DependencyId = object.leafId(); } return eOk; } OdResult OdDbImpAssocSingleDependencyActionParam::getObject(OdDbCompoundObjectId& idObject) const { idObject.setEmpty(); OdDbAssocDependencyPtr pDependency = OdDbAssocDependency::cast(m_DependencyId.openObject(OdDb::kForRead)); if (pDependency.isNull()) { return eOk; } return pDependency->getDependentOnCompoundObject(idObject); } OdDbObjectId OdDbImpAssocSingleDependencyActionParam::getObject() const { OdDbAssocDependencyPtr pDependency = OdDbAssocDependency::cast(m_DependencyId.openObject()); if (pDependency.isNull()) return OdDbObjectId::kNull; return pDependency->dependentOnObject(); } OdResult OdDbImpAssocSingleDependencyActionParam::createDependency( const OdDbObjectId& actionId, const OdDbCompoundObjectId& compoundObjectId, OdDbSubentId subentId, bool isReadDependency, bool isWriteDependency, int dependencyOrder) { OdDbAssocActionPtr pAction = OdDbAssocAction::cast(actionId.openObject(OdDb::kForWrite)); if (pAction.isNull()) return eNullEntityPointer; OdDb::SubentType subenType = subentId.type(); OdDbAssocDependencyPtr pDependency = subenType == OdDb::kNullSubentType ? OdDbAssocDependency::createObject().get() : static_cast(OdDbAssocGeomDependency::createObject().get()); actionId.database()->addOdDbObject(pDependency); pDependency->setIsReadDependency(isReadDependency); pDependency->setIsWriteDependency(isWriteDependency); pDependency->setOrder(dependencyOrder); pDependency->attachToObject(compoundObjectId); if (subenType != OdDb::kNullSubentType) static_cast(pDependency.get())->setSubentity(subentId); pAction->addDependency(pDependency->objectId(), true); m_DependencyId = pDependency->objectId(); return eOk; } //------------------------------------------------------------------------------------------------------------------- // Replace: OdDbObjectId m_AssocViewRepHatchActionParam -> OdDbObjectIdArray m_ActionParams OdDbImpAssocCompoundActionParam::OdDbImpAssocCompoundActionParam() : m_Unknown1(0) { m_usingInheritor = false; m_Unknown1 = 0; m_Unknown2 = 0; m_UseAdditionalAnchors = 0; m_AnchorId1 = NULL; m_AnchorId2 = NULL; m_Unknown3 = 0; m_AnchorId3= NULL; } OdDbImpAssocCompoundActionParam::~OdDbImpAssocCompoundActionParam() { } OdResult OdDbImpAssocCompoundActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { if (!m_usingInheritor) { OdResult res = OdDbImpAssocActionParam::dwgInFields(pFiler, objectId); if (res != eOk) return res; } OdUInt16 ver = pFiler->rdInt16(); ODA_ASSERT_ONCE(!ver); // TODO if (ver) return eMakeMeProxy; m_Unknown1 = pFiler->rdInt16(); // 0 ODA_ASSERT_ONCE(!m_Unknown1); // test int nParamsSize = pFiler->rdInt32(); m_ActionParams.resize(nParamsSize); OdDbObjectId * pId = m_ActionParams.asArrayPtr(); while (nParamsSize--) { (*pId++) = pFiler->rdHardOwnershipId(); } if (m_usingInheritor) { m_Unknown2 = pFiler->rdInt16(); // 0 m_UseAdditionalAnchors = static_cast(pFiler->rdInt32()); // 0 m_AnchorId1 = pFiler->rdSoftPointerId(); } if (m_UseAdditionalAnchors != 0) { m_AnchorId2 = pFiler->rdSoftPointerId(); m_Unknown3 = static_cast(pFiler->rdInt32()); m_AnchorId3 = pFiler->rdSoftPointerId(); } return eOk; } void OdDbImpAssocCompoundActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { if (!m_usingInheritor) { OdDbImpAssocActionParam::dwgOutFields(pFiler, objectId); } OdUInt16 ver = 0; pFiler->wrInt16(ver); ODA_ASSERT_ONCE(!m_Unknown1); // test pFiler->wrInt16(m_Unknown1); // 0 int nParamsSize = m_ActionParams.size(); pFiler->wrInt32(nParamsSize); const OdDbObjectId * pId = m_ActionParams.asArrayPtr(); while (nParamsSize--) { pFiler->wrHardOwnershipId(*pId++); } if (m_usingInheritor) { pFiler->wrInt16(m_Unknown2); // 0 pFiler->wrInt32(m_UseAdditionalAnchors); // 0 pFiler->wrSoftPointerId(m_AnchorId1); } if (m_UseAdditionalAnchors != 0) { pFiler->wrSoftPointerId(m_AnchorId2); pFiler->wrInt32(m_Unknown3); pFiler->wrSoftPointerId(m_AnchorId3); } } OdResult OdDbImpAssocCompoundActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { if (!m_usingInheritor) { OdResult res = OdDbImpAssocActionParam::dxfInFields(pFiler, objectId); if (res != eOk) return res; } if (!pFiler->atSubclassData(OdDbAssocCompoundActionParam::desc()->name())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) OdUInt32 ver = pFiler->rdUInt32(); if (ver) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } NEXT_CODE(90) m_Unknown1 = (OdUInt16) pFiler->rdUInt32(); // 0 ODA_ASSERT_ONCE(!m_Unknown1); // test NEXT_CODE(90) int nParamsSize = pFiler->rdInt32(); m_ActionParams.reserve(nParamsSize); while (nParamsSize--) { NEXT_CODE(360) m_ActionParams.append(pFiler->rdObjectId()); } if (m_usingInheritor) { NEXT_CODE(90) m_Unknown2 = static_cast(pFiler->rdInt32()); NEXT_CODE(90) m_UseAdditionalAnchors = static_cast(pFiler->rdInt32()); NEXT_CODE(330) m_AnchorId1 = pFiler->rdObjectId(); } if (m_UseAdditionalAnchors != 0) { NEXT_CODE(330) m_AnchorId2 = pFiler->rdObjectId(); NEXT_CODE(90) m_Unknown3 = static_cast(pFiler->rdInt32()); NEXT_CODE(330) m_AnchorId3 = pFiler->rdObjectId(); } ODA_ASSERT_ONCE(pFiler->atEOF()); return eOk; } void OdDbImpAssocCompoundActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { if (!m_usingInheritor) { OdDbImpAssocActionParam::dxfOutFields(pFiler, objectId); } pFiler->wrSubclassMarker(OdDbAssocCompoundActionParam::desc()->name()); OdUInt32 ver = 0; pFiler->wrUInt32(90, ver); ODA_ASSERT_ONCE(!m_Unknown1); // test pFiler->wrUInt32(90, m_Unknown1); int nParamsSize = m_ActionParams.size(); pFiler->wrUInt32(90, nParamsSize); const OdDbObjectId * pId = m_ActionParams.asArrayPtr(); while (nParamsSize--) { pFiler->wrObjectId(360, *pId++); } if (m_usingInheritor) { pFiler->wrUInt32(90, m_Unknown2); pFiler->wrUInt32(90, m_UseAdditionalAnchors); pFiler->wrObjectId(330, m_AnchorId1); } if (m_UseAdditionalAnchors != 0) { pFiler->wrObjectId(330, m_AnchorId2); pFiler->wrUInt32(90, m_Unknown3); pFiler->wrObjectId(330, m_AnchorId3); } } OdStringArray OdDbImpAssocCompoundActionParam::compareWith(OdDbImpAssocActionParam *paramIDToCompare, OdDb::DwgVersion filerVersion /*OdDb::kDHL_CURRENT*/) const { OdStringArray retArr; OdDbImpAssocCompoundActionParam* pComparedParam = static_cast(paramIDToCompare); ODA_ASSERT(pComparedParam != NULL); if (NULL != pComparedParam) { retArr = OdDbImpAssocActionParam::compareWith(paramIDToCompare, filerVersion /*OdDb::kDHL_CURRENT*/); if (m_Unknown1 != pComparedParam->m_Unknown1) retArr.append(CS_NOT_CRITICAL); unsigned nParamsSize = m_ActionParams.size(); if (nParamsSize != pComparedParam->m_ActionParams.size()) retArr.append(CS_DIFFERENT_OBJECTS); else { const OdDbObjectId * pId = m_ActionParams.asArrayPtr(); const OdDbObjectId * pComparedId = pComparedParam->m_ActionParams.asArrayPtr(); OdDbObjectId m_surfaceObjectDepId; while (nParamsSize--) { OdDbObject* pObject = pId->openObject().get(); OdDbObject* pComparedObject = pComparedId->openObject().get(); if (typeid(*pObject) != typeid(*pComparedObject)) { retArr.append(CS_DIFFERENT_OBJECTS); return retArr; } pId++; pComparedId++; } } if (m_usingInheritor != pComparedParam->m_usingInheritor) { retArr.append(CS_DIFFERENT_OBJECTS); return retArr; } else { if (m_Unknown2 != pComparedParam->m_Unknown2) retArr.append(CS_OBJECT_ERROR); // TODO if (m_UseAdditionalAnchors != pComparedParam->m_UseAdditionalAnchors) retArr.append(CS_OBJECT_ERROR); // TODO if (m_AnchorId1 != pComparedParam->m_AnchorId1) retArr.append(CS_OBJECT_ERROR); // TODO } if (m_UseAdditionalAnchors != pComparedParam->m_UseAdditionalAnchors) { retArr.append(CS_DIFFERENT_OBJECTS); return retArr; } else { if (m_AnchorId2 != pComparedParam->m_AnchorId2) retArr.append(CS_OBJECT_ERROR); // TODO if (m_Unknown3 != pComparedParam->m_Unknown3) retArr.append(CS_OBJECT_ERROR); // TODO if (m_AnchorId3 != pComparedParam->m_AnchorId3) retArr.append(CS_OBJECT_ERROR); // TODO } } return retArr; } OdResult OdDbImpAssocCompoundActionParam::addParam_IfNotExistsAtIndex(OdDbAssocCompoundActionParam* self, const OdString& paramName, OdRxClass* pParamClass, const OdDbObjectId anchorId, OdDbObjectId& paramId, int& paramIndex) { ODA_ASSERT_ONCE(!paramName.isEmpty() && pParamClass && self); OdDbImpAssocCompoundActionParam* selfImpl = static_cast(getImpObject(self)); OdDbObjectIdArray idPars = self->paramsAtName(paramName); if (paramIndex < (int)idPars.size()) { paramId = idPars[paramIndex]; return eAlreadyInDb; } selfImpl->m_AnchorId1 = anchorId; return selfImpl->addParam(self, paramName, pParamClass, paramId, paramIndex); } OdResult OdDbImpAssocCompoundActionParam::addParam(OdDbAssocCompoundActionParam* self, const OdString& paramName, OdRxClass* pParamClass, OdDbObjectId& paramId, int& paramIndex) { OdDbAssocActionParamPtr pParam = OdDbAssocActionParam::cast(pParamClass->create()); if (pParam.isNull()) return eBadObjType; paramId = self->database()->addOdDbObject(pParam); pParam->setOwnerId(self->objectId()); pParam->setName(paramName); paramIndex = m_ActionParams.size(); m_ActionParams.push_back(paramId); return eOk; } OdResult OdDbImpAssocCompoundActionParam::removeParam(OdDbAssocCompoundActionParam* /*self*/, const OdDbObjectId& paramId, bool alsoEraseIt) { unsigned nIdx; if (m_ActionParams.find(paramId, nIdx)) { if (alsoEraseIt) { OdDbObjectPtr pObj = paramId.openObject(OdDb::kForWrite); pObj->erase(); } m_ActionParams.removeAt(nIdx); return eOk; } return eInvalidInput; } OdResult OdDbImpAssocCompoundActionParam::removeAllParams(OdDbAssocCompoundActionParam* /*self*/, bool alsoEraseThem) { if (alsoEraseThem) { int nSize = m_ActionParams.size(); OdDbObjectId* pId = m_ActionParams.asArrayPtr(); while (nSize--) { OdDbObjectPtr pObj = (pId++)->openObject(OdDb::kForWrite); pObj->erase(); } } m_ActionParams.resize(0); return eOk; } OdDbObjectIdArray OdDbImpAssocCompoundActionParam::paramsAtName(const OdString& paramName) const { ODA_ASSERT_ONCE(!paramName.isEmpty()); OdDbObjectIdArray idsRes; OdUInt32 sz = m_ActionParams.size(), idx = 0; for (; idx < sz; idx++) { OdDbAssocActionParamPtr pParam = OdDbAssocActionParam::cast(m_ActionParams[idx].openObject()); ODA_ASSERT_ONCE(!pParam.isNull()); if (pParam.isNull()) continue; OdString sName = pParam->name(); ODA_ASSERT_ONCE(!sName.isEmpty()); if (paramName != sName) continue; idsRes.push_back(m_ActionParams[idx]); } return idsRes; } OdDbObjectId OdDbImpAssocCompoundActionParam::paramAtName(const OdString& paramName, int index) const // = 0 { OdDbObjectIdArray ids = paramsAtName(paramName); ODA_ASSERT_ONCE(index >= 0); if (index < 0 || index >= (int)ids.size()) return OdDbObjectId(); return ids[index]; } //------------------------------------------------------------------------------------------------------------------- OdDbImpAssocObjectActionParam::OdDbImpAssocObjectActionParam() : m_isBase(true) { } OdDbImpAssocObjectActionParam::~OdDbImpAssocObjectActionParam() { } OdResult OdDbImpAssocObjectActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocSingleDependencyActionParam::dwgInFields(pFiler, objectId); if (res != eOk) return res; OdUInt16 ver = pFiler->rdInt16(); if (ver) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } return eOk; } void OdDbImpAssocObjectActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocSingleDependencyActionParam::dwgOutFields(pFiler, objectId); OdUInt16 ver = 0; pFiler->wrInt16(ver); } OdResult OdDbImpAssocObjectActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocSingleDependencyActionParam::dxfInFields(pFiler, objectId); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocObjectActionParam::desc()->name())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) OdInt32 ver = pFiler->rdInt32(); if (ver) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } ODA_ASSERT_ONCE(pFiler->atEOF()); // TODO return eOk; } void OdDbImpAssocObjectActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocSingleDependencyActionParam::dxfOutFields(pFiler, objectId); pFiler->wrSubclassMarker(OdDbAssocObjectActionParam::desc()->name()); OdInt32 ver = 0; pFiler->wrInt32(90, ver); } ///////////////////////////////////////////////////////////////////////// OdDbImpAssocVertexActionParam::OdDbImpAssocVertexActionParam() { } OdDbImpAssocVertexActionParam::~OdDbImpAssocVertexActionParam() { } OdResult OdDbImpAssocVertexActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocSingleDependencyActionParam::dwgInFields(pFiler, objectId); if (res != eOk) return res; int ver = pFiler->rdInt32(); if (ver) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } OdGePoint3d point = pFiler->rdPoint3d(); m_vertexRef = OdDbVertexRef(point); ODA_ASSERT_ONCE(point == m_vertexRef.point()); return eOk; } void OdDbImpAssocVertexActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocSingleDependencyActionParam::dwgOutFields(pFiler, objectId); int ver = 0; pFiler->wrInt32(ver); pFiler->wrPoint3d(m_vertexRef.point()); } OdResult OdDbImpAssocVertexActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocSingleDependencyActionParam::dxfInFields(pFiler, objectId); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocVertexActionParam::desc()->name())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) OdInt32 ver = pFiler->rdInt32(); if (ver) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } NEXT_CODE(10) OdGePoint3d point; pFiler->rdPoint3d(point); m_vertexRef = OdDbVertexRef(point); ODA_ASSERT_ONCE(point == m_vertexRef.point()); ODA_ASSERT_ONCE(pFiler->atEOF()); // TODO return eOk; } void OdDbImpAssocVertexActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocSingleDependencyActionParam::dxfOutFields(pFiler, objectId); pFiler->wrSubclassMarker(OdDbAssocVertexActionParam::desc()->name()); OdInt32 ver = 0; pFiler->wrInt32(90, ver); pFiler->wrPoint3d(10, m_vertexRef.point()); } OdResult OdDbImpAssocVertexActionParam::getVertexRef( OdArray& vertexRefs ) const { vertexRefs.push_back( m_vertexRef ); return eOk; } OdResult OdDbImpAssocVertexActionParam::getVertexRef( OdDbVertexRef& vertexRef ) const { vertexRef = m_vertexRef; return eOk; } OdResult OdDbImpAssocVertexActionParam::getVertexRefEval(OdArray& vertexRefs) { OdResult res; OdDbAssocGeomDependencyPtr pGeomDep; { OdDbObjectIdArray dependencyIds; res = getDependencies(true, true, dependencyIds); if (!dependencyIds.empty()) pGeomDep = dependencyIds.last().openObject(); } if (pGeomDep.isNull()) { vertexRefs.append(m_vertexRef); return eOk; } OdDbCompoundObjectId compoundId; if ((res = pGeomDep->getDependentOnCompoundObject(compoundId)) != eOk) return res; OdArray transientSubentIds; pGeomDep->getTransientSubentIds(transientSubentIds); if (transientSubentIds.isEmpty()) return eNotApplicable; OdGePoint3dArray vertexPositions; if ((res = pGeomDep->getVertexSubentityGeometry(vertexPositions)) != eOk) return res; if (vertexPositions.isEmpty() || vertexPositions.size() != transientSubentIds.size()) return eNotApplicable; OdDbVertexRef vertexRef(compoundId, transientSubentIds.first(), vertexPositions.first()); vertexRefs.append(vertexRef); return eOk; } OdResult OdDbImpAssocVertexActionParam::setVertexRef( const OdDbVertexRef& vertexRef, bool isReadDependency, bool isWriteDependency, int dependencyOrder, OdDbObjectId actionId ) { if (isReadDependency || isWriteDependency) createDependency(actionId, vertexRef.entity(), vertexRef.subentId(), isReadDependency, isWriteDependency, dependencyOrder); /*if ( isReadDependency || isWriteDependency ) { OdDbAssocActionPtr pAction = OdDbAssocAction::cast( actionId.openObject( OdDb::kForWrite ) ); OdDbSubentRefPtr pSubRef = OdDbSubentRef::cast( vertexRef.referencedRef() ); if ( !pSubRef.isNull() ) { OdDbAssocGeomDependencyPtr pDependency = OdDbAssocGeomDependency::createObject(); actionId.database()->addOdDbObject( pDependency ); pDependency->setIsReadDependency( isReadDependency ); pDependency->setIsWriteDependency( isWriteDependency ); OdDbCompoundObjectId compoundObjectId; compoundObjectId.setEmpty(); compoundObjectId.set( vertexRef.entity() ); pDependency->attachToObject( compoundObjectId ); pDependency->setSubentity( pSubRef->subentId() ); pAction->addDependency( pDependency->objectId(), true ); m_DependencyId = pDependency->objectId(); } }*/ m_vertexRef = vertexRef; return eOk; } ////////////////////////////////////////////////////////////////////////// OdDbImpAssocEdgeActionParam::OdDbImpAssocEdgeActionParam() { } OdDbImpAssocEdgeActionParam::~OdDbImpAssocEdgeActionParam() { } OdResult OdDbImpAssocEdgeActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocSingleDependencyActionParam::dwgInFields(pFiler, objectId); if (res != eOk) return res; int ver = pFiler->rdInt32(); if (ver) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } m_UnkownId = pFiler->rdSoftPointerId(); if (!pFiler->rdBool()) { m_edgeRef.reset(); } else { OdInt32 entId = pFiler->rdInt32(); OdSharedPtr pCurve3d; switch (entId) { case 23: //case OdGe::kLineSeg3d: // to regenerate DbLine in m_dbEntIds pCurve3d = new OdGeLineSeg3d(); if (OdGeDwgIO::inFields(pFiler, *(OdGeLineSeg3d*) pCurve3d.get()) != eOk) return eMakeMeProxy; break; case 17: //case OdGe::kEllipArc3d: // to regenerate DbEllipse in m_dbEntIds // x3a8 pCurve3d = new OdGeEllipArc3d(); if (OdGeDwgIO::inFields(pFiler, *(OdGeEllipArc3d*) pCurve3d.get()) != eOk) return eMakeMeProxy; break; case 11: //case OdGe::kCircArc3d: // to regenerate DbArc in m_dbEntIds // budweiser2013.dwg pCurve3d = new OdGeCircArc3d(); if (OdGeDwgIO::inFields(pFiler, *(OdGeCircArc3d*) pCurve3d.get()) != eOk) return eMakeMeProxy; break; case 42: //case OdGe::kNurbCurve3d: // to regenerate DbSpline in m_dbEntIds // budweiser2013.dwg x12fa8 // TODO move kSpunSurface and kSegmentChain2d to end of enum // via pCurve3d = new OdGeNurbCurve3d(); if (OdGeDwgIO::inFields(pFiler, *(OdGeNurbCurve3d*) pCurve3d.get()) != eOk) return eMakeMeProxy; break; case 19: //case OdGe::kLine3d: // to regenerate DbLine in m_dbEntIds pCurve3d = new OdGeLine3d(); if (OdGeDwgIO::inFields(pFiler, *(OdGeLine3d*) pCurve3d.get()) != eOk) return eMakeMeProxy; break; case 47: pCurve3d = new OdGeCompositeCurve3d(); if (OdGeDwgIO::inFields(pFiler, *(OdGeCompositeCurve3d*) pCurve3d.get() ) != eOk) return eMakeMeProxy; break; default: ODA_FAIL_ONCE(); // TODO return eNotImplementedYet; } m_edgeRef = OdDbEdgeRef(pCurve3d); } return eOk; } void OdDbImpAssocEdgeActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocSingleDependencyActionParam::dwgOutFields(pFiler, objectId); int ver = 0; pFiler->wrInt32(ver); pFiler->wrSoftPointerId( m_UnkownId ); bool bHasGeometry = !m_edgeRef.isEmpty(); pFiler->wrBool( bHasGeometry ); if (bHasGeometry) { OdInt32 entId = m_edgeRef.curve()->type(); pFiler->wrInt32( entId ); switch (entId) { case 23: //case OdGe::kLineSeg3d: // to regenerate DbLine in m_dbEntIds OdGeDwgIO::outFields(pFiler, *(OdGeLineSeg3d*) m_edgeRef.curve()); break; case 17: //case OdGe::kEllipArc3d: // to regenerate DbEllipse in m_dbEntIds // x3a8 OdGeDwgIO::outFields(pFiler, *(OdGeEllipArc3d*) m_edgeRef.curve()); break; case 11: //case OdGe::kCircArc3d: // to regenerate DbArc in m_dbEntIds // budweiser2013.dwg OdGeDwgIO::outFields(pFiler, *(OdGeCircArc3d*) m_edgeRef.curve()); break; case 42: //case OdGe::kNurbCurve3d: // to regenerate DbSpline in m_dbEntIds // budweiser2013.dwg x12fa8 // TODO move kSpunSurface and kSegmentChain2d to end of enum // via OdGeDwgIO::outFields(pFiler, *(OdGeNurbCurve3d*) m_edgeRef.curve()); break; case 19: //case OdGe::kNurbCurve3d: // to regenerate DbSpline in m_dbEntIds // budweiser2013.dwg x12fa8 OdGeDwgIO::outFields(pFiler, *(OdGeLine3d*) m_edgeRef.curve()); break; case 47: OdGeDwgIO::outFields(pFiler, *(OdGeCompositeCurve3d*) m_edgeRef.curve()); break; default: ODA_FAIL_ONCE(); // TODO throw OdError(eNotImplementedYet); } } } OdResult OdDbImpAssocEdgeActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocSingleDependencyActionParam::dxfInFields(pFiler, objectId); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocEdgeActionParam::desc()->name())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) OdInt32 ver = pFiler->rdInt32(); if (ver) { ODA_FAIL_ONCE(); // TODO return eMakeMeProxy; } NEXT_CODE(330) m_UnkownId = pFiler->rdObjectId(); NEXT_CODE(290) if (!pFiler->rdBool()) { m_edgeRef.reset(); } else { NEXT_CODE(90) OdUInt32 entId = pFiler->rdUInt32(); OdSharedPtr pCurve3d; switch (entId) { case 23: //case OdGe::kLineSeg3d: // to regenerate DbLine in m_dbEntIds pCurve3d = new OdGeLineSeg3d(); if (OdGeDxfIO::inFields(pFiler, *(OdGeLineSeg3d*)pCurve3d.get()) != eOk) return eMakeMeProxy; break; case 17: //case OdGe::kEllipArc3d: // to regenerate DbEllipse in m_dbEntIds // x3a8 pCurve3d = new OdGeEllipArc3d(); if (OdGeDxfIO::inFields(pFiler, *(OdGeEllipArc3d*)pCurve3d.get()) != eOk) return eMakeMeProxy; break; case 11: //case OdGe::kCircArc3d: // to regenerate DbArc in m_dbEntIds // budweiser2013.dwg pCurve3d = new OdGeCircArc3d(); if (OdGeDxfIO::inFields(pFiler, *(OdGeCircArc3d*)pCurve3d.get()) != eOk) return eMakeMeProxy; break; case 42: //case OdGe::kNurbCurve3d: // to regenerate DbSpline in m_dbEntIds // budweiser2013.dwg x12fa8 // TODO move kSpunSurface and kSegmentChain2d to end of enum // via pCurve3d = new OdGeNurbCurve3d(); if (OdGeDxfIO::inFields(pFiler, *(OdGeNurbCurve3d*)pCurve3d.get()) != eOk) return eMakeMeProxy; break; case 19: //case OdGe::kLine3d: // to regenerate DbLine in m_dbEntIds pCurve3d = new OdGeLine3d(); if (OdGeDxfIO::inFields(pFiler, *(OdGeLine3d*)pCurve3d.get()) != eOk) return eMakeMeProxy; break; case 47: pCurve3d = new OdGeCompositeCurve3d(); if (OdGeDxfIO::inFields(pFiler, *(OdGeCompositeCurve3d*)pCurve3d.get()) != eOk) return eMakeMeProxy; break; default: ODA_FAIL_ONCE(); // TODO return eNotImplementedYet; } m_edgeRef = OdDbEdgeRef(pCurve3d); } ODA_ASSERT_ONCE(pFiler->atEOF()); // TODO return eOk; } void OdDbImpAssocEdgeActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocSingleDependencyActionParam::dxfOutFields(pFiler, objectId); pFiler->wrSubclassMarker(OdDbAssocEdgeActionParam::desc()->name()); OdInt32 ver = 0; pFiler->wrInt32(90, ver); pFiler->wrObjectId( 330, m_UnkownId ); bool bHasGeometry = !m_edgeRef.isEmpty(); pFiler->wrBool( 290, bHasGeometry ); if (bHasGeometry) { OdInt32 entId = m_edgeRef.curve()->type(); pFiler->wrUInt32(90, entId); switch (entId) { case 23: //case OdGe::kLineSeg3d: // to regenerate DbLine in m_dbEntIds OdGeDxfIO::outFields(pFiler, *(OdGeLineSeg3d*) m_edgeRef.curve()); break; case 17: //case OdGe::kEllipArc3d: // to regenerate DbEllipse in m_dbEntIds // x3a8 OdGeDxfIO::outFields(pFiler, *(OdGeEllipArc3d*) m_edgeRef.curve()); break; case 11: //case OdGe::kCircArc3d: // to regenerate DbArc in m_dbEntIds // budweiser2013.dwg OdGeDxfIO::outFields(pFiler, *(OdGeCircArc3d*) m_edgeRef.curve()); break; case 42: //case OdGe::kNurbCurve3d: // to regenerate DbSpline in m_dbEntIds // budweiser2013.dwg x12fa8 // TODO move kSpunSurface and kSegmentChain2d to end of enum // via OdGeDxfIO::outFields(pFiler, *(OdGeNurbCurve3d*) m_edgeRef.curve()); break; case 19: //case OdGe::kLine3d: // to regenerate DbLine in m_dbEntIds OdGeDxfIO::outFields(pFiler, *(OdGeLine3d*) m_edgeRef.curve()); break; case 47: OdGeDxfIO::outFields(pFiler, *(OdGeCompositeCurve3d*) m_edgeRef.curve()); break; default: ODA_FAIL_ONCE(); // TODO throw OdError(eNotImplementedYet); } } } OdStringArray CompareTwoCircArc3d(const OdGeCircArc3d& arc, const OdGeCircArc3d& arcToCompare)//type 11 { OdStringArray retArr; if (arc.center() != arcToCompare.center()) retArr.append(CS_NOT_CRITICAL);// TODO if (arc.normal() != arcToCompare.normal()) retArr.append(CS_NOT_CRITICAL);// TODO if (arc.normal() != arcToCompare.normal()) retArr.append(CS_NOT_CRITICAL);// TODO if (arc.normal() != arcToCompare.normal()) retArr.append(CS_NOT_CRITICAL);// TODO if (arc.radius() != arcToCompare.radius()) retArr.append(CS_NOT_CRITICAL);// TODO if (arc.startAng() != arcToCompare.startAng()) retArr.append(CS_NOT_CRITICAL);// TODO if (arc.endAng() != arcToCompare.endAng()) retArr.append(CS_NOT_CRITICAL);// TODO return retArr; } OdStringArray CompareTwoLineSeg3d(const OdGeLineSeg3d& line, const OdGeLineSeg3d& lineToCompare)//type 23 { OdStringArray retArr; if (line.startPoint() != lineToCompare.startPoint()) retArr.append(CS_NOT_CRITICAL);// TODO if (line.endPoint() - line.startPoint() != lineToCompare.endPoint() - lineToCompare.startPoint()) retArr.append(CS_NOT_CRITICAL);// TODO return retArr; } OdStringArray CompareTwoEllipArc3d(const OdGeEllipArc3d& ellArc, const OdGeEllipArc3d& ellArcToCompare)// type 17 { OdStringArray retArr; if (ellArc.center() != ellArcToCompare.center()) retArr.append(CS_NOT_CRITICAL);// TODO if (ellArc.majorAxis() != ellArcToCompare.majorAxis()) retArr.append(CS_NOT_CRITICAL);// TODO if (ellArc.minorAxis() != ellArcToCompare.minorAxis()) retArr.append(CS_NOT_CRITICAL);// TODO if (ellArc.majorRadius() != ellArcToCompare.majorRadius()) retArr.append(CS_NOT_CRITICAL);// TODO if (ellArc.minorRadius() != ellArcToCompare.minorRadius()) retArr.append(CS_NOT_CRITICAL);// TODO if (ellArc.startAng() != ellArcToCompare.startAng()) retArr.append(CS_NOT_CRITICAL);// TODO if (ellArc.endAng() != ellArcToCompare.endAng()) retArr.append(CS_NOT_CRITICAL);// TODO return retArr; } OdStringArray CompareTwoNurbCurve3d(const OdGeNurbCurve3d& spline, const OdGeNurbCurve3d& splineToCompare) // type 42 { OdStringArray retArr; int degree = 0; bool rational = false, periodic = false; OdGeKnotVector knots; OdGeDoubleArray weights; OdGePoint3dArray controlPoints; double tolKnot = knots.tolerance(); spline.getDefinitionData(degree, rational, periodic, knots, controlPoints, weights); int degree1 = 0; bool rational1 = false, periodic1 = false; OdGeKnotVector knots1; OdGeDoubleArray weights1; OdGePoint3dArray controlPoints1; double tolKnot1 = knots1.tolerance(); splineToCompare.getDefinitionData(degree1, rational1, periodic1, knots1, controlPoints1, weights1); //OdInt32 growSize = 8; // TODO // = knots.growLength(); //ODA_ASSERT_ONCE(growSize == 8); // test //growSize = 8; if (spline.evalMode() != splineToCompare.evalMode()) retArr.append(CS_NOT_CRITICAL);// TODO if (degree != degree1) retArr.append(CS_NOT_CRITICAL);// TODO if (tolKnot != tolKnot1) retArr.append(CS_NOT_CRITICAL);// TODO OdInt32 countKnots = knots.length(); OdInt32 countKnots1 = knots1.length(); if (countKnots != countKnots1) retArr.append(CS_DIFFERENT_PARAM_CRITICAL);// TODO else { OdInt32 idx = 0; for (; idx < countKnots; idx++) { double knot = knots[idx]; double knot1 = knots1[idx]; if (knot != knot1) retArr.append(CS_NOT_CRITICAL);// TODO } OdInt32 countWeights = weights.size(); OdInt32 countWeights1 = weights1.size(); if (countWeights != countWeights1) retArr.append(CS_DIFFERENT_PARAM_CRITICAL);// TODO else { for (idx = 0; idx < countWeights; idx++) { double weight = weights[idx]; // 1.000000 1.493825 ... 1.993101 1.000000 double weight1 = weights1[idx]; // 1.000000 1.493825 ... 1.993101 1.000000 if (weight != weight1) retArr.append(CS_NOT_CRITICAL);// TODO } OdInt32 countPoints = controlPoints.size(); OdInt32 countPoints1 = controlPoints1.size(); if (countPoints != countPoints1) retArr.append(CS_DIFFERENT_PARAM_CRITICAL);// TODO else { for (idx = 0; idx < countPoints; idx++) { OdGePoint3d pt = controlPoints[idx]; OdGePoint3d pt1 = controlPoints1[idx]; if (pt != pt1) retArr.append(CS_NOT_CRITICAL);// TODO } } } } return retArr; } OdStringArray CompareTwoLine3d(const OdGeLine3d& line, const OdGeLine3d& lineToCompare)//type 19 { OdStringArray retArr; if (line.pointOnLine() != lineToCompare.pointOnLine()) retArr.append(CS_NOT_CRITICAL);// TODO if (line.direction() != lineToCompare.direction()) retArr.append(CS_NOT_CRITICAL);// TODO return retArr; } OdStringArray OdDbImpAssocEdgeActionParam::compareWith(OdDbImpAssocActionParam *paramIDToCompare, OdDb::DwgVersion filerVersion /*OdDb::kDHL_CURRENT*/) const { OdStringArray retArr; OdDbImpAssocEdgeActionParam* pComparedParam = static_cast(paramIDToCompare); ODA_ASSERT(pComparedParam != NULL); if (NULL != pComparedParam) { retArr = OdDbImpAssocSingleDependencyActionParam::compareWith(paramIDToCompare, filerVersion /*OdDb::kDHL_CURRENT*/); if (m_UnkownId.isNull() != pComparedParam->m_UnkownId.isNull()) retArr.append(CS_DIFFERENT_PARAM_CRITICAL); else if (!m_UnkownId.isNull()) { OdDbObject* unknownObject = m_UnkownId.openObject().get(); OdDbObject* comparedUnknownObject = pComparedParam->m_UnkownId.openObject().get(); if (typeid(*unknownObject) != typeid(*comparedUnknownObject)) { retArr.append(CS_DIFFERENT_OBJECTS); //return retArr; } } if (m_edgeRef.isEmpty() != pComparedParam->m_edgeRef.isEmpty()) retArr.append(CS_NOT_CRITICAL);// TODO else { if (!m_edgeRef.isEmpty()) { if (m_edgeRef.curve()->type() != pComparedParam->m_edgeRef.curve()->type()) retArr.append(CS_DIFFERENT_PARAM_CRITICAL); switch (m_edgeRef.curve()->type()) { case 23: //case OdGe::kLineSeg3d: { OdStringArray retCompared = CompareTwoLineSeg3d(*(OdGeLineSeg3d*)m_edgeRef.curve(), *(OdGeLineSeg3d*)pComparedParam->m_edgeRef.curve()); retArr.append(retCompared); } break; case 17: //case OdGe::kEllipArc3d: { OdStringArray retCompared = CompareTwoEllipArc3d(*(OdGeEllipArc3d*)m_edgeRef.curve(), *(OdGeEllipArc3d*)pComparedParam->m_edgeRef.curve()); retArr.append(retCompared); } break; case 11: //case OdGe::kCircArc3d: { OdStringArray retCompared = CompareTwoCircArc3d(*(OdGeCircArc3d*)m_edgeRef.curve(), *(OdGeCircArc3d*)pComparedParam->m_edgeRef.curve()); retArr.append(retCompared); } break; case 42: //case OdGe::kNurbCurve3d: { OdStringArray retCompared = CompareTwoNurbCurve3d(*(OdGeNurbCurve3d*)m_edgeRef.curve(), *(OdGeNurbCurve3d*)pComparedParam->m_edgeRef.curve()); retArr.append(retCompared); } break; case 19: //case OdGe::kLine3d: { OdStringArray retCompared = CompareTwoLine3d(*(OdGeLine3d*)m_edgeRef.curve(), *(OdGeLine3d*)pComparedParam->m_edgeRef.curve()); retArr.append(retCompared); } break; case 47: { OdGeCompositeCurve3d curve = *(OdGeCompositeCurve3d*)m_edgeRef.curve(); OdGeCompositeCurve3d curveToCompare = *(OdGeCompositeCurve3d*)pComparedParam->m_edgeRef.curve(); const OdGeCurve3dPtrArray& curvelist = curve.getCurveList(); const OdGeCurve3dPtrArray& curvelistToCompare = curveToCompare.getCurveList(); if (curvelist.size() != curvelistToCompare.size()) retArr.append(CS_DIFFERENT_PARAM_CRITICAL); else { for (unsigned int i = 0; i < curvelist.size(); i++) { if (curvelist[i]->type() != curvelistToCompare[i]->type()) retArr.append(CS_NOT_CRITICAL);// TODO switch (curvelist[i]->type()) { case 11: //arc segment { ODA_ASSERT_ONCE(curvelist[i]->isKindOf(OdGe::kCircArc3d)); OdStringArray retCompared = CompareTwoCircArc3d(*(OdGeCircArc3d*)curvelist[i].get(), *(OdGeCircArc3d*)curvelistToCompare[i].get()); retArr.append(retCompared);// TODO } break; case 23://line segment ODA_ASSERT_ONCE(curvelist[i]->isKindOf(OdGe::kLineSeg3d)); { OdStringArray retCompared = CompareTwoLineSeg3d(*(OdGeLineSeg3d*)curvelist[i].get(), *(OdGeLineSeg3d*)curvelistToCompare[i].get()); retArr.append(retCompared); } break; default: ODA_FAIL_ONCE(); // TODO } } } } break; default: ODA_FAIL_ONCE(); // TODO throw OdError(eNotImplementedYet); } } } } return retArr; } OdResult OdDbImpAssocEdgeActionParam::getEdgeRef( OdArray& edgeRefs ) const { edgeRefs.push_back( m_edgeRef ); return eOk; } OdResult OdDbImpAssocEdgeActionParam::getEdgeRefEval(OdArray& edgeRefs) { OdResult res; OdDbCompoundObjectId compoundId; if ((res = getDependentOnCompoundObject(compoundId)) != eOk) return res; OdDbAssocGeomDependencyPtr pGeomDep; { OdDbObjectIdArray dependencyIds; res = getDependencies(true, true, dependencyIds); if (!dependencyIds.empty()) pGeomDep = OdDbAssocGeomDependency::cast(dependencyIds.last().openObject()); } if (pGeomDep.isNull()) return eNotApplicable; OdArray transientSubentIds; pGeomDep->getTransientSubentIds(transientSubentIds); if (transientSubentIds.isEmpty()) return eNotApplicable; OdGeCurve3dPtrArray edgeCurves; if ((res = pGeomDep->getEdgeSubentityGeometry(edgeCurves)) != eOk) return res; if (edgeCurves.isEmpty() || edgeCurves.size() != transientSubentIds.size()) return eNotApplicable; OdDbEdgeRef edgeRef(compoundId, transientSubentIds.first()); edgeRef.setCurve(edgeCurves.first()); edgeRefs.append(edgeRef); return eOk; } OdResult OdDbImpAssocEdgeActionParam::setEdgeRef( const OdDbEdgeRef& edgeRef, bool isReadDependency, bool isWriteDependency, int dependencyOrder, OdDbObjectId actionId ) { if ( isReadDependency || isWriteDependency ) createDependency(actionId, edgeRef.entity(), edgeRef.subentId(), isReadDependency, isWriteDependency, dependencyOrder); m_edgeRef = edgeRef; return eOk; } OdResult OdDbImpAssocEdgeActionParam::getDependentOnCompoundObject( OdDbCompoundObjectId& compoundId ) const { compoundId.setEmpty(); OdResult res; OdDbAssocDependencyPtr pDependency = OdDbAssocDependency::cast( m_DependencyId.openObject( OdDb::kForRead ) ); if ( pDependency.isNull() ) { return eOk; } OdDbCompoundObjectId cmpId; res = pDependency->getDependentOnCompoundObject( cmpId ); if ( eOk != res ) { return res; } compoundId = cmpId; return eOk; } OdResult OdDbImpAssocEdgeActionParam::setEdgeSubentityGeometry( const OdGeCurve3d* pNewEdgeCurve ) { m_edgeRef = OdDbEdgeRef(pNewEdgeCurve); return eOk; } OdResult OdDbImpAssocEdgeActionParam::setObject(OdDbObjectId actionId, const OdDbCompoundObjectId& object, bool isReadDependency /*= true*/, bool isWriteDependency /*= false*/) { ODA_VERIFY_ONCE(!actionId.isNull()); if (isReadDependency || isWriteDependency) { m_DependencyId = object.leafId(); } return eOk; } OdResult OdDbImpAssocEdgeActionParam::getObject(OdDbCompoundObjectId* /*idObject*/) const // TODO { //idObject->setEmpty(); //OdResult res; //OdDbAssocDependencyPtr pDependency = OdDbAssocDependency::cast(m_DependencyId.openObject(OdDb::kForRead)); //if (pDependency.isNull()) //{ // return eOk; //} //OdDbCompoundObjectIdPtr cmpId; //res = pDependency->getDependentOnCompoundObject(cmpId); //if (eOk != res) //{ // return res; //} //*idObject = *idObject; return eNotImplementedYet; } ////////////////////////////////////////////////////////////////////////// OdDbImpAssocPointRefActionParam::OdDbImpAssocPointRefActionParam() { } OdDbImpAssocPointRefActionParam::~OdDbImpAssocPointRefActionParam() { } OdResult OdDbImpAssocPointRefActionParam::calcMidPoint(const OdGeCurve3d* pGeCurve, OdGePoint3d& midPoint) { if (!pGeCurve) return eNullEdgeCurve; try { midPoint = pGeCurve->midPoint(); } catch (OdError& e) { return e.code(); } return eOk; } OdResult OdDbImpAssocPointRefActionParam::calcCenterPoint(const OdGeCurve3d* pGeCurve, OdGePoint3d& centerPoint) { if (!pGeCurve) return eNullEdgeCurve; if (pGeCurve->isKindOf(OdGe::kCircArc3d)) centerPoint = ((OdGeCircArc3d*)pGeCurve)->center(); else if (pGeCurve->isKindOf(OdGe::kEllipArc3d)) centerPoint = ((OdGeEllipArc3d*)pGeCurve)->center(); else return eInvalidInput; return eOk; } OdResult OdDbImpAssocPointRefActionParam::calcClosestPoint(const OdGeCurve3d* pGeCurve, const OdGePoint3d& pickPoint, const OdGeVector3d& vec, bool bIntOrApint, const OdGeTol& tol, OdGePoint3d& point) { point = OdGePoint3d::kOrigin; if (!pGeCurve) return eNullEdgeCurve; OdGeLine3d geLine3d(pickPoint, vec); OdSharedPtr pUnboundCurve; if (bIntOrApint) pUnboundCurve = getUnboundedCurveFrom(pGeCurve); const OdGeCurve3d* pCurve = pUnboundCurve.isNull() ? pGeCurve : pUnboundCurve.get(); OdGeCurveCurveInt3d curveIntersect(geLine3d, *pCurve, OdGeVector3d::kIdentity, tol); int n = curveIntersect.numIntPoints(); if (n <= 0) return eNotApplicable; int nPntIndx = 0; if (n > 1) { OdGePoint3d firstPnt = curveIntersect.intPoint(0); double smallestDist = firstPnt.distanceTo(pickPoint); for (int i = 1; i < n; i++) { OdGePoint3d curPnt = curveIntersect.intPoint(i); double dist = curPnt.distanceTo(pickPoint); if (dist < smallestDist) { smallestDist = dist; nPntIndx = i; } } } point = curveIntersect.intPoint(nPntIndx); return eOk; } OdResult OdDbImpAssocPointRefActionParam::calcParamAtPoint(const OdGeCurve3d* pGeCurve, const OdGePoint3d& pickPoint, bool bIntOrApint, const OdGeTol& tol, double& pParam) { pParam = 0.0; if (!pGeCurve) return eNullEdgeCurve; if (!pGeCurve->isKindOf(OdGe::kLineSeg3d)) { OdSharedPtr pUnboundCurve; if (bIntOrApint) pUnboundCurve = getUnboundedCurveFrom(pGeCurve); const OdGeCurve3d* pCurve = pUnboundCurve.isNull() ? pGeCurve : pUnboundCurve.get(); if (pCurve->isOn(pickPoint, tol)) { pParam = pCurve->paramOf(pickPoint, tol); return eOk; } return eNotApplicable; } pParam = pGeCurve->paramOf(pickPoint, tol); return eOk; } OdResult OdDbImpAssocPointRefActionParam::calcPointAtParam(const OdGeCurve3d* pGeCurve, double dParam, OdGePoint3d& pnt) { if (!pGeCurve) return eNullEdgeCurve; pnt = pGeCurve->evalPoint(dParam); return eOk; } OdResult OdDbImpAssocPointRefActionParam::calcExtendedIntPoint(const OdGeCurve3d* pGeCurve1, const OdGeCurve3d* pGeCurve2, double dParam, const OdGeTol&/* tol*/, OdGePoint3d& evalPnt) { OdDbCurve* dbCurve1(nullptr); OdDbCurve* dbCurve2(nullptr); OdDbCurve::createFromOdGeCurve(*pGeCurve1, dbCurve1); OdDbCurve::createFromOdGeCurve(*pGeCurve2, dbCurve2); OdDbCurvePtr pDbCurve1; OdDbCurvePtr pDbCurve2; pDbCurve1.attach(dbCurve1); pDbCurve2.attach(dbCurve2); if (!dbCurve1 || !dbCurve2) return eNotApplicable; OdGePoint3dArray pointArr; OdResult res = pDbCurve1->intersectWith(pDbCurve2.get(), OdDb::kExtendBoth, pointArr); if (res != eOk) return res; if (pointArr.isEmpty()) return eNotApplicable; if (pointArr.size() == 1) { evalPnt = pointArr.first(); } else if (pointArr.size() > 1) { OdGePoint3d intPnt; if (OdDbImpAssocPointRefActionParam::calcPointAtParam(pGeCurve1, dParam, intPnt) != eOk) return eNotApplicable;; evalPnt = pointArr.first(); double dMinDis = pointArr.first().distanceTo(intPnt); for (auto it = pointArr.begin() + 1; it != pointArr.end(); it++) { double dCurDis = it->distanceTo(intPnt); if (dCurDis < dMinDis) { dMinDis = dCurDis; evalPnt = *it; } } } return eOk; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// OdDbImpAssocOsnapPointRefActionParam::OdDbImpAssocOsnapPointRefActionParam() { m_usingInheritor = true; m_UnknownParam1 = 0; m_OsnapMode = (OdDb::OsnapMode)0; m_NearPointParam = -1; } OdDbImpAssocOsnapPointRefActionParam::~OdDbImpAssocOsnapPointRefActionParam() { } OdResult OdDbImpAssocOsnapPointRefActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocActionParam::dwgInFields(pFiler, objectId); if (res != eOk) return res; res = OdDbImpAssocCompoundActionParam::dwgInFields(pFiler, objectId); if (res != eOk) return res; m_UnknownParam1 = pFiler->rdInt16(); m_OsnapMode = (OdDb::OsnapMode)pFiler->rdInt8(); m_NearPointParam = pFiler->rdDouble(); return eOk; } void OdDbImpAssocOsnapPointRefActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocActionParam::dwgOutFields(pFiler, objectId); OdDbImpAssocCompoundActionParam::dwgOutFields(pFiler, objectId); pFiler->wrInt16(static_cast(m_UnknownParam1)); pFiler->wrInt8(static_cast(m_OsnapMode)); pFiler->wrDouble(m_NearPointParam); } OdResult OdDbImpAssocOsnapPointRefActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocActionParam::dxfInFields(pFiler, objectId); if (res != eOk) return res; res = OdDbImpAssocCompoundActionParam::dxfInFields(pFiler, objectId); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocOsnapPointRefActionParam::desc()->dxfName())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) m_UnknownParam1 = pFiler->rdInt32(); NEXT_CODE(90) m_OsnapMode = (OdDb::OsnapMode)pFiler->rdInt32(); NEXT_CODE(40) m_NearPointParam = pFiler->rdDouble(); ODA_ASSERT_ONCE(pFiler->atEOF()); return res; } void OdDbImpAssocOsnapPointRefActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocActionParam::dxfOutFields(pFiler, objectId); OdDbImpAssocCompoundActionParam::dxfOutFields(pFiler, objectId); pFiler->wrSubclassMarker(OdDbAssocOsnapPointRefActionParam::desc()->dxfName()); pFiler->wrInt32(90, m_UnknownParam1); pFiler->wrInt32(90, m_OsnapMode); pFiler->wrDouble(40, m_NearPointParam); } //TODO: AlexeyTyurin OdStringArray OdDbImpAssocOsnapPointRefActionParam::compareWith(OdDbImpAssocActionParam *paramIDToCompare, OdDb::DwgVersion /*filerVersion*/ /*OdDb::kDHL_CURRENT*/) const { OdStringArray retArr; OdDbImpAssocOsnapPointRefActionParam* pComparedParam = static_cast(paramIDToCompare); ODA_ASSERT(pComparedParam != NULL); if (NULL != pComparedParam) { if (m_sName.compare(pComparedParam->m_sName) != 0) retArr.append(CS_PARAM_NAME); } return retArr; } OdDbOsnapPointRefPtr OdDbImpAssocOsnapPointRefActionParam::asOsnapPointRef(const OdDbAssocOsnapPointRefActionParam* pSelf) const { OdResult res = eOk; OdDbOsnapPointRefPtr pRefPt; OdDbAssocActionParamPtr param = pSelf->paramAtIndex(0).safeOpenObject(); OdDbAssocGeomDependencyPtr pGeomDep; { OdDbObjectIdArray dependencyIds; res = param->getDependencies(true, true, dependencyIds); if (!dependencyIds.empty()) pGeomDep = dependencyIds.last().openObject(); } pRefPt = OdDbOsnapPointRef::createObject(); OdDb::OsnapMode osnapMode = pSelf->osnapMode(); double nearParam = pSelf->nearPointParam(); pRefPt->setOsnapType(osnapMode); pRefPt->setNearPointParam(nearParam); if (pGeomDep.get()) { OdDbCompoundObjectId compId1; res = pGeomDep->getDependentOnCompoundObject(compId1); OdDbObjectIdArray ids; res = compId1.getFullPath(ids); OdDbEntityPtr ent = ids.first().openObject(); if (ent.get()) { OdSmartPtr persSubentIdPE = ent; if (persSubentIdPE.get()) { OdArray subents; res = persSubentIdPE->getTransientSubentIds(ent, pGeomDep->persistentSubentId(), subents); if (subents.size()) { if (osnapMode == OdDb::kOsModeEnd && subents.first().type()==OdDb::kVertexSubentType) { switch (subents.first().index()) { case OdDbAssocCurvePersSubentIdPE::kStart: pRefPt->setOsnapType(OdDb::kOsModeStart); break; case OdDbAssocCurvePersSubentIdPE::kEnd: //pRefPt->setOsnapType(OdDb::kOsModeEnd); break; } } if (pSelf->anchorId().objectClass()->isDerivedFrom(OdDbViewport::desc())) ids.insertAt(0, pSelf->anchorId()); pRefPt->setIdPath(OdDbFullSubentPath(ids, subents.first())); } } } } else { if (param->isKindOf(OdDbAssocVertexActionParam::desc())) { OdDbAssocVertexActionParam* vertexParam = static_cast(param.get()); OdDbVertexRef vertexRef; res = vertexParam->getVertexRef(vertexRef); pRefPt->setPoint(vertexRef.point()); } else { ODA_ASSERT_ONCE(!!"unsupported class of assoc.action param"); res = eNotImplemented; } } if (res != eOk) throw OdError(res); return pRefPt; } OdResult OdDbImpAssocOsnapPointRefActionParam::evaluatePointOverride(OdGePoint3d& evalPnt) const { if (m_ActionParams.isEmpty()) return eNotApplicable; OdResult res = eNotApplicable; OdDb::OsnapMode osnapMode = this->osnapMode(); OdDbAssocActionParamPtr param = m_ActionParams[0].safeOpenObject(); if (param->isKindOf(OdDbAssocEdgeActionParam::desc())) { OdDbAssocEdgeActionParam* pEdgeActParam = OdDbAssocEdgeActionParam::cast(param); OdArray edgeRefs; pEdgeActParam->getEdgeRefEval(edgeRefs); if (edgeRefs.isEmpty()) return eNotApplicable; const OdGeCurve3d* pCurve = edgeRefs.first().curve(); if (!pCurve) return eNotApplicable; res = evaluateCurvePnt(pCurve, osnapMode, evalPnt); } else if (param->isKindOf(OdDbAssocVertexActionParam::desc())) { OdDbAssocVertexActionParam* pVertexActParam = OdDbAssocVertexActionParam::cast(param); OdArray vertexRefs; pVertexActParam->getVertexRefEval(vertexRefs); if (vertexRefs.isEmpty()) return eNotApplicable; evalPnt = vertexRefs.first().point(); res = eOk; } return res; } OdResult OdDbImpAssocOsnapPointRefActionParam::createInstanceAndPostToDatabase(const OdDbObjectId& bodyId, OdDb::OsnapMode osnapMode, const OdDbFullSubentPath& path, const OdGePoint3d& point, OdDbObjectId& paramId) { if (path.objectIds().isEmpty() || osnapMode == 0) return eInvalidInput; double pParam(-1.0); OdDbSubentId subEntId = path.subentId(); OdResult res = getTransientSubentId(osnapMode, point, path, subEntId, &pParam); if (res != eOk) return res; OdDbAssocActionBodyPtr pBody = bodyId.openObject(OdDb::kForWrite); if (pBody.isNull()) return eNullObjectPointer; OdDbAssocOsnapPointRefActionParamPtr pOsnapActParam = OdDbAssocOsnapPointRefActionParam::createObject(); if (osnapMode != 0) pOsnapActParam->setOsnapMode(osnapMode); paramId = pBody->database()->addOdDbObject(pOsnapActParam, pBody->parentAction()); int paramIndex; pBody->addParam(paramId, paramIndex); OdDbObjectPtr subActParam; OdDb::SubentType subEntType = subEntId.type(); if (subEntType == OdDb::kVertexSubentType) subActParam = OdDbAssocVertexActionParam::createObject(); else subActParam = OdDbAssocEdgeActionParam::createObject(); OdDbObjectId subParamId; subParamId = pBody->database()->addOdDbObject(subActParam, paramId); pOsnapActParam->addParam(subParamId, paramIndex); OdDbCompoundObjectId objCompId; objCompId.setFullPath(path.objectIds()); OdDbAssocVertexActionParamPtr pVertParam = OdDbAssocVertexActionParam::cast(subActParam); if (pVertParam) { OdDbVertexRef vertRef(objCompId, subEntId, point); pVertParam->setVertexRef(vertRef); } OdDbAssocEdgeActionParamPtr pEdgeParam = OdDbAssocEdgeActionParam::cast(subActParam); if (pEdgeParam) { OdDbEdgeRef edgeRef(objCompId, subEntId); OdDbEntityPtr edgeEnt = edgeRef.createEntity(); if (!edgeEnt.isNull() && edgeEnt->isKindOf(OdDbCurve::desc())) { OdGeCurve3d* pCurve(nullptr); if (OdDbCurve::cast(edgeEnt.get())->getOdGeCurve(pCurve) == eOk && pCurve) { std::unique_ptr curve(pCurve); edgeRef.setCurve(curve.get()); } } pEdgeParam->setEdgeRef(edgeRef); pOsnapActParam->setParam(pParam); } return eOk; } OdResult OdDbImpAssocOsnapPointRefActionParam::getTransientSubentId( OdDb::OsnapMode osnapMode, const OdGePoint3d& pickPoint, const OdDbFullSubentPath& path, OdDbSubentId& subEntId, double* pParam) { subEntId = OdDbSubentId(); if (path.objectIds().isEmpty()) return eInvalidInput; OdGePoint3d point = pickPoint; OdGeTol tol = getOsnapPointTol(osnapMode); bool bViewport = false; if (path.objectIds().size() > 1 && path.objectIds().first().objectClass()->isDerivedFrom(OdDbViewport::desc())) { bViewport = true; point.z = 0; } OdDbObjectId objId = path.objectIds().last(); OdDbEntityPtr pEnt = OdDbEntity::cast(objId.openObject()); if (pEnt.isNull()) return eInvalidInput; OdSmartPtr pPE = pEnt->isA()->getX(OdDbAssocPersSubentIdPE::desc()); if (pPE.isNull()) return eBadProtocolExtension; OdGeMatrix3d mTrans; if (!OdDbPointRef::calcTransform(path.objectIds(), mTrans)) return eWasErased; //Handling different bindings if (osnapMode <= OdDb::kOsModeStart && osnapMode != 0 && osnapMode != OdDb::kOsModeNode && osnapMode != OdDb::kOsModeIns && //osnapMode != OdDb::kOsModeNear && osnapMode != OdDb::kOsModePar ) { OdArray allEdgesIds; pPE->getAllSubentities(pEnt, OdDb::kEdgeSubentType, allEdgesIds); if (allEdgesIds.isEmpty()) return eInvalidInput; switch (osnapMode) { case OdDb::kOsModeEnd: { bool bFoundVert = false; for (auto itEdge : allEdgesIds) { if (bFoundVert) break; OdDbSubentId startVertexSubentId, endVertexSubentId; OdArray otherVertexSubentIds; pPE->getEdgeVertexSubentities(pEnt, itEdge, startVertexSubentId, endVertexSubentId, otherVertexSubentIds); OdArray vertSubEnts; vertSubEnts.append(startVertexSubentId); vertSubEnts.append(endVertexSubentId); vertSubEnts.append(otherVertexSubentIds); for (auto itSubEnt : vertSubEnts) { if (itSubEnt.type() == OdDb::kNullSubentType) continue; OdGePoint3d vertexPosition; if (pPE->getVertexSubentityGeometry(pEnt, itSubEnt, vertexPosition) == eOk) { vertexPosition.transformBy(mTrans); if (bViewport) vertexPosition.z = 0; if (vertexPosition.isEqualTo(point)) { bFoundVert = true; subEntId = itSubEnt; break; } } } } } break; case OdDb::kOsModeMid: case OdDb::kOsModeCen: { for (auto itEdge : allEdgesIds) { OdGeCurve3d* pEdgeCurve(nullptr); if (eOk != pPE->getEdgeSubentityGeometry(pEnt, itEdge, pEdgeCurve) || !pEdgeCurve) continue; std::unique_ptr edgeCurve(pEdgeCurve); OdGePoint3d snapPoint; OdResult res = eOk; if (osnapMode == OdDb::kOsModeMid) res = OdDbImpAssocPointRefActionParam::calcMidPoint(edgeCurve.get(), snapPoint); else res = OdDbImpAssocPointRefActionParam::calcCenterPoint(edgeCurve.get(), snapPoint); if (res != eOk) continue; snapPoint.transformBy(mTrans); if (bViewport) snapPoint.z = 0; if (!snapPoint.isEqualTo(point)) continue; OdDbEntityPtr pDbCurve; OdDbEntityPtr pSubEnt = pEnt->subentPtr(path); if (pSubEnt) pDbCurve = OdDbCurve::cast(pSubEnt); if (allEdgesIds.size() == 1 || osnapMode == OdDb::kOsModeMid || pDbCurve.isNull()) { subEntId = itEdge; break; } double dArcDbRadius(0); if (pDbCurve->isKindOf(OdDbCircle::desc())) dArcDbRadius = OdDbCircle::cast(pDbCurve)->radius(); else if (pDbCurve->isKindOf(OdDbArc::desc())) dArcDbRadius = OdDbArc::cast(pDbCurve)->radius(); else continue; double dArcGeRadius(0); bool bIsCircular(true); if (edgeCurve->isKindOf(OdGe::kCircArc3d)) dArcGeRadius = ((OdGeCircArc3d*)edgeCurve.get())->radius(); else if (edgeCurve->isKindOf(OdGe::kEllipArc3d)) { dArcGeRadius = ((OdGeEllipArc3d*)edgeCurve.get())->majorRadius(); bIsCircular = ((OdGeEllipArc3d*)edgeCurve.get())->isCircular(); } else continue; if (bIsCircular && OdEqual(dArcDbRadius, dArcGeRadius, tol.equalPoint())) { subEntId = itEdge; break; } } } break; default: { for (auto itEdge : allEdgesIds) { OdGeCurve3d* pEdgeCurve(nullptr); if (eOk != pPE->getEdgeSubentityGeometry(pEnt, itEdge, pEdgeCurve) || !pEdgeCurve) continue; std::unique_ptr edgeCurve(pEdgeCurve); edgeCurve->transformBy(mTrans); bool bIntOrApint(false); if (osnapMode == OdDb::kOsModeIntersec || osnapMode == OdDb::kOsModeApint) bIntOrApint = true; if (bViewport) { if (OdDbImpAssocPointRefActionParam::calcClosestPoint(edgeCurve.get(), pickPoint, OdGeVector3d::kZAxis, bIntOrApint, tol, point) == eOk) { subEntId = itEdge; if (pParam) OdDbImpAssocPointRefActionParam::calcParamAtPoint(edgeCurve.get(), point, bIntOrApint, tol, *pParam); break; } continue; } if (edgeCurve->isOn(point, tol)) { subEntId = itEdge; if (pParam) OdDbImpAssocPointRefActionParam::calcParamAtPoint(edgeCurve.get(), point, bIntOrApint, tol, *pParam); break; } } } break; } } else { if (osnapMode == OdDb::kOsModeIns || osnapMode == OdDb::kOsModeNode) { OdArray allVertexIds; pPE->getAllSubentities(pEnt, OdDb::kVertexSubentType, allVertexIds); if (allVertexIds.isEmpty()) return eInvalidInput; double dSmallestDist = 1.0e30; for (auto itVertId : allVertexIds) { if (itVertId.type() == OdDb::kNullSubentType) continue; OdGePoint3d vertexPosition; if (pPE->getVertexSubentityGeometry(pEnt, itVertId, vertexPosition) == eOk) { vertexPosition.transformBy(mTrans); if (bViewport) vertexPosition.z = 0; double dist = point.distanceTo(vertexPosition); if (dist < dSmallestDist) { subEntId = itVertId; dSmallestDist = dist; } } } } } return eOk; } OdResult OdDbImpAssocOsnapPointRefActionParam::evaluateCurvePnt(const OdGeCurve3d* pCurve, OdDb::OsnapMode osnapMode, OdGePoint3d& evalPnt) const { OdResult res = eNotApplicable; if (osnapMode == OdDb::kOsModeMid) res = OdDbImpAssocPointRefActionParam::calcMidPoint(pCurve, evalPnt); else if (osnapMode == OdDb::kOsModeCen) { if (pCurve->type() == OdGe::kCircArc3d) { evalPnt = static_cast(pCurve)->center(); res = eOk; } else if (pCurve->type() == OdGe::kEllipArc3d) { evalPnt = static_cast(pCurve)->center(); res = eOk; } } else if (osnapMode == OdDb::kOsModeNear || osnapMode == OdDb::kOsModeQuad) { double dParam = nearPointParam(); res = OdDbImpAssocPointRefActionParam::calcPointAtParam(pCurve, dParam, evalPnt); } else if (osnapMode == OdDb::kOsModePerp || osnapMode == OdDb::kOsModeTan) { OdDbAssocOsnapPointRefActionParamPtr otherOsnapActParam = m_AnchorId1.safeOpenObject(); if (otherOsnapActParam.isNull()) return eNotApplicable; double dParam = nearPointParam(); OdGePoint3d referencePoint; OdGePoint3d otherPnt; if (OdDbImpAssocPointRefActionParam::calcPointAtParam(pCurve, dParam, referencePoint) == eOk && otherOsnapActParam->evaluatePointOverride(otherPnt) == eOk) { res = calcTanOrPerpPoint(osnapMode, pCurve, referencePoint, otherPnt, evalPnt); } } else if (osnapMode == OdDb::kOsModeApint && m_ActionParams.size() > 1) { OdDbAssocEdgeActionParamPtr edgeParamSnd = m_ActionParams[1].safeOpenObject(); if (!edgeParamSnd.isNull()) { OdArray edgeRefsSnd; edgeParamSnd->getEdgeRefEval(edgeRefsSnd); if (edgeRefsSnd.isEmpty()) return eNotApplicable; const OdGeCurve3d* pCurveSnd = edgeRefsSnd.first().curve(); if (!pCurve) return eNotApplicable; double dParam = nearPointParam(); return OdDbImpAssocPointRefActionParam::calcExtendedIntPoint(pCurve, pCurveSnd, dParam, getOsnapPointTol(osnapMode), evalPnt); } } return res; } //------------------------------------------------------------------------------------------------------------------- // Replace: OdDbObjectId m_AssocViewRepHatchActionParam -> OdDbObjectIdArray m_ActionParams OdDbImpAssocPathActionParam::OdDbImpAssocPathActionParam() : m_UnknownPathActionParam1(0) { } OdDbImpAssocPathActionParam::~OdDbImpAssocPathActionParam() { } OdResult OdDbImpAssocPathActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocCompoundActionParam::dwgInFields(pFiler, objectId); if (res != eOk) return res; m_UnknownPathActionParam1 = pFiler->rdInt16(); // 0 return eOk; } void OdDbImpAssocPathActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocCompoundActionParam::dwgOutFields(pFiler, objectId); pFiler->wrInt16(OdInt16(m_UnknownPathActionParam1)); } OdResult OdDbImpAssocPathActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocCompoundActionParam::dxfInFields(pFiler, objectId); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocPathActionParam::desc()->name())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) m_UnknownPathActionParam1 = pFiler->rdInt32(); return eOk; } void OdDbImpAssocPathActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocCompoundActionParam::dxfOutFields(pFiler, objectId); pFiler->wrSubclassMarker(OdDbAssocPathActionParam::desc()->name()); pFiler->wrUInt32(90, m_UnknownPathActionParam1); } OdStringArray OdDbImpAssocPathActionParam::compareWith(OdDbImpAssocActionParam *paramIDToCompare, OdDb::DwgVersion filerVersion /*OdDb::kDHL_CURRENT*/) const { OdStringArray retArr; OdDbImpAssocPathActionParam* pComparedParam = dynamic_cast(paramIDToCompare); ODA_ASSERT(pComparedParam != NULL); if (NULL != pComparedParam) { retArr = OdDbImpAssocCompoundActionParam::compareWith(paramIDToCompare, filerVersion /*OdDb::kDHL_CURRENT*/); if (m_sName.compare(pComparedParam->m_sName) != 0) retArr.append(CS_PARAM_NAME); if (m_UnknownPathActionParam1 != pComparedParam->m_UnknownPathActionParam1) retArr.append(CS_DIFFERENT_PARAM_CRITICAL); } return retArr; } //------------------------------------------------------------------------------------------------------------------- OdDbImpAssocTrimmingPathActionParam::OdDbImpAssocTrimmingPathActionParam() { m_Unknown1 = 0; m_Unknown2 = 0; m_UnkVect.set(0., 0., -1.); m_Unknown3 = 0; } OdDbImpAssocTrimmingPathActionParam::~OdDbImpAssocTrimmingPathActionParam() { } OdResult OdDbImpAssocTrimmingPathActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocPathActionParam::dwgInFields(pFiler, objectId); if (res != eOk) return res; m_Unknown2 = pFiler->rdInt16(); // 0 m_UnkVect = pFiler->rdVector3d(); m_Unknown3 = pFiler->rdInt8(); // 0 return eOk; } void OdDbImpAssocTrimmingPathActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocPathActionParam::dwgOutFields(pFiler, objectId); pFiler->wrInt16(m_Unknown2); // 0 pFiler->wrVector3d(m_UnkVect); pFiler->wrInt8(m_Unknown3); // 0 } OdResult OdDbImpAssocTrimmingPathActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocPathActionParam::dxfInFields(pFiler, objectId); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocTrimmingPathActionParam::desc()->name())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90); m_Unknown2 = OdUInt16(pFiler->rdInt32()); NEXT_CODE(10); pFiler->rdVector3d(m_UnkVect); NEXT_CODE(90); m_Unknown3 = OdUInt8(pFiler->rdInt32()); return eOk; } void OdDbImpAssocTrimmingPathActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocPathActionParam::dxfOutFields(pFiler, objectId); pFiler->wrSubclassMarker(OdDbAssocTrimmingPathActionParam::desc()->name()); pFiler->wrUInt32(90, m_Unknown2); pFiler->wrVector3d(10, m_UnkVect); pFiler->wrUInt32(90, m_Unknown3); } OdStringArray OdDbImpAssocTrimmingPathActionParam::compareWith(OdDbImpAssocActionParam *paramIDToCompare, OdDb::DwgVersion filerVersion /*OdDb::kDHL_CURRENT*/) const { OdStringArray retArr; OdDbImpAssocTrimmingPathActionParam* pComparedParam = dynamic_cast(paramIDToCompare); ODA_ASSERT(pComparedParam != NULL); if (NULL != pComparedParam) { retArr = OdDbImpAssocPathActionParam::compareWith(paramIDToCompare, filerVersion /*OdDb::kDHL_CURRENT*/); if (m_Unknown2 != pComparedParam->m_Unknown2) retArr.append(CS_DIFFERENT_PARAM_CRITICAL); if (m_UnkVect != pComparedParam->m_UnkVect) retArr.append(CS_DIFFERENT_PARAM_CRITICAL); if (m_Unknown3 != pComparedParam->m_Unknown3) retArr.append(CS_DIFFERENT_PARAM_CRITICAL); } return retArr; } //------------------------------------------------------------------------------------------------------------------- OdDbImpAssocFaceActionParam::OdDbImpAssocFaceActionParam() : m_UnknownPathActionParam1(0), m_UnknownPathActionParam2(0) { m_pAsmBodyActionParam = new OdDbImpAssocAsmBodyActionParam(); } OdDbImpAssocFaceActionParam::~OdDbImpAssocFaceActionParam() { delete m_pAsmBodyActionParam; } OdResult OdDbImpAssocFaceActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { //OdResult res = OdDbImpAssocActionParam::dwgInFields(pFiler, objectId); //if (res != eOk) // return res; m_pAsmBodyActionParam->dwgInFields(pFiler, objectId); m_UnknownPathActionParam1 = pFiler->rdInt32(); m_UnknownPathActionParam2 = pFiler->rdInt32(); // 0 return eOk; } void OdDbImpAssocFaceActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { //OdDbImpAssocActionParam::dwgOutFields(pFiler, objectId); m_pAsmBodyActionParam->dwgOutFields(pFiler, objectId); pFiler->wrInt32(m_UnknownPathActionParam1); pFiler->wrInt32(m_UnknownPathActionParam2); } OdResult OdDbImpAssocFaceActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { //OdResult res = OdDbImpAssocActionParam::dxfInFields(pFiler, objectId); //if (res != eOk) // return res; OdResult res = m_pAsmBodyActionParam->dxfInFields(pFiler, objectId); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocFaceActionParam::desc()->name())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) m_UnknownPathActionParam1 = pFiler->rdUInt32(); NEXT_CODE(90) m_UnknownPathActionParam2 = pFiler->rdUInt32(); ODA_ASSERT_ONCE(pFiler->atEOF()); // TODO return eOk; } void OdDbImpAssocFaceActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { ///OdDbImpAssocActionParam::dxfOutFields(pFiler, objectId); m_pAsmBodyActionParam->dxfOutFields(pFiler, objectId); pFiler->wrSubclassMarker(OdDbAssocFaceActionParam::desc()->name()); pFiler->wrUInt32(90, m_UnknownPathActionParam1); pFiler->wrUInt32(90, m_UnknownPathActionParam2); } //------------------------------------------------------------------------------------------------------------------- OdDbImpAssocTrimmingBodyActionParam::OdDbImpAssocTrimmingBodyActionParam() { } OdDbImpAssocTrimmingBodyActionParam::~OdDbImpAssocTrimmingBodyActionParam() { } OdResult OdDbImpAssocTrimmingBodyActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocFaceActionParam::dwgInFields(pFiler, objectId); if (res != eOk) return res; m_unknownTrimmingBodyParam1 = static_cast(pFiler->rdInt32()); m_unknownTrimmingBodyParam2 = pFiler->rdInt8(); // 0 return eOk; } void OdDbImpAssocTrimmingBodyActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocFaceActionParam::dwgOutFields(pFiler, objectId); pFiler->wrInt32(m_unknownTrimmingBodyParam1); pFiler->wrInt8(m_unknownTrimmingBodyParam2); } OdResult OdDbImpAssocTrimmingBodyActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { OdResult res = OdDbImpAssocFaceActionParam::dxfInFields(pFiler, objectId); if (res != eOk) return res; if (!pFiler->atSubclassData(OdDbAssocTrimmingBodyActionParam::desc()->name())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) m_unknownTrimmingBodyParam1 = static_cast(pFiler->rdInt32()); NEXT_CODE(280) m_unknownTrimmingBodyParam2 = pFiler->rdInt8(); return eOk; } void OdDbImpAssocTrimmingBodyActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { OdDbImpAssocFaceActionParam::dxfOutFields(pFiler, objectId); pFiler->wrSubclassMarker(OdDbAssocTrimmingBodyActionParam::desc()->name()); pFiler->wrInt32(90, m_unknownTrimmingBodyParam1); pFiler->wrInt8(280, m_unknownTrimmingBodyParam2); } //------------------------------------------------------------------------------------------------------------------- OdDbImpAssocAsmBodyActionParam::OdDbImpAssocAsmBodyActionParam() : m_UnknownPathActionParam1(0) { m_pSingleDependencyActionParam = new OdDbImpAssocSingleDependencyActionParam(); } OdDbImpAssocAsmBodyActionParam::~OdDbImpAssocAsmBodyActionParam() { delete m_pSingleDependencyActionParam; } OdResult OdDbImpAssocAsmBodyActionParam::dwgInFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) { OdResult res = eNotImplemented; //res = OdDbImpAssocActionParam::dwgInFields(pFiler, objectId); //if (res != eOk) // return res; res = m_pSingleDependencyActionParam->dwgInFields(pFiler, objectId); m_UnknownPathActionParam1 = pFiler->rdInt32(); bool bReadEnt = pFiler->rdBool(); if (bReadEnt) { res = OdDbAcisIO::readAcisData(pFiler, m_pModelerGeom); } return res; } void OdDbImpAssocAsmBodyActionParam::dwgOutFields(OdDbDwgFiler* pFiler, OdDbObjectId objectId) const { //OdDbImpAssocActionParam::dwgOutFields(pFiler, objectId); m_pSingleDependencyActionParam->dwgOutFields(pFiler, objectId); pFiler->wrInt32(m_UnknownPathActionParam1); bool bWriteEnt = m_pModelerGeom.get() != NULL; pFiler->wrBool(bWriteEnt); if (bWriteEnt) { OdModelerGeometryPtr mGeom = m_pModelerGeom; OdDbAcisIO::writeAcisData(pFiler, mGeom); } } OdResult OdDbImpAssocAsmBodyActionParam::dxfInFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) { OdResult res = eNotImplemented; //res = OdDbImpAssocActionParam::dxfInFields(pFiler, objectId); //if (res != eOk) // return res; res = m_pSingleDependencyActionParam->dxfInFields(pFiler, objectId); if (!pFiler->atSubclassData(OdDbAssocAsmBodyActionParam::desc()->name())) { ODA_FAIL_ONCE(); return eMakeMeProxy; } NEXT_CODE(90) m_UnknownPathActionParam1 = pFiler->rdInt32(); NEXT_CODE(290) bool bReadEnt = pFiler->rdBool(); if (bReadEnt) { m_pModelerGeom = OdDbAcisIO::readAcisData(pFiler); } ODA_ASSERT_ONCE(pFiler->atEOF()); // TODO return eOk; } void OdDbImpAssocAsmBodyActionParam::dxfOutFields(OdDbDxfFiler* pFiler, OdDbObjectId objectId) const { //OdDbImpAssocActionParam::dxfOutFields(pFiler, objectId); m_pSingleDependencyActionParam->dxfOutFields(pFiler, objectId); pFiler->wrSubclassMarker(OdDbAssocAsmBodyActionParam::desc()->name()); pFiler->wrUInt32(90, m_UnknownPathActionParam1); bool bWriteEnt = m_pModelerGeom.get() != NULL; pFiler->wrBool(290, bWriteEnt); if (bWriteEnt) { OdModelerGeometryPtr mGeom = m_pModelerGeom; OdDbAcisIO::writeAcisData(pFiler, mGeom, false); } }