Giter Club home page Giter Club logo

Comments (7)

marcomusy avatar marcomusy commented on September 22, 2024

hi ..so your meshes are almost overlapping?
You maybe can try by measuring the distainces of the 2 meshes and then cut with the computed scalar

https://vedo.embl.es/autodocs/content/vedo/vedo/pointcloud.html#Points.cut_with_scalar
https://vedo.embl.es/autodocs/content/vedo/vedo/pointcloud.html#Points.distance_to

mesh1.distance_to(mesh2, signed=True)
mesh1.cut_with_scalar(0, "Distance")

also have you tried
https://vedo.embl.es/autodocs/content/vedo/vedo/mesh.html#Mesh.intersect_with

from vedo.

IsabellaPa avatar IsabellaPa commented on September 22, 2024

Yes, I projected the meshes to the same plane. I have something like a tunnel that changes its shape and have to find the area that is common along the tunnel length. So in the example that I've sent the shapes are pretty similar as the distance in the tunnel was very small but the shape can vary much more.

The approach with distances leads to similar results as before.
image

While intersect_with returns a collection of lines.
image

I also tried to find the points that are included in all shapes that I compare, but in the end I don't know how I could reconnect the points to an area again.

from vedo.

marcomusy avatar marcomusy commented on September 22, 2024

Sorry from what you have sent it is not clear to me at all what the "tunnel" is or where it is in the image.
Also if you projected on the "same plane" it means the 2 objects are coplanar - and in fact you have got lots of intersections.. so there is no space inbetween?
What is the red sphere?

from vedo.

IsabellaPa avatar IsabellaPa commented on September 22, 2024

Ah sorry. I made a sketch to clarify my problem. I think I spent too much time with it already :)

image
(1)
So the blue thing is my tunnel (I simplified the shape). And the green circles are the shape of the tunnel at specific heights, aka I intersect the tunnel with planes that are parallel to the yellow plane and save the intersection polygon. These intersections led to the blue and green shape that I posted earlier.
(2)
Then I project all my intersections onto the yellow plane. I want to find the red area that is common for all intersection polygons (green circles).

This projection is what I sent earlier. I didn't include images with the tunnel. The tunnel is made out of a vedo mesh.
The sphere is a landmark that's not used in this case, I just didn't take it out of the visualization. :)

I hope that makes it clearer? If not please let me know!

from vedo.

marcomusy avatar marcomusy commented on September 22, 2024

Ok now it is more clear..
you may create a copy of the 3d circles and shift it forward (and/or backwards along the normal) and form a cylindrical Ribbon mesh. You use then this mesh to .cut_with_mesh() the other ones that would be created in the same way until you are only left with the intersection. You may need to use .slice() to create a filled circle to be cut.

from vedo.

IsabellaPa avatar IsabellaPa commented on September 22, 2024

I'm not 100% sure if I understand correctly what you want to do with the ribbon. As far as I interpreted it the Ribbon fills the space between two boundaries/circles.
This works find for me if the meshes are a tiny bit apart but when I put them into the same plane they start to do funny things
image
Here in pink the ribbon.
I get my ribbon by:

intersection_circle = tunnel_mesh.intersect_with_plane(origin=new_center, normal=normal).join(reset=True)
mslices = vedo.pointcloud.merge(intersection_circle).color(color[distance]) 
mslices_boundaries = mslices.boundaries()
(I'm doing this for multiple outlines)

ribbon_mesh = Ribbon(mslices_boundaries_0, mslices_boundaries_1, closed =True, mode = 1).color('pink')

Results for mode 0 and mode 1 are not the same but similar in the problem. Setting closed = False also didn't help.

Also, in my tunnel the walls can sometimes touch in the middle so I have two separate circles or more at the same intersection height.

I do appreciate your help a lot!

from vedo.

marcomusy avatar marcomusy commented on September 22, 2024

You can play around with a test case to find the strategy that best fits your problem, consider this as a starting point:

from vedo import *

ln = [[sin(x), cos(x), x / 2] for x in np.arange(6,9, 0.1)]
N = len(ln)
radii = [0.3*(cos(6.0*ir/N))**2+0.1 for ir in range(N)]
tube = Tube(ln, r=radii, res=48).triangulate()

n = (0.3,-1,0)
slices = []
for i in range(-3, 6):
    sli = tube.slice(origin=[0,i/10,0], normal=n)
    sli.c("b9").bc("k5").lighting("off").pickable(True)
    # sli = tube.intersect_with_plane(origin=[0,i/10,0], normal=n)
    sli.reorient(n, [0,0,1])
    slices.append(sli)

show([tube, slices], N=2, sharecam=0, axes=1)

Screenshot from 2024-04-24 15-31-21

from vedo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.