Author Topic: Region inside region  (Read 4674 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
Re: Region inside region
« Reply #15 on: December 08, 2014, 01:24:12 PM »
Using Marc'Antonio Alessi's suggestion is problematic if the original regions have 'islands'.
have you an example?
If you subtract a region from another region, the result can be a new region with an island or hole at its center. Inside that hole a different region may be located that does not at any point overlap the region containing the hole.
Ok, I meant to ask a graphic example... in the case of islands perhaps the subtract method is better.
 I do not know if this can be faster: use (vlax-invoke Obj "Explode") and then go through all the segments obtained with ssget "_f" and see if r1 intersect... or... decode Acis info?...!

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Region inside region
« Reply #16 on: December 08, 2014, 04:07:20 PM »
FWIW: You can create a valid 3D solid from the entity list of a region and with 3D solids you can use the CheckInterference method. But I am not saying this will be a fast approach.

Lupo76

  • Bull Frog
  • Posts: 343
Re: Region inside region
« Reply #17 on: December 09, 2014, 03:03:52 AM »
Another method is to compare area of intersection against area of original regions.
This way you can verify if r1 is inside r2 or vice versa.
This will return nil or a list in which first element is the region containing the other region.
Code - Auto/Visual Lisp: [Select]
  1. (defun reg_inside (r1 r2 / a1 a2 a r)
  2.   (vla-boolean (setq r (vla-copy r1)) acintersection (vla-copy r2))
  3.   (setq a1 (vla-get-area r1)
  4.         a2 (vla-get-area r2)
  5.         a  (vla-get-area r )
  6.         )
  7.   (vla-delete r)
  8.   (cond
  9.     ((equal a a1 1e-8) (list r2 r1))
  10.     ((equal a a2 1e-8) (list r1 r2))
  11.   )
  12. )

@Lupo76: How do you intend to compare hundreds of regions? What is the expected result?

Thank you all!
I never expected to get so many answers:-)

I preferred this solution, it seemed the cleanest.
is sufficiently fast.

PS. I do not have holes in my regions: it is to check if a region (square) is into another region (irregularly shaped).