itwinjs-core
itwinjs-core copied to clipboard
Clip 3D volumes of a model based on geometry of one or more elements
Request: clip 3d volumes of a model based on geometry of one or more elements.
To solve this, we could obtain the geometry of a specified set of elements as polyfaces. We could produce a ClipVector from them (one clip plane per facet), then use the ClipVector to clip the model.
A key aspect of this is that this should be an enterprise solution, not hard-coded for certain elements.
See this discussion for more details. Also this one.
See this specific comment for an experiment that was done that shows the proof of concept.
Update August 19th: This could be solved by enabling frontend application to obtain polyfaces from the geometry of the elements of interest, convert them into a set of convex hulls, possibly expand those hulls, create a convex clip plane set from each hull, and apply the result as a ClipVector to the view.
- [ ] Rpc interface method to obtain polyfaces from one or more elements. #4470
- [x] geometry-core API to produce convex clip plane set from polyfaces. #4185
- [ ] geometry-core API to expand polyface by a specified distance from its surface.
- [ ] API to decompose a polyface into a set of approximate convex hulls.
- This is probably better left to an external library like V-HACD, transpiled to WebAssembly and incorporated into a sample.
We should consider an alternate approach than just getting polyfaces from elements. It can result in many clip planes and they would not necessarily be convex except for very simple geometry.
~~Perhaps just getting the bounds of the element and clipping based on that could be enough.~~
Element bounding boxes will not suffice - that is what they thought we were suggesting, and pointed out that the bounding box of e.g. a long curvy pipe will be a poor substitute for the actual geometry. Ideally we'd have a simplified envelope around the geometry.
It would be wonderful if this could be solved using volume classifiers. Volume classification tiles contain volumes (possibly expanded) for every element. My understanding is that volume classifiers cannot hide geometry because they are applied after rendering has occurred. Perhaps the geometry in the tiles could be used in some different way to do the clipping?
The users do not have direct access to the elements' geometry from the frontend -- not even exportGraphics for obtaining meshes.
Hello iTwin team. Regarding this development request, is it possible to please share an update? Refers to this: https://github.com/iTwin/itwinjs-core/discussions/3961
Thanks Tony
@tonygem2022 it's on our roadmap. You can now create a clip plane set from a polyface. @EarlinLutz is currently adding support for expanding a polyface's surface. I am adding support for obtaining polyfaces for elements. Work on the convex hull decomposition library has not yet begun.
Thanks for the timely response @pmconne So if i understand the road map correctly, this will be 2H22, i.e. before end December? Thanks.
That's the plan.
Hello @pmconne. A gentle check in to see if this timeline is still on progress? Absolve the follow-up though it doesnt appear this page is frequently updated. Thanks.
Thanks for checking in @tonygem2022. All of the components mentioned in my previous reply are now in place. All that remains is to assemble them into an example illustrating how to apply them to clip the view. I'll be working on that next week.
That's great @pmconne! Please let me know when complete and we would be pleased to test. Thanks.
@tonygem2022 @hanan-commits-work @Rycha2021 @ovaisa #4794 illustrates one way to achieve this. It uses V-HACD to produce the convex hulls required for clipping. All of the features it uses - obtaining polyfaces from elements and producing a clip from a polyface - are included in iTwin.js 3.5. @EarlinLutz and @dassaf4 are still finishing up the API for expanding the polyfaces; we can backport it to 3.5 if necessary once it becomes available.
Thanks @pmconne. Is the iTwin team working on providing an example? Thanks
@tonygem2022 #4794 contains the example.