/////////////////////////////////////////////////////////////////////////////// // 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 "DbAssocSubentGeomCache.h" #include "Ge/GePoint3d.h" #include "Ge/GeCurve3d.h" #include "Ge/GeSurface.h" #include "OdError.h" #include "OdResult.h" OdDbAssocSubentGeomCache::OdDbAssocSubentGeomCache() : m_Ptr() , m_Type(kNone) , m_iCount(0) { } OdDbAssocSubentGeomCache::~OdDbAssocSubentGeomCache() { invalidate(); } void OdDbAssocSubentGeomCache::operator=(const OdDbAssocSubentGeomCache& /*other*/) { throw OdError(eNotImplementedYet); } OdResult OdDbAssocSubentGeomCache::dwgInFields(OdDbDwgFiler* /*pFiler*/) { return eMakeMeProxy; } OdResult OdDbAssocSubentGeomCache::dwgOutFields(OdDbDwgFiler* /*pFiler*/) const { return eNotImplementedYet; } OdResult OdDbAssocSubentGeomCache::dxfInFields(OdDbDxfFiler* /*pFiler*/) { return eMakeMeProxy; } OdResult OdDbAssocSubentGeomCache::dxfOutFields(OdDbDxfFiler* /*pFiler*/) const { return eNotImplementedYet; } bool OdDbAssocSubentGeomCache::getGeometry(Type& type, OdGePoint3d& point, const OdGeCurve3d*& curve,const OdGeSurface*& surface) const { switch (m_Type) { case kSurface: surface = m_Ptr.m_pSurf->get(); break; case kCurve3d: curve = m_Ptr.m_pCurve->get(); break; case kPoint3d: point = *m_Ptr.m_pPoint; break; case kNone: default: return false; } type = m_Type; return true; } void OdDbAssocSubentGeomCache::setGeometry(Type type, const OdGePoint3d& point, OdGeCurve3d* curve, OdGeSurface* surface) { invalidate(); m_Type = type; m_iCount = 1; switch (m_Type) { case kSurface: m_Ptr.m_pSurf = new std::unique_ptr(surface); break; case kCurve3d: m_Ptr.m_pCurve = new std::unique_ptr(curve); break; case kPoint3d: m_Ptr.m_pPoint = new OdGePoint3d(point); break; case kNone: default: m_Type = kNone; break; } } void OdDbAssocSubentGeomCache::invalidate() { switch (m_Type) { case kSurface: { std::unique_ptr* pSurf = m_Ptr.m_pSurf; for (unsigned int i = 0; i < m_iCount; ++i) { pSurf[i].reset(); } delete pSurf; } break; case kCurve3d: { std::unique_ptr* pCurve = m_Ptr.m_pCurve; for (unsigned int i = 0; i < m_iCount; ++i) { pCurve[i].reset(); } delete pCurve; } break; case kPoint3d: delete m_Ptr.m_pPoint; break; case kNone: default: break; } }