Commit Graph

128 Commits

Author SHA1 Message Date
Petru Conduraru 824c1fc280 ifcwrap: keep geometry's owning element alive to fix silent data corruption (#1124)
create_shape() returns a Python-owned Element (SWIG_POINTER_OWN in the
boost::variant out typemap). Its .geometry property calls Element::geometry(),
which returns a reference into the element's boost::shared_ptr<Representation>
_geometry member. SWIG wraps that reference as a non-owning pointer, so the
returned Triangulation/BRep/Serialization proxy does not keep the element alive.

When a caller keeps only .geometry (e.g. create_shape(s, e).geometry) and drops
the parent element, Python garbage-collects the element, destroying its
shared_ptr and freeing the underlying representation. Subsequent reads of
verts/faces then return freed memory: empty or implausible float/int garbage,
non-deterministically depending on GC and allocator timing. This is silent data
corruption, not a crash, and has bitten users since 2020.

Fix: in the TriangulationElement/SerializedElement/BRepElement pythoncode, wrap
the geometry getter so the returned geometry stores a backreference to its
owning element (result._parent = self). This makes the parent's lifetime at
least as long as the geometry's, automatically and transparently, so no caller
has to remember to hold the element. This is aothms's suggested backreference,
applied generically in the binding rather than left as a workaround.

Reproduced deterministically (washBasin fixture): before, verts len 0 vs 133500
across repeated GC-pressure runs; after, 133500 every run for all three element
types. test_create_shape passes; no regressions.

Note: tree.select_ray()'s ray_intersection_result (2024 follow-up in #1124) is a
separate ownership mechanism (std::vector element reference + std::array member
pointer) and is left as follow-up scope.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-19 10:04:48 +02:00
sboddy 97a85fe5a7 Merge pull request #8608 from sboddy/feature-svg-edge-classification-3668-4
Classify projection edges in SVG elevations (#3668)
2026-07-18 20:32:37 +01:00
Andrej730 b35f99e63f ty: detect unresolved references 2026-07-18 22:39:33 +05:00
Andrej730 f744753726 settings_mixin.build_parser: fix ty == "bool" typo, should be an assignment 2026-07-18 22:39:33 +05:00
Stephen Boddy 183e4c47f7 Add SVG edge classification on/off + render settings
Add svg-use-edge-classification (default off, preserving today's
linework), svg-render-crease-edges, and svg-render-sharp-edges
settings, gating the existing 5-class classification feature so it
can be disabled entirely (falling back to the pre-classification
whole-shape output) or have individual classes suppressed.

Also fixes a bug uncovered while wiring this into Bonsai: ready(),
where geometry_settings() actually gets read into the serializer,
was only ever invoked explicitly by IfcConvert's CLI driver and
isn't exposed to Python. Every Svg* setting -- including the three
from previous rounds -- silently stayed at its hardcoded constructor
default when the serializer was constructed directly through the
Python bindings, as Bonsai does. Fixed by calling ready() from
SvgSerializer's own constructor, safe since it only reads
geometry_settings() with no other side effects, and settings are
always finalized before construction in every call path.

Generated with the assistance of an AI coding tool.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-18 01:33:15 +01:00
Andrej730 9213b31235 logger: reuse logger_or_root, dedupe optional-logger-arg pattern 2026-07-16 17:28:24 +05:00
Andrej730 8a00ce84cc geom/main.py: fix ty complaint 2026-07-14 14:56:06 +05:00
Thomas Krijnen 6a6756de66 Bump binary versions in makefiles; add backwards compatibility to logger usage in python #8167 2026-06-15 09:56:36 +02:00
Thomas Krijnen ca99ef3af7 More changes to pass around logger to parse-related calls 2026-06-14 14:49:14 +02:00
Thomas Krijnen a7738eeb64 Pass around non-static logger instances and programmatic access to messages in-memory 2026-06-10 18:40:17 +02:00
Andrej730 26280d24fe Add ty to check for missing symbols and other simple errors 2026-03-20 15:36:14 +05:00
Andrej730 f2e2e324b1 Fixing stubs
- `function_item`, `tags` added in df7318973
- MakeVolume added in c385b93, ignore as all other conversion settings
- moved `SeparateZUpNode` ignore to the other geom serializer settings
2026-03-18 12:25:14 +05:00
Andrej730 eba798c544 typing 2026-03-13 20:26:22 +05:00
Andrej730 dfc91e6639 ifcopenshell-python - clean up unused imports 2026-01-16 17:16:24 +05:00
Andrej730 13be6ccd45 Sort imports 2025-12-19 18:53:14 +05:00
Thomas Krijnen 487a4f345d Creoox json serializer 2025-11-17 14:06:39 +01:00
Thomas Krijnen 6df5632f91 black 2025-10-26 13:33:10 +01:00
Thomas Krijnen b10415b1b3 Rework iterator constructor #7291 2025-10-26 13:31:31 +01:00
Thomas Krijnen 6ffcf363a6 Fix geom literals #6974 2025-08-06 10:49:45 +02:00
Andrej730 b97dca5d47 typing 2025-07-03 18:48:08 +05:00
Andrej730 68a602573b ifcopenshell.geom.iterator - more descriptive error in __init__ #6865 2025-07-02 18:14:34 +05:00
Thomas Krijnen bb329affb8 settings: DeferProcessingFirstElement, MaxOffset, MaxOffsetDeviation, ApplyOffset; taxonomy: centroid funcs; iterator get_tasks + items() funcs; geom.map_shape() 2025-07-01 21:10:24 +02:00
Andrej 02d359d0e6 Fix Ruff UP035 (also deprecated annotation symbols) 2025-06-09 18:03:19 +05:00
Andrej 3a66a1c754 geom settings - add new settings from 439f9c1 2025-06-05 19:05:27 +05:00
Andrej feebc701fa Fix Ruff UP008 (super-call-with-parameters)
https://docs.astral.sh/ruff/rules/super-call-with-parameters/
2025-05-28 18:24:13 +05:00
Andrej a42a95adcb Fix Ruff UP037 (quoted-annotation)
https://docs.astral.sh/ruff/rules/quoted-annotation/
2025-05-28 18:24:11 +05:00
Andrej730 29bd89324a ifcopenshell.geom.tree.get_clash_type 2025-05-23 18:42:55 +05:00
Andrej730 88befea174 typing 2025-05-23 18:42:55 +05:00
Andrej730 547506d626 black . 2025-03-31 19:10:20 +05:00
Thomas Krijnen 9254601924 Underscores in geom setting to argparse namespace 2025-03-28 12:11:27 +01:00
Thomas Krijnen 45c45d6862 ifcopenshell.geom.serializers.guess_from_extension() 2025-03-21 14:35:47 +01:00
Thomas Krijnen 6880e31a66 Add ColladaSerializer to python bindings 2025-03-21 14:35:23 +01:00
Thomas Krijnen 2a2bfea870 Read settings from argparser 2025-03-20 11:47:14 +01:00
Richard Brice 04e07db0a3 Import alignment from csv (#6234)
* Start of the official alignment API

* Import alignment into bonsai model using CSV file
2025-03-14 07:31:50 -07:00
Andrej730 9ba3b6a61f add cgal-original-edges option to settings (5599e52) 2025-03-14 18:19:08 +05:00
Dion Moult 5300f4c78f Fix failing tests 2025-01-28 10:54:37 +11:00
Dion Moult e29f686d3f Update setting literal from old name of "debug" to new name "debug-boolean". 2025-01-13 15:45:27 +11:00
Thomas Krijnen 9fa44fdc3c Setting rename 2024-12-29 15:53:07 +01:00
Andrej730 19c1394d94 typing 2024-12-27 19:43:29 +05:00
Andrej730 c5aad82e3d typing - add missing settings 2024-11-11 16:31:14 +05:00
Andrej730 09df81ab15 typing 2024-10-31 18:40:13 +05:00
Thomas Krijnen a4226369bd Update type literal 2024-10-07 20:48:58 +02:00
Andrej730 9131804e4e black . 2024-09-30 16:02:52 +05:00
Thomas Krijnen 314534436d Add .ttl + Well Known Text geometry serializer 2024-09-27 16:32:47 +02:00
Thomas Krijnen 2554280e50 triangulation-type setting for non-triangulated polyhedral from iterator 2024-09-18 19:28:07 +02:00
Andrej730 ea6df7f617 Use latest syntax for setting geometry settings #5299
Also fixed:
- old include_curves use
- missing use of 'include_curves' in ifcopenshell.draw
2024-09-05 15:08:35 +05:00
Andrej730 fcf41bf00c fix typing issue
Overloads were breaking because type checker is confused what default value should it use for the argument.
Made it keyword-only to resolve the issue.
2024-09-05 15:04:17 +05:00
Andrej730 1282f5c308 geom.Iterate - fix incorrect typing, document some arguments #5299 2024-09-04 18:51:07 +05:00
Andrej730 b0eaf23d2c Fix missing serializer_settings argument #5299 2024-09-04 18:51:07 +05:00
Thomas Krijnen 7e6607adcf black 2024-08-25 10:39:57 +02:00