intersect simple mesh=parrallel.gh (5.6 MB)
i try write a code to remove Intersection meshes from List(remove from intersectn list all(intersect) -1)
i Test 2 way first for loop and second parrallel; loop but parrallel loop send error ?! is there any suggestion to faster this code?and fix this bug?
private void RunScript(List<Mesh> mesh, ref object A)
{
Component.Name = "Mesh intersect"; Component.NickName = "Mesh intersect";
Polyline[] p ;
var md = mesh.ToList();
// for (int i = 0; i < md.Count; i++)
Parallel.For(0, md.Count, i =>
{
for (int j = md.Count - 1; j > i; j--)
{
p = Rhino.Geometry.Intersect.Intersection.MeshMeshAccurate(md[i], md[j], 0.01);
if(p != null){
lock (md)
md.RemoveAt(j);
}}
}
);
A = (md);
}
@mahdiyar Why is the System.parallel method not correct? Result