Open
Description
Hi, I am visualizing some quad and hexahedral meshes, I used Mesh, and meshed them using triangles. I used Line to simulate the edges of the mesh, but the lines are not displaying properly on the mesh, here is the code:
import numpy as np
from vispy import app, scene
nx, ny = 10, 10
x = np.linspace(-5, 5, nx)
y = np.linspace(-5, 5, ny)
xx, yy = np.meshgrid(x, y)
zz = np.sin(0.5 * xx) * np.cos(0.5 * yy)
vertices = np.c_[xx.ravel(), yy.ravel(), zz.ravel()]
faces_tri = []
edges = []
for j in range(ny - 1):
for i in range(nx - 1):
p0 = j * nx + i
p1 = p0 + 1
p2 = p0 + nx + 1
p3 = p0 + nx
faces_tri.append([p0, p1, p2])
faces_tri.append([p0, p2, p3])
edges += [[p0, p1], [p1, p2], [p2, p3], [p3, p0]]
faces_tri = np.array(faces_tri)
edges = np.array(edges)
line_segments = vertices[edges]
line_points = line_segments.reshape(-1, 3)
canvas = scene.SceneCanvas(keys="interactive", show=True, bgcolor="white")
view = canvas.central_widget.add_view()
view.camera = "turntable"
view.camera.fov = 45
view.camera.distance = 20
scene.visuals.Mesh(
vertices=vertices,
faces=faces_tri,
color=(0.5, 0.7, 1.0, 1.0),
shading="flat",
parent=view.scene,
)
scene.visuals.Line(
pos=line_points,
color="black",
width=2.0,
connect="segments",
parent=view.scene,
)
app.run()
I know that using WireframeFilter
can display the edges of the mesh, but all that is displayed are triangles, and I actually only want to display the edges of the quads.
How can this be solved? Thanks!
Metadata
Metadata
Assignees
Labels
No labels