Maybe there is smarter way, but I used as your suggested method:
//Store naked mesh vertices and their ids
List<Point3f> pts = new List<Point3f>();
bool[] flag = M.GetNakedEdgePointStatus();
allPointsFound = new List<List<int>>();
//History is need to stop searching rtee
//When all point groups are found
history.Clear();
//Create Rtree
RTree tree = new RTree();
for(int i = 0; i < flag.Length; i++){
if(flag[i]){
tree.Insert(M.Vertices[i], i);
pts.Add(M.Vertices[i]);
}
}
//Search RTree
for(int i = 0; i < pts.Count; i++){
tempIDList = new List<int>();
tree.Search(new Sphere(pts[i], radius), method);
if(tempIDList.Count > 1)
allPointsFound.Add(tempIDList);
if(history.Count == M.Vertices.Count)
break;
}
//Now move found vertices to one of firs vertex position
foreach(List<int> i in allPointsFound)
for(int j = 1; j < i.Count; j++)
M.Vertices[i[0]] = M.Vertices[i[j]];
M.Vertices.CombineIdentical(false, false);
A = M;
}
// <Custom additional code>
//Rtree collections
List<int> history = new List<int>();
List<List<int>> allPointsFound;
List<int> tempIDList;
private void method(object sender, RTreeEventArgs e){
if(!history.Contains(e.Id)){
tempIDList.Add(e.Id);
history.Add(e.Id);
}
}
15_RTree_WeldMesh.gh (7.6 KB)
First I tested the rtee method with bunch of points:
It seems to do what I needed.
