private void RegionOverlapCallback(object sender, RTreeEventArgs e) { var dataIndex = e.Id; // The full-grid index of the point found // Reconstruct variables from the data tag var data = e.Tag as Tuple <int, GridPt[, ], List <Curve>, int, int, double>; var regionIndex = data.Item1; var gridPoints = data.Item2; var overlapRegion = data.Item3[regionIndex]; var xExtents = data.Item4; var yExtents = data.Item5; var tolerance = data.Item6; // Using the known GridPt 2D array bounds, locate the 2D indices from the 1D dataIndex //Print("regionOverlapCallback (start) xExtents={0} yExtents={1}", xExtents, yExtents); var xIndex = dataIndex / yExtents; var yIndex = dataIndex % yExtents; //Print("\t\tPt where dataIndex={0} is at {1},{2}", dataIndex, xIndex, yIndex); // Increment overlaps after checking if the curve actually overlaps var overlappingPt = gridPoints[xIndex, yIndex]; //Print("\t\tPt where gridIndex={0} is at {1}", overlappingPt.GridIndex, overlappingPt.Location); var worldXY = Plane.WorldXY; var isOutside = PointContainment.Outside; var containmentTest = overlapRegion.Contains(overlappingPt.Location, worldXY, tolerance); if (containmentTest != isOutside) { overlappingPt.BaseOverlaps += 1; } //Print("\n"); }
private void SearchCallback(object sender, RTreeEventArgs e) { var data = e.Tag as SearchData; if (data is null) { return; } data.ContainedIndex = e.Id; e.Cancel = true; }
private static void ClosestPointCallback(object sender, RTreeEventArgs e) { ClosestPointSearchData closestPointSearchData = e.Tag as ClosestPointSearchData; if (closestPointSearchData != null) { Point3d val = closestPointSearchData.Points[e.Id]; Sphere searchSphere = e.SearchSphere; double num = val.DistanceTo(searchSphere.Center); if (closestPointSearchData.Index == -1 || num < closestPointSearchData.Distance) { searchSphere = e.SearchSphere; e.SearchSphere = new Sphere(searchSphere.Center, num); closestPointSearchData.Distance = num; closestPointSearchData.Index = e.Id; } } }
static void SearchCallback(object sender, RTreeEventArgs e) { SearchData data = e.Tag as SearchData; if (data == null) { return; } data.HitCount = data.HitCount + 1; Point3f vertex = data.Mesh.Vertices[e.Id]; double distance = data.Point.DistanceTo(vertex); if (data.Index == -1 || data.Distance > distance) { // shrink the sphere to help improve the test e.SearchSphere = new Sphere(data.Point, distance); data.Index = e.Id; data.Distance = distance; } }
private static void SphereCallback(object sender, RTreeEventArgs e) { SphereSearchData distanceSearchData = e.Tag as SphereSearchData; distanceSearchData.Ids.Add(e.Id); }
static void BoundingBoxCallback(object sender, RTreeEventArgs e) { var boxSearchData = e.Tag as BoxSearchData; boxSearchData.Ids.Add(e.Id); }
/// <summary> /// RTree.SearchOverlap callback /// </summary> private void SearchCallback(object sender, RTreeEventArgs e) { m_events.Add(new Tuple <int, int>(e.Id, e.IdB)); }