Skip to content

fix(IfcImporter): add vertex key to geometry dedup hash#238

Draft
ShaMan123 wants to merge 2 commits into
ThatOpen:mainfrom
ShaMan123:fix/geometry-vertex-dedup-hash#237
Draft

fix(IfcImporter): add vertex key to geometry dedup hash#238
ShaMan123 wants to merge 2 commits into
ThatOpen:mainfrom
ShaMan123:fix/geometry-vertex-dedup-hash#237

Conversation

@ShaMan123

@ShaMan123 ShaMan123 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

closes #237

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following:

  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Follow the Conventional Commits v1.0.0 standard for PR naming (e.g. feat(examples): add hello-world example).
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@ShaMan123

Copy link
Copy Markdown
Contributor Author

The issue references an concise ifc repro fixture that can be used as a test case (once vitest is in)

@ShaMan123 ShaMan123 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vertex key construction is Claude's suggestion.

@ShaMan123

Copy link
Copy Markdown
Contributor Author

Actually I am not sure this is a correct fix.
This doesn't cover cases that are geometrically the same with differently ordered vertices.

@ShaMan123 ShaMan123 closed this Jul 7, 2026
@ShaMan123 ShaMan123 reopened this Jul 7, 2026
@ShaMan123
ShaMan123 marked this pull request as draft July 7, 2026 10:40
@agviegas

Copy link
Copy Markdown
Contributor

Great repro, it makes the problem obvious: both plates share outline, area, volume and centroid, and the only difference is where the holes sit, which is exactly what the old key never looked at.

Direction is right. One thing to fix first: the vertexKey sum can cancel. JS % keeps the sign of the dividend, so h goes negative for negative coordinates and stays signed through the mixing. Summed commutatively, two vertices whose hashes are exact negatives cancel to zero and drop out of the key. The final if (vertexKey < 0) only fixes the sign of the result, not the cancellation. Normalize each h first:

let h = Math.round(position[i] * p) % MODULUS;
if (h < 0) h += MODULUS;

And a question: does the key need to be order-invariant at all? The commutative sum buys a match on a permuted buffer but costs collision resistance, where an ordered polynomial hash is stronger and simpler. Do we actually see web-ifc emit permuted duplicates? If not, I'd take the ordered one.

Minor: the AABB doesn't separate your two plates (same outline, same box), so vertexKey is carrying the fix alone. Fine to keep the corners, just noting what's load-bearing.

The #237 repro would make a good regression test. Still a draft, what's left on your side?

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.

IfcFileReader#loadShellGeometry WRONG geometry deduplication

2 participants