FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Feat: Join coplanar SVG projection cells using normal vector evaluation by dipayansardar73-decode · Pull Request #7894 · IfcOpenShell/IfcOpenShell · GitHub

Feat: Join coplanar SVG projection cells using normal vector evaluation - #7894

Closed
dipayansardar73-decode wants to merge 5 commits into
IfcOpenShell:v0.8.0from
dipayansardar73-decode:fix-3742-coplanar-svg-projection-v3
Closed

Feat: Join coplanar SVG projection cells using normal vector evaluation#7894
dipayansardar73-decode wants to merge 5 commits into
IfcOpenShell:v0.8.0from
dipayansardar73-decode:fix-3742-coplanar-svg-projection-v3

Conversation

dipayansardar73-decode commented Apr 2, 2026
edited
Loading

Copy link
Copy Markdown

Resolves #3742

This PR addresses the issue where IfcOpenShell SVG outputs failed to join cells forming coplanar faces if they were angled relative to the projection.

The previous logic inside draw.py relied on identical ray_distance (depth). This fails on any surface that is non-orthogonal to the view frustum.

Implementation Details:

  1. Updated format(x) to extract x.position and x.normal instead of ray distance from the BRep queries.
  2. Replaced the scalar depth check with point-to-plane vector operations:
    • Verify parallel alignment using the dot product of both normals: numpy.dot(n1, n2)
    • Verify geometric coplanarity by taking the vector between both trace points against the normal: numpy.dot((p1 - p2), n1)

This ensures cells properly merge regardless of arbitrary projection angles.

dipayansardar73-decode changed the title Feat: Join coplanar SVG projection cells using normal vector evaluationFix #3742: Coplanar projection cell merger using point-to-plane physics Feat: Join coplanar SVG projection cells using normal vector evaluationFeat: Join coplanar SVG projection cells using normal vector evaluationFix #3742: Coplanar projection cell merger using point-to-plane physics Apr 2, 2026
dipayansardar73-decode changed the title Feat: Join coplanar SVG projection cells using normal vector evaluationFeat: Join coplanar SVG projection cells using normal vector evaluationFix #3742: Coplanar projection cell merger using point-to-plane physics Feat: Join coplanar SVG projection cells using normal vector evaluation Apr 2, 2026
dipayansardar73-decode changed the title Feat: Join coplanar SVG projection cells using normal vector evaluation Feat: Join coplanar SVG projection cells using normal vector evaluation Apr 2, 2026

Copy link
Copy Markdown
Member

@dipayansardar73-decode This is awesome, thank you.
Would it be possible to only join these coplanar surfaces if they share the same material?
If not, they should be separated.

Copy link
Copy Markdown
Author

@dipayansardar73-decode This is awesome, thank you. Would it be possible to only join these coplanar surfaces if they share the same material? If not, they should be separated.

@theoryshaw Yes, absolutely! That's a great point. I noticed the original logic only checked the instance class types but skipped over the materials entirely.
Since the underlying BRep query already exposes the style_index for the intersecting faces, it's very straightforward to add. I'll update the mathematical check to ensure that faces only merge if both their normals are perfectly coplanar and they share the exact same style_index.
I'll push the updated commit to this PR right away!

Copy link
Copy Markdown
Author

@theoryshaw Just pushed the update! It now checks style_index before merging. Does the logic in that commit look good to you, or is there another material attribute you'd prefer I check instead?

theoryshaw commented Apr 2, 2026
edited
Loading

Copy link
Copy Markdown
Member

I just tested and i couldn't get this to work.

I created some test files we can commonly use to test:
https://hub.openingdesign.com/OSArch/Community_Troubleshooting/src/branch/main/7894_Join%20coplanar%20SVG%20projection%20cells%20using%20normal%20vector%20evaluation

I think both materials and styles should play into when edges merge.

I'm thinking the following logic would be a good approach:
See red 'X' for conditions they should join.
If there's (2) different materials with the same style, i don't think they should join.
see the drawing called NORTH SECTION in the coplanar join.ifc file.

dipayansardar73-decode commented Apr 3, 2026
edited
Loading

Copy link
Copy Markdown
Author

I just tested and i couldn't get this to work.

I created some test files we can commonly use to test: https://hub.openingdesign.com/OSArch/Community_Troubleshooting/src/branch/main/7894_Join%20coplanar%20SVG%20projection%20cells%20using%20normal%20vector%20evaluation

@theoryshaw Ah, that makes perfect sense. Thank you for the detailed diagram and the test file. You are absolutely right—relying on the visual style_index alone is a drafting hazard. If two adjacent walls are made of Concrete and Plaster respectively, their physical material boundary line must remain visible on the drawing, even if an architect accidentally painted them both with the same grey visual style.

I have just pushed an extensive update to this PR to implement exactly the logic you asked for.

Copy link
Copy Markdown
Author

@theoryshaw

Implementation Details: I upgraded the pipeline inside draw.py to directly fetch and enforce real-world physical material boundaries during the SVG path merge.

  1. Modified the format(x) BRep payload to push the actual x.instance (the live IFC object) down into the vector looping engine.
  2. Implemented ifcopenshell.util.element.get_material(inst) to cross-reference the exact physical IfcMaterial driving both intersecting polygons.
  3. Added a highly optimized material_cache dictionary locally inside the sweep loop so we aren't repeatedly taxing the IFC graph by fetching materials for thousands of connected edges.
    Now, the engine strictly obeys your matrix rule. If the faces are perfectly coplanar and share the exact same style, it performs a final check on mat1.id() == mat2.id(). If they represent different structural materials, it aggressively preserves the separation line.

Could you re-run your coplanar join.ifc test file against this latest commit? It should map to your Red "X" Diagram completely now.

Copy link
Copy Markdown
Member

Hm, i couldn't get it to work.

Copy link
Copy Markdown
Author

Hm, i couldn't get it to work.

@theoryshaw
Thanks for taking a look at this. I ’ve spent a solid few hours today digging into why this isn't working as expected in the viewport, and I think I’ve found the root of the problem.

The issue isn't in the coplanar joining logic itself, but in how the drawing engine handles the material-to-style mapping. Currently, different materials (like your Concrete and Brick examples) are colliding and falling back to a single generic style because the CSS class names aren't being generated uniquely or accurately for each material.

Copy link
Copy Markdown
Author

@theoryshaw
I have successfully patched this locally with the following changes:

  1. Updated ifcopenshell.draw: To extract and sanitize material names into unique .mat-[MaterialName] and .material-[MaterialName] classes (preserving CamelCase for accuracy).
  2. Updated operator.py: To ensure these classes are actually injected into the viewport linework groups (generate_material_layers).
  3. Fallback Protection: Added a .no-material class to separate elements with no assignments from those that should have unique styles.

Copy link
Copy Markdown
Author

@theoryshaw
The reason it still looks grey in your screenshot is that the default default.css assets are lowercase (e.g., .material-concrete) while the engine is now producing CamelCase (e.g., .mat-Concrete). Since CSS is case-sensitive, they don't match.

I’ve been working on this for hours across both the Python engine and the Blender addon layers to get the mapping perfect. I'd love to hear your thoughts on standardizing these material classes so i can finally fix this 'Same Style' collision for everyone.

Copy link
Copy Markdown
Member

Hi @dipayansardar73-decode
I started vibe coding to help me understand your approach, as well as try to answer your questions... but I ended up coming up with another approach: #7908

Feel free to comment and review.

I would defer to an core maintainer on the ultimate pull.

Copy link
Copy Markdown
Author

@theoryshaw
I have been testing your PR locally and it's a massive improvement. Moving the merging to the SVG layer finally lets us join non-wall elements like actuators, which were previously skipped by the hardcoded checks. Your 3D adjacency check handles the coplanar cases perfectly.
I noticed the CI is failing on linting, but the code itself is rock solid. Thanks for the effort. Great Work !

Copy link
Copy Markdown
Member

Thank Claude. :)
Thank you for reviewing!

Copy link
Copy Markdown
Author

Thank Claude. :) Thank you for reviewing!

Haha! Claude is blushing 😂
Welcome :)

Copy link
Copy Markdown
Member

@dipayansardar73-decode okay to close this PR? If you have some other intent, please open again.

theoryshaw closed this Apr 6, 2026

dipayansardar73-decode commented Apr 8, 2026
edited
Loading

Copy link
Copy Markdown
Author

@dipayansardar73-decode okay to close this PR? If you have some other intent, please open again.

@theoryshaw Yes yes, that's perfectly fine 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Join projection planes that are coplanar.

2 participants


Back | FazBrowse Home | New Git URL