Title: Remove entity from file doesn't work well · Issue #208 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Remove entity from file doesn't work well · Issue #208 · IfcOpenShell/IfcOpenShell
X Title: Remove entity from file doesn't work well · Issue #208 · IfcOpenShell/IfcOpenShell
Description: I would like to remove some entities from an IFC file but I've encountered an issue with some entities. To sum up, let's consider this entity : #256= IFCPROPERTYSINGLEVALUE('Keyname',$,IFCINTEGER(3),$); From the file, I was able to get t...
Open Graph Description: I would like to remove some entities from an IFC file but I've encountered an issue with some entities. To sum up, let's consider this entity : #256= IFCPROPERTYSINGLEVALUE('Keyname',$,IFCINTEGER(3...
X Description: I would like to remove some entities from an IFC file but I've encountered an issue with some entities. To sum up, let's consider this entity : #256= IFCPROPERTYSINGLEVALUE('Keyname'...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/208
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Remove entity from file doesn't work well","articleBody":"I would like to remove some entities from an IFC file but I've encountered an issue with some entities. To sum up, let's consider this entity :\r\n\r\n`#256= IFCPROPERTYSINGLEVALUE('Keyname',$,IFCINTEGER(3),$);`\r\n\r\nFrom the file, I was able to get the associated object as `IfcUtil::IfcBaseClass*` and then called `file.removeEntity` on this object. The most part of the `removeEntity` function works well. However, near the end, the following lines throw an exception because of a `BOOST_ASSERT` :\r\n\r\n```\r\nIfcEntityList::ptr entity_attributes = traverse(entity, 1);\r\nfor (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {\r\n IfcUtil::IfcBaseClass* entity_attribute = *it;\r\n if (entity_attribute == entity) continue;\r\n entitiesByReference(entity_attribute->entity->id())->remove(entity);\r\n if (entitiesByReference(entity_attribute->entity->id())->filtered(weak_roots)->size() == 0) {\r\n deletion_queue.insert(entity_attribute);\r\n }\r\n}\r\n```\r\n\r\nThe first line creates a list of entity from attributes of the given entity. In this case, they are two entities in this list : the entity we want to remove and an entity based on `IfcInteger`. The first one is ignored by `if (entity_attribute == entity) continue;` but the second one isn't. The exception is thrown because of a bad use of `boost::shared_ptr` in `entitiesByReference(entity_attribute->entity->id())->remove(entity);` This issue appears because the entity based on `IfcInteger` isn't in the file by itself on a dedicated line (its id equals to 0).\r\n\r\nMy guess is `IfcEntityList::ptr()` isn't well initialized as it should be in :\r\n\r\n```\r\nIfcEntityList::ptr IfcFile::entitiesByReference(int t) {\r\n\tentities_by_ref_t::const_iterator it = byref.find(t);\r\n\treturn (it == byref.end()) ? IfcEntityList::ptr() : it->second;\r\n}\r\n```\r\n\r\nThere are several fix I can pull request to help you if necessary. It's possible to fix this issue at different levels : from the pointer initialization to the call of `entitiesByReference` on an entity obviously not in the file. I don't have enough knowledge on the IFCOpenShell code yet to know what is an acceptable fix and what can break almost everything. Let me know what do you think.","author":{"url":"https://github.com/FragColor","@type":"Person","name":"FragColor"},"datePublished":"2017-04-21T13:02:17Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/208"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:91f6a810-5ca0-63b6-f988-77180f75ac06 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A9C2:3C07AF:761BA2:A2326B:6B047999 |
| html-safe-nonce | 283d46f8605c1bdb5956baf4c3f8e798f0f5eac5256a190863c977869a324f6f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOUMyOjNDMDdBRjo3NjFCQTI6QTIzMjZCOjZCMDQ3OTk5IiwidmlzaXRvcl9pZCI6IjUzNjY0MjI0NzY5MTIwOTc2ODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 33c485c6ec6cfced1f797adb64258fed40366bf731086d00d6f3105d1580d582 |
| hovercard-subject-tag | issue:223376874 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/208/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e153506f8db68ea0c9ad15ac68c96c156f97801ca5b8e3d152be4306796dc549/IfcOpenShell/IfcOpenShell/issues/208 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e153506f8db68ea0c9ad15ac68c96c156f97801ca5b8e3d152be4306796dc549/IfcOpenShell/IfcOpenShell/issues/208 |
| og:image:alt | I would like to remove some entities from an IFC file but I've encountered an issue with some entities. To sum up, let's consider this entity : #256= IFCPROPERTYSINGLEVALUE('Keyname',$,IFCINTEGER(3... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | FragColor |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9c099f1b85def81ca352464c276510dfef32deaf3c305404e65b8d270284a58b |
| turbo-cache-control | no-preview |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cf73f57448d52b3a7b619195e182b33d3b3454ca |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width