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…