-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add edges to join two detached meshes? #1019
Comments
You maybe forgot to create a copy? from vedo import *
mesh = Mesh(dataurl+'bunny.obj').cut_with_plane([0.02,0,0]).c("blue7")
boundaries = mesh.boundaries()
boundaries_smoothed = boundaries.clone().smooth_mls_1d(f=2.0)
lines = Lines(boundaries, boundaries_smoothed).lw(2)
show(mesh, boundaries, boundaries_smoothed, lines, axes=1) |
Ah apologies! I forgot to add in the shifting downward into the larger code section. It should be |
not sure if I understand what your're trying to do... extruding the boundary? from vedo import *
mesh = Mesh(dataurl+'bunny.obj').cut_with_plane([0.02,0,0]).c("blue7")
boundaries = mesh.boundaries().join(reset=True)
boundaries_smoothed = boundaries.copy().smooth_mls_1d(f=2.0).shift(dx=-.1)
ribbon = Ribbon(boundaries, boundaries_smoothed).c("red7").alpha(0.5)
show(mesh, boundaries, boundaries_smoothed, ribbon, axes=1) |
I'm trying to connect these two boundaries. Using a ribbon doesn't seem to work unfortunately. This also relates to #968. The last step in replicating the madcad algorithm is to join the inflated and deflated meshes with mkquad (https://pymadcad.readthedocs.io/en/latest/_modules/madcad/mesh/mesh.html) |
It doesn't work because the points are aligned but not ordered: from vedo import *
b0 = Mesh("boundaries.vtk")
b1 = Mesh("boundaries_smoothed.vtk")
show(
b0, b1,
Lines(b0,b1),
b0.labels("id", scale=0.05),
b1.labels("id", scale=0.05),
axes=1,
).close()
# THIS DOES NOT WORK YET BUT IT'S THE WAY TO GO...:
b0.add_ids()
b1.add_ids()
ids0 = b0.pointdata["PointID"]
ids1 = b1.pointdata["PointID"]
points = b0.coordinates.tolist() + b1.coordinates.tolist()
ids = ids0.tolist() + ids1.tolist()
n = b1.npoints
faces = []
for k in range(b0.npoints-1):
i0 = ids[k]
i1 = ids[k+1]
j0 = ids[k+n]+n
faces.append([i0, i1, j0])
# print(faces)
m = Mesh([points, faces], c="k6")
show(m, axes=1).close() |
I can't figure out a method to reorder the points unfortunately. Do you have a suggestion? Unfortunately I want to ensure the original boundary is unaffected so your last comment won't be appropriate. I can't set lines (apart from deleting a value one by one with
|
@marcomusy how can I overwrite the existing boundary.lines with new indices? I should be able to resolve it after doing this (or creating a new Mesh with just vertices and lines). |
Have you tried |
Got it to work! Thanks again for your help. I reordered points with:
Lines were connected with two triangles via a slight modification to your recommendation (the second append to
|
Awesome! Nice stuff! |
I have a
a = mesh.boundaries()
and aa_smooth = mesh.boundaries().smooth_mls_1d().shift(dz=-1)
. I want to be able to join them together via new edges determined by nearest neighbours.My approach was to calculate the nearest neighbour of
a
ina_smooth
and to then append them to a copy ofa
.I have calculated the Euclidean distance between the points. I thought at this stage I could append the lines and vertices and it would work as intended, however, it only shows the original boundary points. When I run
.clean()
it removes the smoothed boundary.The text was updated successfully, but these errors were encountered: