Spatial Querying: Implementation of BVH tree for IFC files using NCollection_UBTree#130
Conversation
|
interesting work... I've been integrating collision detection with the cython FCL wrappers, hence my curiosity. OCC has a BVH package, have you looked into it? Or are these OCCT >= 7.0 specific? |
I guess they are. I used Must say it works rather well. Would be quite awesome if this is wrapped in pyOCC. I guess the reason it is not is because it is a templated class to allow some genericity (which SWIG does not automatically wrap). Maybe I will send in a pyOCC PR someday. Really quite a valuable OCCT component. |
|
Yeah, so I was ( pleasantly ) surprised by the BVH package myself in OCCT... |
Well there are two template parameters (in 6.9) the type for the bounding box, which I guess is always These BVH trees work well for things that can be divided into distinct elements (e.g. the objects within an IFC file). For point clouds it might work if you are able to create meaningful segmentations or euclidean clusters (e.g using PCL), but otherwise other tree structures (kd-trees etc., not sure what FCL provides) are much more suitable. |
|
yeah, so FCL might be of interest for you, since this can handle pointclouds... that lib has awesome performance and deals well with degenerated geom ( eg non-convex ) |
|
@aothms what about the BVH related classes in OCC. Are these of interest? |
|
@jf--- Well, I don't know yet what's the relations between [1] and [2]. That's actually the thing I wanted to find out before merging this PR, but didn't get to it yet. [1] https://dev.opencascade.org/doc/refman/html/class_n_collection___u_b_tree.html |
|
Good afternoon, my example: `# -- coding: utf-8 -- import ifcopenshell model = ifcopenshell.open("D:\M2\Checker_Test\Duplex_A.ifc") tree_settings = ifcopenshell.geom.settings() elements = t.select_box(((-0.24150015000001304, -22.182734150000012, 6.609000000000000), #checking coordinates Z settings = ifcopenshell.geom.settings() for element in elements: MaxZ = bbox.CornerMax().Z() print ("the Z - coordinates of the box 6.609000000000000 - 9.000000150000012,
|
|
Hey @aothms does this tree still reliable to work with ? |
|
@samiba6 sure, has been extended since with things like distances and ray intersection |
Rationale
By arranging the bounding volumes into a bounding volume hierarchy, the time complexity (the number of tests performed) can be reduced to logarithmic in the number of objects. With such a hierarchy in place, during collision testing, children volumes do not have to be examined if their parent volumes are not intersected. From wikipedia.
Bounding box intersection: 0.000 seconds
Solid volume containment: 0.597 seconds
API
Python
C++
Implementation
Open Cascade NCollection_UBTree
Performance
Nothing conclusive, querying times for bounding boxes below timer resolution for small-medium sized models. Tree construction + geometry generation linearithmic (?).