/////////////////////////////////////////////////////////////////////////////// // 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 "COdPowerTowerEntity.h" #include "EmbeddedASMEntPE.h" #include "OdAssocPowerTowerPersSubentIdPE.h" #include const int COdPowerTowerEntity::kVersion = 1; ODRX_DEFINE_MEMBERS_EX(COdPowerTowerEntity, // ClassName OdDbEntity, // ParentClass DBOBJECT_CONSTR, // DOCREATE OdDb::kDHL_CURRENT, // DwgVer OdDb::kMReleaseCurrent, // MaintVer 1025, // nProxyFlags (kEraseAllowed | kDisableProxyWarning) L"COdPowerTowerEntity", // DWG class name L"CODPOWERTOWERENTITY", // DxfName L"ExAssocNetwork", // AppName OdRx::kMTLoading | OdRx::kHistoryAware); COdPowerTowerEntity::COdPowerTowerEntity() { } COdPowerTowerEntity::~COdPowerTowerEntity() { } OdResult COdPowerTowerEntity::dwgInFields(OdDbDwgFiler* pFiler) { assertWriteEnabled(); OdDbEntity::dwgInFields(pFiler); OdInt32 ver = pFiler->rdInt32(); if (ver > kVersion) return eMakeMeProxy; m_basePnt = pFiler->rdPoint3d(); OdDbFiler::FilerType filerType = pFiler->filerType(); if (filerType != OdDbFiler::FilerType::kIdXlateFiler) { OdInt32 nGeomCount = pFiler->rdInt32(); for (OdInt32 n = 0; n < nGeomCount; n++) m_geom.append(OdDb3dSolid::createObject()); setEmbedded(); for (auto geom : m_geom) geom->dwgInFields(pFiler); subSetDatabaseDefaults(pFiler->database(), true); } return eOk; } void COdPowerTowerEntity::dwgOutFields(OdDbDwgFiler* pFiler) const { assertReadEnabled(); OdDbEntity::dwgOutFields(pFiler); pFiler->wrInt32(kVersion); pFiler->wrPoint3d(m_basePnt); OdDbFiler::FilerType filerType = pFiler->filerType(); if (filerType != OdDbFiler::FilerType::kIdXlateFiler) { pFiler->wrInt32(m_geom.size()); for (auto geom : m_geom) geom->dwgOutFields(pFiler); } } bool COdPowerTowerEntity::subWorldDraw(OdGiWorldDraw* pWd) const { assertReadEnabled(); OdGeMatrix3d matr = OdGeMatrix3d::translation(m_basePnt - OdGePoint3d::kOrigin); pWd->geometry().pushModelTransform(matr); for (auto geom : m_geom) geom->subWorldDraw(pWd); pWd->geometry().popModelTransform(); return true; } OdResult COdPowerTowerEntity::subTransformBy(const OdGeMatrix3d& xfm) { assertWriteEnabled(); m_basePnt.transformBy(xfm); return eOk; } void COdPowerTowerEntity::subSetDatabaseDefaults(OdDbDatabase* pDb, bool/* doSubents*/) { assertWriteEnabled(); for (auto geom : m_geom) geom->setDatabaseDefaults(pDb); } OdResult COdPowerTowerEntity::subGetOsnapPoints(OdDb::OsnapMode osnapMode, OdGsMarker gsSelectionMark, const OdGePoint3d& pickPoint, const OdGePoint3d& lastPoint, const OdGeMatrix3d& xWorldToEye, OdGePoint3dArray& snapPoints) const { assertReadEnabled(); for (auto geom : m_geom) geom->getOsnapPoints(osnapMode, gsSelectionMark, pickPoint, lastPoint, xWorldToEye, snapPoints); OdGeMatrix3d matr = OdGeMatrix3d::translation(m_basePnt - OdGePoint3d::kOrigin); for (auto& pnt : snapPoints) pnt.transformBy(matr); return eOk; } int COdPowerTowerEntity::getVersion() { return kVersion; } void COdPowerTowerEntity::setEmbedded() { assertWriteEnabled(); OdSmartPtr pPE = OdDb3dSolid::desc()->getX(OdDbEmbeddedASMEntPropsPE::desc()); if (!pPE.isNull()) { for (auto geom : m_geom) pPE->setIsEmbeddedEnt(geom); } } void COdPowerTowerEntity::createTowerGeometry() { assertWriteEnabled(); //Main column OdDb3dSolidPtr pMainCol = OdDb3dSolid::createObject(); pMainCol->createBox(100., 100., 8000.); pMainCol->transformBy(OdGeMatrix3d::translation(OdGePoint3d(0, 0, 4000) - OdGePoint3d::kOrigin)); m_geom.append(pMainCol); //beam OdDb3dSolidPtr pbeam1 = OdDb3dSolid::createObject(); pbeam1->createBox(100., 2000., 100.); pbeam1->transformBy(OdGeMatrix3d::translation(OdGePoint3d(0, 0, 8050) - OdGePoint3d::kOrigin)); m_geom.append(pbeam1); OdGeMatrix3d transforms[3] = { OdGeMatrix3d::translation(OdGePoint3d(0, 0, 8175) - OdGePoint3d::kOrigin), OdGeMatrix3d::translation(OdGePoint3d(0, 700, 8175) - OdGePoint3d::kOrigin), OdGeMatrix3d::translation(OdGePoint3d(0, -700, 8175) - OdGePoint3d::kOrigin) }; //insulators for (int i = 0; i < 3; i++) { OdDb3dSolidPtr pCyl = OdDb3dSolid::createObject(); pCyl->createFrustum(150, 15, 15, 15); pCyl->transformBy(transforms[i]); m_geom.append(pCyl); OdGePoint3d coneStartPnt(0, 0, 150); for (int j = 0; j < 3; j++) { OdGePoint3d conePnt = coneStartPnt + OdGeVector3d(0, 0, 1) * j * 100; OdGeMatrix3d coneTr = OdGeMatrix3d::translation(conePnt - OdGePoint3d::kOrigin); OdDb3dSolidPtr pCone = OdDb3dSolid::createObject(); pCone->createFrustum(150, 100, 100, 0); pCone->transformBy(transforms[i]); pCone->transformBy(coneTr); m_geom.append(pCone); } } setEmbedded(); }