Skip to content

Clip transformed meshes against section planes in world space - #147

Merged
mahach666 merged 1 commit into
IOExtend:mainfrom
menes97:fix/clipper-world-space
Nov 12, 2026
Merged

mahach666 merged 1 commit into
IOExtend:mainfrom
menes97:fix/clipper-world-space

Conversation

@menes97

@menes97 menes97 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #58

NwcMeshClipper.Clip tested the mesh's local vertices against section planes given in world space, and kept the original Transform on the result. A translated or rotated mesh was therefore cut in the wrong place. This affects the IFC export with SectionPlanes/SectionBox and ClipGeometryWithSectionPlanes.

I took the first option from the issue: when the mesh has a Transform, each active plane is mapped into the mesh's local space before the cut. For a world position x = M·l + t, using the same matrix as GetWorldVertices, the plane n·x = d becomes (Mᵀn)·l = d − n·t, normalized again. The result keeps its local vertices and its Transform, so the IFC export with WorldCoordinates = false stays consistent. If a transform yields a degenerate or non-finite plane, the plane is used unchanged, the same fallback GetWorldVertices uses for a transform it can't apply. Meshes without a Transform are clipped exactly as before.

Tests (SectioningTests):

  • NwcMeshClipper_Clip_TranslatedMesh_CutsInWorldSpace: the case from the issue. A triangle moved to world Z = 100 is kept whole by CreateBottom(50) and removed by CreateTop(50). The kept triangle keeps its Transform, and its world vertices are still at Z = 100.
  • NwcMeshClipper_Clip_RotatedMesh_CutsInWorldSpace: a quarter turn about Z plus a translation puts a triangle at world Y 2..4. CreateFront(3) keeps exactly its Y ≥ 3 part, with world vertices at Y = 3 and Y = 4.

Both fail without the change. dotnet build NwcIO.slnx succeeds, and NwcIO.Tests passes locally: 241 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).

🤖 Generated with Claude Code

NwcMeshClipper.Clip tested the local vertices against the world-space
section planes and kept the Transform, so a translated or rotated mesh
was cut in the wrong place (IFC export with section planes or a box,
for one). The planes are now mapped into the mesh's local space before
the cut, so the result keeps its local vertices and its Transform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mahach666
mahach666 merged commit c24a082 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.

NwcMeshClipper ignores mesh Transform and clips local-space vertices against world-space section planes

2 participants