Skip to content

Subshape order is not deterministic #37

@AntonReiswich

Description

@AntonReiswich

In GitLab by @klei_j0 on Feb 17, 2025, 20:45

It is possible to iterate the direct subshapes of a Shape. But the order of the subshapes is not necessarily consistent across multiple runs, if in each run the Shape is generated from a Shape::filter or Shape::select_subshapes call:

  • Internally, to detect duplicates, filter and select_subshapes manage the found shapes using an std::unordered_set, which uses a custom hash function that depends on the current memory address of a Shape's TopoDS_Shape's TShape. This memory address is bound to change across runs.
  • When returning a Shape from filter or select_subshapes the subshapes are stored in an ordered std::vector, but the ordering depends on the hash values of the elements in the std::unordered_set.

Ideally, we would use a hash function that is consistent across runs. I think I read that this is available in newer versions of OCCT (7.8?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions