JuliaGeometry/Meshes.jl

Function to remove internal edges of 2D mesh

Open

#1195 aperta il 16 mag 2025

Vedi su GitHub
 (11 commenti) (0 reazioni) (0 assegnatari)Julia (98 fork)auto 404
featurehelp wanted

Metriche repository

Star
 (460 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

is there a function to remove internal edges in a 2D mesh? say for example i have a mesh with two quadrangles which touch like this:

julia> using Meshes, GLMakie

julia> points1 = [(0,0), (1,0), (0,1), (1,1), (1,0), (2,0), (1,1), (2,1)];

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: 1.0 m, y: 0.0 m)
  ├─ Point(x: 0.0 m, y: 1.0 m)
  ├─ Point(x: 1.0 m, y: 1.0 m)
  ├─ Point(x: 1.0 m, y: 0.0 m)
  ├─ Point(x: 2.0 m, y: 0.0 m)
  ├─ Point(x: 1.0 m, y: 1.0 m)
  └─ Point(x: 2.0 m, y: 1.0 m)
  2 elements
  ├─ Quadrangle(1, 2, 4, 3)
  └─ Quadrangle(5, 6, 8, 7)

julia> viz(mesh1, showsegments=true)

i'd like to programmatically simplify this to a single quadrangle like this:

julia> points2 = [(0,0), (2,0), (0,1), (2,1)];

julia> quads2 = connect.([(1,2,4,3)], Quadrangle);

julia> mesh2 = SimpleMesh(points2, quads2)
1 SimpleMesh
  4 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: 1.0 m)
  └─ Point(x: 2.0 m, y: 1.0 m)
  1 elements
  └─ Quadrangle(1, 2, 4, 3)

julia> viz(mesh2, showsegments=true)

Guida contributor