/// search for overlap with a MillingCutter c positioned at cl, return found objects public LinkedList <Triangle> search_cutter_overlap(MillingCutter c, CLPoint cl) { double r = c.getRadius(); // build a bounding-box at the current CL Bbox bb = new Bbox(cl.x - r, cl.x + r, cl.y - r, cl.y + r, cl.z, cl.z + c.getLength()); return(this.search(bb)); }
/// search for overlap with input Bbox bb, return found objects public LinkedList <Triangle> search(Bbox bb) { Debug.Assert(dimensions.Count > 0); LinkedList <Triangle> tris = new LinkedList <Triangle>(); this.search_node(tris, bb, root); return(tris); }
} // end spread(); /// search kd-tree starting at *node, looking for overlap with bb, and placing /// found objects in *tris protected void search_node(LinkedList <Triangle> tris, Bbox bb, KDNode <Triangle> node) { if (node.isLeaf) { // we found a bucket node, so add all triangles and return. foreach (Triangle t in node.tris) { tris.AddLast(t); } //std::cout << " search_node Leaf bucket tris-size() = " << tris->size() << "\n"; return; // end recursion } else if ((node.dim % 2) == 0) { // cutting along a min-direction: 0, 2, 4 // not a bucket node, so recursevily search hi/lo branches of KDNode uint maxdim = (uint)(node.dim + 1); if (node.cutval > bb[maxdim]) { // search only lo search_node(tris, bb, node.lo); } else { // need to search both child nodes if (node.hi != null) { search_node(tris, bb, node.hi); } if (node.lo != null) { search_node(tris, bb, node.lo); } } } else { // cutting along a max-dimension: 1,3,5 uint mindim = (uint)(node.dim - 1); if (node.cutval < bb[mindim]) { // search only hi search_node(tris, bb, node.hi); } else { // need to search both child nodes if (node.hi != null) { search_node(tris, bb, node.hi); } if (node.lo != null) { search_node(tris, bb, node.lo); } } } return; // Done. We get here after all the recursive calls above. } // end search_kdtree();
/// return true if *this overlaps Bbox b /// does this Bbox overlap with b? //C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: bool overlaps(const Bbox& b) const public bool overlaps(Bbox b) { if ((this.maxpt.x < b.minpt.x) || (this.minpt.x > b.maxpt.x)) { return(false); } else if ((this.maxpt.y < b.minpt.y) || (this.minpt.y > b.maxpt.y)) { return(false); } else if ((this.maxpt.z < b.minpt.z) || (this.minpt.z > b.maxpt.z)) { return(false); } else { return(true); } }