-
Notifications
You must be signed in to change notification settings - Fork 88
Support for constructive geometry #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @jondea thank you for proposing the primitive. I think what we really need is an API for constructive geometry. There are some packages out there already like implementing subtraction, intersection and union of primitives. Ideally, we will be able to introduce these same operations in Meshes.jl reusing our primitive types to avoid inefficiencies with type conversion, and to help new users who just want to load a single ecosystem to get things done quickly. |
Hi @juliohm, thank you for the pointers! That approach is certainly more elegant. I've made a branch with the |
All these boolean operations (union, difference, ...) in 2D can be
implemented in terms of a clipping algorithm. We have one clipping
algorithm implemented and two other algorithms in open PRs that still need
some work.
Em qui., 15 de mai. de 2025, 18:34, Ben Arthur ***@***.***>
escreveu:
… *bjarthur* left a comment (JuliaGeometry/Meshes.jl#251)
<#251 (comment)>
i see the "Intersection" part of the manual, but don't see a union method
anywhere. does it exist?
i ask because i have a mesh with overlapping quadrangles. would like to
simplify it. in the MWE below, there are two quadrangles, but there could
be just one ngon. how do i make it so? have tried simplify and repair to no
avail. in the more general case, i have an arbitrary number of quadrangles,
some of which might overlap, and others not. thx!
julia> using Meshes, GLMakie
julia> points1 = [(0,0), (2,0), (0,2), (2,2), (1,1), (1,3), (3,1), (3,3)];
julia> quads1 = connect.([(1,2,4,3), (5,6,8,7)], Quadrangle);
julia> mesh1 = SimpleMesh(points1, quads1)
2 SimpleMesh
8 vertices
├─ Point(x: 0.0 m, y: 0.0 m)
├─ Point(x: 2.0 m, y: 0.0 m)
├─ Point(x: 0.0 m, y: 2.0 m)
├─ Point(x: 2.0 m, y: 2.0 m)
├─ Point(x: 1.0 m, y: 1.0 m)
├─ Point(x: 1.0 m, y: 3.0 m)
├─ Point(x: 3.0 m, y: 1.0 m)
└─ Point(x: 3.0 m, y: 3.0 m)
2 elements
├─ Quadrangle(1, 2, 4, 3)
└─ Quadrangle(5, 6, 8, 7)
julia> viz(mesh1, color=:blue)
Screenshot.2025-05-15.at.5.32.23.PM.png (view on web)
<https://github.com/user-attachments/assets/0be88e06-13c8-480e-95af-5d30d6dafe8b>
—
Reply to this email directly, view it on GitHub
<#251 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZQW3LR6W5MV3KVQJGQIHD26UB75AVCNFSM6AAAAAB5HGNQXSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQOBVGEYDKNZZGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
so the idea is that if i create a second geometry which bounds both those quadrangles above, then i can use it to clip them and in the process they will be merged into a single geometry? just tried it and seemingly SutherlandHodgman can't input meshes:
|
Sorry, I was typing from my phone and wasn't clear enough in my previous comment. Some of these clipping algorithms allow the calculation of set operations, see https://dl.acm.org/doi/pdf/10.1145/274363.274364 In particular, we could finalize the PR #1125 and use the data structures therein to compute the union. The short answer for your question is that we don't currently support it. It is in the plans. |
As part of a FEM project I have implemented an
Annulus<:Primitive
type and several related functions. Does this count as a primitive, as in there isn't some clever way to make it from two balls? And if not, is this something that would be welcome for a PR?The text was updated successfully, but these errors were encountered: