Repository navigation
Clip transformed meshes against section planes in world space - #147
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #58
NwcMeshClipper.Cliptested the mesh's local vertices against section planes given in world space, and kept the originalTransformon the result. A translated or rotated mesh was therefore cut in the wrong place. This affects the IFC export withSectionPlanes/SectionBoxandClipGeometryWithSectionPlanes.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 positionx = M·l + t, using the same matrix asGetWorldVertices, the planen·x = dbecomes(Mᵀn)·l = d − n·t, normalized again. The result keeps its local vertices and itsTransform, so the IFC export withWorldCoordinates = falsestays consistent. If a transform yields a degenerate or non-finite plane, the plane is used unchanged, the same fallbackGetWorldVerticesuses for a transform it can't apply. Meshes without aTransformare 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 byCreateBottom(50)and removed byCreateTop(50). The kept triangle keeps itsTransform, 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.slnxsucceeds, andNwcIO.Testspasses locally: 241 passed, and 2 skipped because they need private Navisworks files (.NET 10.0.400 on Windows, withglobal.jsonpinned down to it temporarily; not committed).🤖 Generated with Claude Code