Skip to content

Function to remove internal edges of 2D mesh #1195

Open
@bjarthur

Description

@bjarthur

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)
Image

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)
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions