mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-29 16:36:01 -05:00
* Cut: keep per-part filament colors after dovetail cut The dovetail path merged every model part of each half into one volume built from a raw mesh, dropping per-part extruder and material overrides, so the cut result fell back to the object-level extruder (T1). Merge by effective slicing identity (extruder, material, per-part config) instead, one merged volume per group, copying the representative's config and material. Connectors and modifiers are never merged or deleted, and single-group results keep today's single volume named after the object. Fixes #17187 * Fix missing includes * Cut: number extra parts and fix null material lookups Name the extra merged parts Object_2, Object_3, ... as splitting a mesh into parts does, instead of Object_T<extruder>, which misleads when the parts differ by material or by a per-part setting, and whose fallback suffix was not re-checked for uniqueness. Move the merged mesh into the new volume instead of copying it. add_cut_volume() dereferenced the source volume's material, but the cut model has no material table, so cutting a part that has a material id crashed before the merge could carry that id. Fall back to the material id alone, and let PrintObject skip a material's region settings when the material is missing rather than dereferencing null. * Cut: don't replace the source material while copying it add_cut_volume() carried the source volume's material with set_material(), and Model::add_material(id, other) deletes the existing material before copying from other. The source volume and the target object share the cut model, so the second copy of the same volume (the "_A" and "_B" halves of a groove cut) resolved that same material and replaced it with a copy of itself after deleting it, reading freed memory. A part with a material id segfaulted the cut before the merge could carry that id. Copy the material's settings only when the target model has no material of that id yet; otherwise just set the id and keep the existing one. * Cut: carry a part's material id and merge by effective settings The cut model holds no material settings, so add_cut_volume() only needs the id: copying the material there could only replace the source object's own entry, which Model::add_material() deletes before copying from it. Drop the unused duplicate of add_cut_volume() in Model.cpp as well. Group parts by the settings they slice with rather than by the keys they set explicitly: a part that restates a value the object already sets now stays with a part that leaves it implicit, instead of coming back as Object_2. * Model: keep a part's material when converting units ModelObject::convert_units() rebuilt a clone detached from its model and then called set_material() on it: the source volume's material was read without a check, and set_material() reached add_material() through the clone's null model. Any part with a material id crashed the conversion. Copy the id, pointing the clone at the source model for the call so the entry is recorded and its settings resolve after the conversion. set_material() has no callers left, so remove it. * Model tests: free the converted objects through a model ModelObject's destructor is private, so the tests cannot delete the objects convert_units() hands back. Give them to a Model, which owns model objects and frees them.
OrcaSlicer tests
Building, running and writing tests is documented on the wiki, under How to Test.
Two files here rather than there, because coding agents only read what is in the repository: