Title: Iterator with hybrid-cgal-simple-opencascade drops the opening cut on elements with a MappedRepresentation body · Issue #10049 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Iterator with hybrid-cgal-simple-opencascade drops the opening cut on elements with a MappedRepresentation body · Issue #10049 · IfcOpenShell/IfcOpenShell
X Title: Iterator with hybrid-cgal-simple-opencascade drops the opening cut on elements with a MappedRepresentation body · Issue #10049 · IfcOpenShell/IfcOpenShell
Description: Bug Description With hybrid-cgal-simple-opencascade (Bonsai's default geometry library) or cgal-simple, ifcopenshell.geom.iterator returns an empty shape for an element that has an opening and a MappedRepresentation body: 0 vertices, not...
Open Graph Description: Bug Description With hybrid-cgal-simple-opencascade (Bonsai's default geometry library) or cgal-simple, ifcopenshell.geom.iterator returns an empty shape for an element that has an opening and a Ma...
X Description: Bug Description With hybrid-cgal-simple-opencascade (Bonsai's default geometry library) or cgal-simple, ifcopenshell.geom.iterator returns an empty shape for an element that has an opening and ...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/10049
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Iterator with hybrid-cgal-simple-opencascade drops the opening cut on elements with a MappedRepresentation body","articleBody":"### Bug Description\n\nWith `hybrid-cgal-simple-opencascade` (Bonsai's default geometry library) or `cgal-simple`, `ifcopenshell.geom.iterator` returns an empty shape for an element that has an opening and a `MappedRepresentation` body: 0 vertices, nothing logged. Any typed occurrence whose body is mapped from its type is affected. `create_shape` with the same library cuts the opening correctly, and so does the iterator with `opencascade`, `cgal` or `hybrid-cgal-opencascade`. An element with the same box as a direct (unmapped) body also voids correctly.\n\nIn Bonsai this shows up as an element that disappears when you void it. For example, select a typed `IfcStair` and run:\n\n```python\nbpy.ops.bim.add_element(ifc_product=\"IfcFeatureElement\", ifc_class=\"IfcOpeningElement\", skip_dialog=True)\n```\n\nThe stair gets its `IfcRelVoidsElement`, then `tool.Geometry.reimport_element_representations` reloads it through the iterator and builds an empty mesh. Reopening the file goes through the same iterator.\n\n### Minimal reproduction\n\nThe script builds the file from scratch. It creates an `IfcFurnitureType` with a 2 × 1 × 1 m extruded box, an occurrence (mapped via `assign_type`, or with the same box assigned directly as a control) and a 0.5 m opening through the middle:\n\n\u003cdetails>\u003csummary>repro_mapped_opening.py\u003c/summary>\n\n```python\nimport multiprocessing\n\nimport numpy as np\nimport ifcopenshell\nimport ifcopenshell.api.context\nimport ifcopenshell.api.feature\nimport ifcopenshell.api.geometry\nimport ifcopenshell.api.project\nimport ifcopenshell.api.root\nimport ifcopenshell.api.type\nimport ifcopenshell.api.unit\nimport ifcopenshell.geom\nimport ifcopenshell.util.shape_builder\n\n\ndef run(mapped):\n f = ifcopenshell.api.project.create_file(version=\"IFC4\")\n ifcopenshell.api.root.create_entity(f, ifc_class=\"IfcProject\")\n ifcopenshell.api.unit.assign_unit(f)\n model = ifcopenshell.api.context.add_context(f, context_type=\"Model\")\n body = ifcopenshell.api.context.add_context(\n f, context_type=\"Model\", context_identifier=\"Body\", target_view=\"MODEL_VIEW\", parent=model\n )\n builder = ifcopenshell.util.shape_builder.ShapeBuilder(f)\n\n # A type with a 2 x 1 x 1 m box body. assign_type gives the occurrence a MappedRepresentation;\n # the control gives the occurrence the same box directly.\n element_type = ifcopenshell.api.root.create_entity(f, ifc_class=\"IfcFurnitureType\")\n box = builder.extrude(builder.rectangle(size=np.array((2.0, 1.0))), magnitude=1.0)\n ifcopenshell.api.geometry.assign_representation(f, element_type, builder.get_representation(body, [box]))\n element = ifcopenshell.api.root.create_entity(f, ifc_class=\"IfcFurniture\")\n ifcopenshell.api.geometry.edit_object_placement(f, product=element)\n if mapped:\n ifcopenshell.api.type.assign_type(f, related_objects=[element], relating_type=element_type)\n else:\n ifcopenshell.api.geometry.assign_representation(f, element, builder.get_representation(body, [box]))\n\n # A 0.5 m cube opening through the middle of the box.\n opening = ifcopenshell.api.root.create_entity(f, ifc_class=\"IfcOpeningElement\")\n cube = builder.extrude(builder.rectangle(size=np.array((0.5, 0.5))), magnitude=1.5, position=(0.75, 0.25, -0.25))\n ifcopenshell.api.geometry.assign_representation(f, opening, builder.get_representation(body, [cube]))\n ifcopenshell.api.geometry.edit_object_placement(f, product=opening)\n ifcopenshell.api.feature.add_feature(f, feature=opening, element=element)\n\n print(\"\\nBody:\", element.Representation.Representations[0].RepresentationType)\n print(f\"{'library':34} {'create_shape':>14} {'iterator':>14}\")\n settings = ifcopenshell.geom.settings()\n for library in (\"opencascade\", \"cgal\", \"cgal-simple\", \"hybrid-cgal-opencascade\", \"hybrid-cgal-simple-opencascade\"):\n results = []\n try:\n shape = ifcopenshell.geom.create_shape(settings, element, geometry_library=library)\n results.append(len(shape.geometry.verts) // 3)\n iterator = ifcopenshell.geom.iterator(\n settings, f, multiprocessing.cpu_count(), include=[element], geometry_library=library\n )\n assert iterator.initialize()\n results.append(len(iterator.get().geometry.verts) // 3)\n except Exception as e:\n results.append(f\"error: {e}\")\n print(f\"{library:34} \" + \" \".join(f\"{str(r):>14}\" for r in results))\n\n\nrun(mapped=True)\nrun(mapped=False)\n```\n\n\u003c/details>\n\nVertex counts (16 = the box with the hole cut through it). The output is identical on both builds tested:\n\n| library | mapped body, `create_shape` | mapped body, iterator | direct body, `create_shape` | direct body, iterator |\n|---|---|---|---|---|\n| `opencascade` | 16 | 16 | 16 | 16 |\n| `cgal` | 16 | 16 | 16 | 16 |\n| `cgal-simple` | 0 | 0 | 0 | 0 |\n| `hybrid-cgal-opencascade` | 16 | 16 | 16 | 16 |\n| `hybrid-cgal-simple-opencascade` | 16 | **0** | 16 | 16 |\n\nThe `cgal-simple` row is expected, since that kernel has no booleans. The bold cell is the bug: the hybrid kernel only fails to fall back to OCC when the body is mapped and the shape comes from the iterator.\n\nThe same thing happens with a typed `IfcStair` whose body is an `IfcPolygonalFaceSet` mapped from its type. It isn't specific to extrusions. Whether the opening has an `ObjectPlacement` doesn't matter, and neither do Bonsai's iterator settings (`weld-vertices`, `layerset-first`, `keep-bounding-boxes`, `context-ids`).\n\n### Where it seems to go wrong\n\nMy reading of the code at a298d34894 (v0.9.0). I haven't confirmed it with a debugger.\n\n- [`hybrid_kernel::convert`](https://github.com/IfcOpenShell/IfcOpenShell/blob/a298d34894/src/ifcgeom/hybrid_kernel.h#L51-L79) chooses a kernel by calling `mapping_->find_openings(item->instance)`. `create_shape` converts per product. For a mapped body, the iterator converts the shared representation once (the shape id comes back as the type's representation, `\u003crep>-openings-\u003cid>`, rather than the occurrence's mapped representation). So `find_openings` finds no openings, and the boolean-less `cgal-simple` kernel is allowed to convert the item.\n- Later, `converter.cpp` applies the occurrence's openings ([L161](https://github.com/IfcOpenShell/IfcOpenShell/blob/a298d34894/src/ifcgeom/converter.cpp#L161), [L203](https://github.com/IfcOpenShell/IfcOpenShell/blob/a298d34894/src/ifcgeom/converter.cpp#L203)). [`hybrid_kernel::convert_openings`](https://github.com/IfcOpenShell/IfcOpenShell/blob/a298d34894/src/ifcgeom/hybrid_kernel.h#L106-L129) finds no boolean-capable kernel that `accepts()` a `cgal-simple` shape and returns `false`.\n\nThe `@todo` at [hybrid_kernel.h L58-L63](https://github.com/IfcOpenShell/IfcOpenShell/blob/a298d34894/src/ifcgeom/hybrid_kernel.h#L58-L63) describes this situation (*\"this would fail later on in the find_openings() call, because we have a SimpleCgalShape which cannot be used on a kernel that supports booleans\"*). The direct-body case avoids it because there the item's instance can be looked up for openings.\n\n### Relation to fa4f53feeb / #9393\n\nfa4f53feeb (\"Check convert_openings() status flag\", the same change #9393 proposes) treats the `false` return as an error and keeps the unopened shape. On a build with that commit, I'd expect the element to come back **un-voided** instead of empty: still wrong, but it no longer vanishes. I haven't tested that build; both builds below predate it. So the remaining problem is that the opening is never cut with the default library. Possible directions, both untested:\n\n- In `hybrid_kernel::convert`, also treat an item as having openings when it's a mapped representation used by a product that has openings.\n- When no kernel accepts the shapes in `convert_openings`, convert the item again with the next boolean-capable kernel and cut it there.\n\n### Environment\n\n- Windows 10 x64\n- `ifcopenshell` 0.8.5 from PyPI, Python 3.12\n- `ifcopenshell` 0.9.1-6022a6d, as shipped with Bonsai in Blender 5.1.2 (v0.9.0 branch, before fa4f53feeb)\n\nThis issue (investigation, repro script and text) was prepared with the assistance of an AI coding tool and reviewed by me.\n","author":{"url":"https://github.com/theoryshaw","@type":"Person","name":"theoryshaw"},"datePublished":"2026-10-24T00:49:44Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/10049"}
| 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:6eb1437f-97f3-8516-a3f5-b8ddeb12d8b3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E878:2102E4:56B4F7:74D7CF:6B049ED0 |
| html-safe-nonce | deda432721a76fa8525b71fa4e11e8dbf262e178e3529fc30441c110fd25eb16 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODc4OjIxMDJFNDo1NkI0Rjc6NzREN0NGOjZCMDQ5RUQwIiwidmlzaXRvcl9pZCI6IjU0NTI1MjI3NTQyODcxMTU5ODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6db510a4650e9a1ed3fe077fe3d2b7a8664978e1bdaec853fbbcb8651f3245ab |
| hovercard-subject-tag | issue:6007671859 |
| 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/10049/issue_layout |
| twitter:image | https://opengraph.githubassets.com/16bc5e1259e6a2187e1709ccb0acaa4c3f2604f2bca33a30902b468db9fd8c2e/IfcOpenShell/IfcOpenShell/issues/10049 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/16bc5e1259e6a2187e1709ccb0acaa4c3f2604f2bca33a30902b468db9fd8c2e/IfcOpenShell/IfcOpenShell/issues/10049 |
| og:image:alt | Bug Description With hybrid-cgal-simple-opencascade (Bonsai's default geometry library) or cgal-simple, ifcopenshell.geom.iterator returns an empty shape for an element that has an opening and a Ma... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | theoryshaw |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9784b6f42e2d5eac4e394fa88cad134c0dc5b6662b4ff2787a1ed1ef5a96331d |
| 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 | 3fd14143b75b2af7b76bbd23b069867d091adfcc |
| 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