Sam Jones Posted January 18, 2020 Share Posted January 18, 2020 The problem I would like to solve is that I would like to draw a boundary around a collection of objects. If the objects are in an orthogonal straight line, this is not difficult. I just get the furthest left and right or furthest top and bottom objects of the group and collect the appropriate X and Ys of their bounding boxes. What if the objects form an "L" shape. Does any one have an idea for and algorithm that I can explore? Quote Link to comment
MullinRJ Posted January 18, 2020 Share Posted January 18, 2020 Sam, I assume from your description you want to preserve the "L" shape. If the objects are drawn in a way that adjacent objects are next to each other in the stacking order, AND each object's BBox overlaps (or touches) the BBoxes next to it, you could create a Polygon for each object's BBox and add the Polygons together with the AddSurface command. When you are done they will all be connected but not necessarily in a "pretty" fashion. However, if there are gaps between the individual BBoxes, this approach won't work. Any approach you take that will work will be very dependent on the configuration of shapes before you start. Raymond Quote Link to comment
Sam Jones Posted January 19, 2020 Author Share Posted January 19, 2020 The configuration of the objects will be unknown at the start. The only thing known is what objects are selected. What I want to do is easy for a human, but difficult to create an algorithm for. draw a shape around all the selected objects excluding all objects that are outside the collective shape of their boundaries. Oh well, such is life. Quote Link to comment
JBenghiat Posted January 20, 2020 Share Posted January 20, 2020 If you’re looking for a rectangular boundary, you can just get the min of left bounds, the max of top bounds, etc. This would be the same as the bounding box of the grouped elements. looking at a boundary that conforms to the shape a bit better, you can compute the convex hull. For your L shape, this would draw a line across the crook of the L — not exactly what you want, but a more efficient shape than a rectangle. You can find comp sci algorithms for this — if you’re willing to use some python, you may even find one off the shelf. The input data set would be the four vertices of every object. Concave hull algorithms exist, however the analysis is a lot more complex and I believe work better when your data is more akin to a point cloud representing a contiguous object. Quote Link to comment
Sam Jones Posted January 20, 2020 Author Share Posted January 20, 2020 I had already achieved the rectangular shape. I guess I was hoping for magic to achieve a more conforming shape on selected Lighting Devices not placed in order, placed in a non overlapping and non-rectangular shape. If I could guarantee the order of placement to describe the shape I might figure out a way to poll the bounding boxes, but I cannot. I guess its as difficult as I had hoped it was not. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.