How to make a bounding rectangle with C#


#1

Is there a way to do with C# the same that the Plane Through Shape component does?


(David Rutten) #2

The Plane Through Shape component is C#, so yes, it’s possible.

Do you want to create a plane that extends beyond the boundingbox of the shape as a whole, or do you want to create the smallest possible plane which is still bigger than the specific section?


#3

I would like to do exactly the same: a function that receives the shape, the plane and the boundary inflation and returns the rectangle. Is there already a function to do that?


#4

I think it is

  1. Get bounding box of object
  2. Inflate bounding box (parameter t)
  3. Move plane to center of bbox
  4. Intersect plane with bbox
  5. Move that intersection curve back to original plane

(David Rutten) #5

The quick way is to get the bounding-box of the shape, project all 8 corners onto the plane (s,t) space, find the lowest and highest s and t values, then use those to create a Rectangle3d based on your plane. This will give you a rectangle which is guaranteed not smaller than your shape. It could however still be much larger than it needs to be. If you want to shrink it, you’ll have to perform an intersection between your plane and your shape and find the boundingbox of only the intersection points/curves. That will give you the smallest possible rectangle.


#6

Thanks a lot. I’ll try that.