pygalmesh icon indicating copy to clipboard operation
pygalmesh copied to clipboard

Create rectangular based pyramids and find intersections

Open ConnorM17 opened this issue 4 years ago • 1 comments

Hi, I am trying to create a couple rectangular based pyramids and then find the resulting mesh after using pygalmesh.Intersection.

  • Is there a way to create a rectangular based pyramid with pygalmesh?
  • If I create say 4 of these rectangular based pyramids would I be able to use something like,

u = pygalmesh.Intersection([p1, p2, p3, p4]) to find the resulting mesh?

Currently I am trying to create a rectangular based pyramid from two tetrahedrons...

import numpy
import pygalmesh
import meshplex
import meshio

s1 = pygalmesh.Tetrahedron(
    [0.0, 0.0, 0.0], [1.0, -1.0, 1.0], [1.0, 1.0, 1.0], [-1.0, -1.0, 1.0],
)
s2 = pygalmesh.Tetrahedron(
    [0.0, 0.0, 0.0], [-1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [-1.0, -1.0, 1.0]
)
u = pygalmesh.Intersection([s1, s2])
mesh = pygalmesh.generate_mesh(
    u,
    max_cell_circumradius=0.15,
    max_edge_size_at_feature_edges=0.15,
)
mesh.write("out.vtk")

However, this just seems to run forever and eventually segfault. Any tips?

ConnorM17 avatar Feb 10 '21 23:02 ConnorM17

You probably mean to use the union, not the intersection, but nevertheless CGAL has problems with unions which share a common surface.

The best solution would probably be to submit a PR for adding another primitive. Check out the tetrahedron definition here.

It'd be great if we could get a general convex hull primitive here. This would require finding the hull's feature edges and determining if a point is inside the convex hull. See here for an approach that generalizes barycentric coordinates (as used for tetra right now).

nschloe avatar Feb 12 '21 10:02 nschloe