/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// // ExLine.cpp: implementation of the Center Objects (CenterMark and Center Line) function. // ////////////////////////////////////////////////////////////////////// #include "StdAfx.h" #include "ExSelectionUtils.h" #include "Db3dProfile.h" #include "DbSurface.h" static void addEntityToDb(OdDbDatabase* pDb, OdDbEntity* pEntity) { OdDbBlockTableRecordPtr pMs = pDb->getModelSpaceId().safeOpenObject(OdDb::kForWrite); pMs->appendOdDbEntity(pEntity); } void _Network_func(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabasePtr pDb = pDbCmdCtx->database(); OdDbUserIO* pIO = pDbCmdCtx->dbUserIO(); OdDbSurfacePtr pCreatedNetSurface; OdDbSelectionSetPtr pSSet; OdGePoint3dArray ptsSelected; OdDbFullSubentPathArray uCurves, vCurves; OdDbFullSubentPath pathCurve; OdDbFullSubentPath path; // Select entities in U do { OdString strInvitation = uCurves.isEmpty() ? L"Select U cross section entities :" : L"Select U cross section entities or press ENTER to finish:"; if (uCurves.length() > 0) { const OdString strPrefics = OdString().format(OD_T("%d"), uCurves.length()) + L" entities selected. "; strInvitation = strPrefics + strInvitation; } path = selectedFullSubentPath(pIO, pDb, strInvitation, ptsSelected, pSSet); if (path.objectIds().length() > 0) { uCurves.append(path); } } while (path.objectIds().length() != 0); // Select entities in V do { OdString strInvitation = vCurves.isEmpty() ? L"Select V cross section entities :" : L"Select V cross section entities or press ENTER to finish:"; if (vCurves.length() > 0) { const OdString strPrefics = OdString().format(OD_T("%d"), vCurves.length()) + L" entities selected. "; strInvitation = strPrefics + strInvitation; } path = selectedFullSubentPath(pIO, pDb, strInvitation, ptsSelected, pSSet); if (path.objectIds().length() > 0) { vCurves.append(path); } } while (path.objectIds().length() != 0); if (uCurves.length() < 2 || vCurves.length() < 2) { return; } OdResult res(eGeneralModelingFailure); pDb->startTransaction(); OdArray uProfiles, vProfiles; OdString strMessage(L"Ready"); try { OdUInt32 f; for (f = 0; f < uCurves.size(); ++f) { OdDbCurvePtr pCurve = OdDbCurve::cast(uCurves[f].objectIds().last().safeOpenObject()); OdDb3dProfilePtr pNew = OdDb3dProfile::createObject(); pNew->set(pCurve); uProfiles.push_back(pNew); } for (f = 0; f < vCurves.size(); ++f) { OdDbCurvePtr pCurve = OdDbCurve::cast(vCurves[f].objectIds().last().safeOpenObject()); OdDb3dProfilePtr pNew = OdDb3dProfile::createObject(); pNew->set(pCurve); vProfiles.push_back(pNew); } res = OdDbSurface::createNetworkSurface(uProfiles, vProfiles, pCreatedNetSurface); if (res == eOk) { pCreatedNetSurface->setDatabaseDefaults(pDb); addEntityToDb(pDb, pCreatedNetSurface); } } catch (const OdError& err) { res = eInvalidInput; strMessage = L"Failed: "; strMessage += err.description(); } catch (...) { res = eInvalidInput; strMessage = L"Failed: Unknown error"; } if (res == eOk) { pDb->endTransaction(); } else { pDb->abortTransaction(); } pIO->putString(strMessage); }