Skip to content

Clash detection: visit each pair of overlapping selections once - #152

Merged
mahach666 merged 1 commit into
IOExtend:mainfrom
menes97:fix/clash-selection-pair-enumeration
Nov 12, 2026
Merged

mahach666 merged 1 commit into
IOExtend:mainfrom
menes97:fix/clash-selection-pair-enumeration

Conversation

@menes97

@menes97 menes97 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #16

RunCore took two selections with the same count and the same first mesh for one selection, and started each row at i + 1. So A={1,2} against B={1,3} found no clash. Overlapping selections, and every federated run, reported each unordered pair twice.

How it works now:

  • Identical selections (the same meshes in the same order, compared by reference) still start each row at i + 1. All vs All does the same work as before and allocates nothing.
  • Other selections: a pair (a, b) can only be visited twice when b is also in A and a is also in B. Both paths build two lookups, by mesh reference: the first index of each mesh in A, and the set of meshes in B. When a (at index i) is in B and b is in A at a lower index, the pair was already visited from b and is skipped. Memory stays linear in the selection sizes.
  • Federated runs: RunCoreMultiModel does the same, by reference, because mesh ids repeat across models. The existing same-mesh skip is unchanged.

I avoided a set of visited pairs, which the issue suggests, because it would hold about n²/2 entries for a large All-vs-All run.

Tests (ClashDetectiveTests):

  • ClashDetection_OverlappingSelectionsReportsEachPairOnce: A={1,2} vs B={1,3} and A={1,2} vs B={1,2,3}, single-document and federated.
  • AssemblyClashDetection_AllVsAllPreservesPairsWithRepeatedMeshIds: models that reuse mesh ids.

3 cases fail without the src change: one finds no pairs, two report (1,2) twice. The existing federated tests still pass. dotnet build NwcIO.slnx succeeds, and NwcIO.Tests passes locally: 244 passed, and 2 skipped because they need private Navisworks files (.NET 10.0.400 on Windows, with global.json pinned down to it temporarily; not committed).

The change was drafted with OpenAI Codex, then reviewed and verified with Claude Code.

🤖 Generated with Claude Code

RunCore took two selections with the same first mesh for the same
selection and started each row at i + 1, so A = {1,2} against B = {1,3}
found no clash, while overlapping selections (and every federated run)
reported each pair twice. Identical selections, compared by reference,
still start at i + 1; otherwise a pair is skipped when it was already
visited from an earlier mesh of A, using a first-index lookup of A and
the set of meshes in B, so memory stays linear in the selections.

Fixes IOExtend#16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mahach666
mahach666 merged commit c42d9b6 into IOExtend:main Nov 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clash detector drops valid pairs for same-size selections and reports mirrored duplicates (overlapping selections, federated All-vs-All)

2 participants