Stream: helpdesk (published)

Topic: How to extract faces from a mesh?


view this post on Zulip Ahmed Salih (Feb 17 2023 at 18:21):

Hello guys!

I am really in need of help, since me asking on both Discourse and Slack has been unfruitful. I really want to use this package, it looks great. I have a case where I draw a single element:

using Meshes
using MeshViz
using GLMakie
using LinearAlgebra
using Statistics

grid = CartesianGrid(1,1,1)
display(viz(grid , showfacets = true, alpha=0.25))

image.png

And now I want to extract each face of the element - how do I do that?

view this post on Zulip Ahmed Salih (Feb 18 2023 at 07:36):

To my surprise, this is not possible at all in 3D see:

https://github.com/JuliaGeometry/Meshes.jl/issues/372

Just if anyone else needs to do something similar :)

view this post on Zulip Júlio Hoffimann (Feb 18 2023 at 13:42):

Try to ask in #meshes.jl the next time. We are not following all questions here. You can ask for the boundary of a hexahedron for example with boundary(hexa) to get a mesh with 6 faces. If your hexa is in a grid you can boundary(grid[1]) for example.

view this post on Zulip Júlio Hoffimann (Feb 18 2023 at 13:42):

The hexahedron is a 3D volume. The faces are 2D geometries that live on the boundary.

view this post on Zulip Júlio Hoffimann (Feb 18 2023 at 13:43):

Alternatively, you can try to use the topological relations to find out the índices of faces vertices edges etc.

view this post on Zulip Ahmed Salih (Feb 18 2023 at 15:09):

My bad!

I have not used Zulip that much, it did not occur to me that there were specific streams for each package.

Now I am testing what you mention:

I define:

grid = CartesianGrid(1,1,1)

Then I do:

boundary(grid[1])
6 SimpleMesh{3,Float64}
8 vertices
└─Point(0.0, 0.0, 0.0)
└─Point(1.0, 0.0, 0.0)
└─Point(1.0, 1.0, 0.0)
└─Point(0.0, 1.0, 0.0)
└─Point(0.0, 0.0, 1.0)
└─Point(1.0, 0.0, 1.0)
└─Point(1.0, 1.0, 1.0)
└─Point(0.0, 1.0, 1.0)
6 elements
└─Quadrangle(4, 3, 2, 1)
└─Quadrangle(6, 5, 1, 2)
└─Quadrangle(3, 7, 6, 2)
└─Quadrangle(4, 8, 7, 3)
└─Quadrangle(1, 5, 8, 4)
└─Quadrangle(6, 7, 8, 5)

Which thankfully is exactly what I want - thank you so much!

I hope you understand that my intention was never to be annoying asking so many places, but I tried both slack, discourse and on here - and only you were able to answer my question - thank you very much for that. I will spread the knowledge if I see a similar question in the future :)


Last updated: Dec 28 2024 at 04:38 UTC