I added a mesh to a pyvista.Plotter()
with
p.add_mesh(mesh, show_edges=True, color='linen', pbr=True, metallic=0.8, roughness=0.1, diffuse=1)
but it displays with a discontinuity (where the mesh started and ended)
Why is this junction of cells different from similar ones around this toroid?
It's probably due to how surface normals are computed, and that your mesh connectivity is off along that edge.
The way you often generate such closed surfaces is to parametrise with respect to some generalised coordinates, one of which in this case is the azimuthal angle. Where your azimuthal angle sweep starts (following the physics convention:
phi = 0
corresponds to the+x
axis) and ends (phi = 2*pi
, again the+x
axis) overlaps, but if you don't take care to ensure connectivity across this boundary then you don't have a closed toroid, but rather an open tube turned back on itself that has a seam where the two open ends meet. This affects how surface normals are estimated on the boundary faces.If you check
mesh.extract_feature_edges(boundary_edges=True, non_manifold_edges=True, feature_edges=False, manifold_edges=False).plot()
you will likely get a vertical ring right where the artifact happens. Depending on your mesh it's probably enough to callmesh = mesh.clean()
with a smalltolerance
value, because if your points at the seam properly overlap then this can merge your boundary points and fuse your boundary faces to remove the spurious edge. (You might also have to recompute the normals yourself, but probably not; I'm not entirely sure.)Case in point: here's a concrete example using an extruded polygon (which is what your mesh seems to be, or close enough):
From the shading it's obvious that something's amiss. It's the hidden boundary edge(s):
And cleaning with a small tolerance (to allow for floating-point errors) solves the problem: