How to get the vector of vertices and connectivity

Mizu49
Thu, 09 Jan 2025 03:37:04 +0000
General Usage

How can I obtain the vectors of the vertices and connectivity from the primitive geometry defined by Meshes.jl?

julia> b = Meshes.Box((0.0, 0.0, 0.0), (1.0, 1.0, 1.0))
Box
├─ min: Point(x: 0.0 m, y: 0.0 m, z: 0.0 m)
└─ max: Point(x: 1.0 m, y: 1.0 m, z: 1.0 m)

julia> b = discretize(b)
5 SimpleMesh
  8 vertices
  ├─ Point(x: 0.0 m, y: 0.0 m, z: 0.0 m)
  ├─ Point(x: 1.0 m, y: 0.0 m, z: 0.0 m)
  ├─ Point(x: 1.0 m, y: 1.0 m, z: 0.0 m)
  ├─ Point(x: 0.0 m, y: 1.0 m, z: 0.0 m)
  ├─ Point(x: 0.0 m, y: 0.0 m, z: 1.0 m)
  ├─ Point(x: 1.0 m, y: 0.0 m, z: 1.0 m)
  ├─ Point(x: 1.0 m, y: 1.0 m, z: 1.0 m)
  └─ Point(x: 0.0 m, y: 1.0 m, z: 1.0 m)
  5 elements
  ├─ Tetrahedron(1, 5, 6, 8)
  ├─ Tetrahedron(1, 3, 4, 8)
  ├─ Tetrahedron(1, 3, 6, 8)
  ├─ Tetrahedron(1, 2, 3, 6)
  └─ Tetrahedron(3, 6, 7, 8)

What I want is

vertices = [
    [0.0, 0.0, 0.0]
    [1.0, 0.0, 0.0]
    [1.0, 1.0, 0.0]
    [0.0, 1.0, 0.0]
    [0.0, 0.0, 1.0]
    [1.0, 0.0, 1.0]
    [1.0, 1.0, 1.0]
    [0.0, 1.0, 1.0]
]

connectivity = [
    [1, 5, 6, 8]
    [1, 3, 4, 8]
    [1, 3, 6, 8]
    [1, 2, 3, 6]
    [3, 6, 7, 8]
]

4 posts - 3 participants