EntityID dd::World::CloneEntity(EntityID entity, EntityID parent /* = 0 */) { int clone = CreateEntity(parent); for (auto pair : m_EntityComponents[entity]) { auto type = pair.first; auto component = std::shared_ptr<Component>(m_ComponentFactory.Copy(type, pair.second.get())); if (component != nullptr) { AddComponent(clone, type, component); } } auto itChildren = m_EntityChildren.find(entity); if (itChildren != m_EntityChildren.end()) { for (EntityID child : itChildren->second) { CloneEntity(child, clone); } } CommitEntity(clone); return clone; }
GoafDragJig::GoafDragJig( const AcDbObjectId objId, int pos ) : m_objId( objId ), m_pos( pos ) { m_pGoaf = Goaf::cast( CloneEntity( objId ) ); m_pGoaf->getPolygon( m_polygon ); }
TunnelDragJig::TunnelDragJig( const AcDbObjectId objId ) : m_objId( objId ) { m_pWS = Tunnel::cast( CloneEntity( objId ) ); m_pWS->getSEPoint( spt, ept ); }