Hi to all
is there a way to make MESH | MESH INTERSECTION faster or parallel ?
meshmesh intersection.gh (6.8 KB)
Hi to all
is there a way to make MESH | MESH INTERSECTION faster or parallel ?
Your main input is a surface and the output of the voronoi are all closed breps, therefore you can use a Brep | Brep intersection component.
the parameter is just an example to do the computational speed test, what I need is to speed up the intersection mesh operation
One point @martinsiegrist is that as you input a brep there is an implicit conversion to mesh that takes time.
Here a 3x speed up
Or you can make a c# script (not optimized, without using DataTree …) But it is more fast.
private void RunScript(List<Mesh> meshes, Mesh mesh, ref object A)
{
Line[][] tab_tab = new Line[meshes.Count][];
Parallel.For(0, meshes.Count,
index => {
Line[] tab_lines = Rhino.Geometry.Intersect.Intersection.MeshMeshFast(meshes[index], mesh);
tab_tab[index] = tab_lines;
});
List<Line> lst_lines = new List<Line>();
foreach (Line[] lines in tab_tab)
{
lst_lines.AddRange(lines);
}
A = lst_lines;
}
Or using Mesh Mesh
private void RunScript(List<Mesh> meshes, Mesh mesh, ref object A)
{
Polyline[][] tab_tab = new Polyline[meshes.Count][];
double tol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
Parallel.For(0, meshes.Count,
index => {
Polyline[] intersections, overlaps;
Mesh overlapsMesh;
Rhino.Geometry.Intersect.Intersection.MeshMesh(new List<Mesh>{meshes[index], mesh}, tol, out intersections, false, out overlaps, false, out overlapsMesh, null, System.Threading.CancellationToken.None, null);
tab_tab[index] = intersections;
});
List<Polyline> lst_lines = new List<Polyline>();
foreach (Polyline[] lines in tab_tab)
{
lst_lines.AddRange(lines);
}
A = lst_lines;
}
[meshmesh intersection (1).gh|attachment](upload://xnWkQb7JXN79WgNvtZbF9QSzgZD.gh) (8.7 KB)
thank you @laurent_delrieu
the script works fine, this is how I use it.
meshmesh intersection v2 .gh (70.4 KB)
I was trying to speed up the 3d voronoi and intersection operation.
with this system and with your script the time was reduced a lot!
All good, many times in this forum the problems are due to wrong commands used and the goal is not always clear…
Hi Laurent, thanks a lot for sharing the code, using your code I managed to replace Brep Plane Intersection by converting Breps to Meshes and reduced the time from 90 minutes to 15. I wanted to ask though if there is (for example in the paid version of your Nautilus add-on) a method to cut meshes with planes even faster? In my case it’s a list of 5000 breps to cut with a single plane 350 times…
Of course 15 minutes looks much better than 90, but it’s still quite a time-consuming process, and since it’s about cutting with planes, I still hope that there will be some even faster way.
In smaller tests the difference in favor of your method was higher, e.g. 20 times faster, so the results may depend on many factors, but it was faster than the native Mesh | Plane component.
Hello,
I don’t know if there is something fastest, I have no tool for that. Just some thought sometime it is fastest to work with a big mesh instead of many meshes (join the meshes).
Mesh Iso splitting could perhaps be used. Iso value is the signed distance to plane and iso cut is at 0. I will make a test.
Mesh Iso Splitting is quite fast but some other process not (deconstruct) !
Thanks, I’m playing with it, will get back with the speed comparsions or issues.
EDIT:
It’s very promising, speed gains are big, but to be precise I must take into account needed pre-processing of the geometry and post-processing. - as you showed, some things like deconstruct may take a significant time.
Component tooltip says that “for each iso value, lines are put on a brach of a datatree”.
Mesh | Plane might be 15x slower, but it’s returning data with sub-branches for each mesh used and it’s a very good thing to have. Without that, some further operations might be not possible or they will be 80x slower as shown here.
Fast Intersection.gh (1.9 MB)