inside or outside

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
ditel
Posts: 31
Joined: 06 Feb 2020, 12:21

inside or outside

Post by ditel » 12 Nov 2020, 20:11

Is there any way to know if one entity is inside or outside of another?

Thanks

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: inside or outside

Post by support » 13 Nov 2020, 00:25

Hello,

You may try to call a DRect.Contains() method on the bounding box of the second entity (CADEntity.Box), passing the bounding box of the first entity as a parameter. For example:

Code: Select all

public static bool IsEntity1InsideEntity2(CADEntity ent1, CADEntity ent2)
{
    if (ent2.Box.Contains(ent1.Box))
    {
        return true;
    }
    return false;
}
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

ditel
Posts: 31
Joined: 06 Feb 2020, 12:21

Re: inside or outside

Post by ditel » 17 Nov 2020, 12:25

thanks Mikhail

ditel
Posts: 31
Joined: 06 Feb 2020, 12:21

Re: inside or outside

Post by ditel » 17 Nov 2020, 13:28

Hi Mikhail

In the attached file we need to know all the existing entities within the first entitie number 0

we use DRect.Contains () but return that are true entities that are not inside entity 0 because that entity is inside in of box but not within the entity

Exist another way to make this
thanks
Attachments
FramesSheet4.rar
(68.36 KiB) Downloaded 467 times

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: inside or outside

Post by support » 17 Nov 2020, 23:10

ditel wrote:
17 Nov 2020, 13:28
we use DRect.Contains () but return that are true entities that are not inside entity 0 because that entity is inside in of box but not within the entity
Sorry, but this sentence is not quite clear to me.

Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

ditel
Posts: 31
Joined: 06 Feb 2020, 12:21

Re: inside or outside

Post by ditel » 18 Nov 2020, 13:15

Hi Mikhail

Sorry for not explaining myself correctly. I'm going to try again.
In the attached drawing we have a design. We have to search for all entities within entity 0

column A shows all the entities that the function should return as true

public static bool IsEntity1InsideEntity2 (CADEntity ent1, CADEntity ent2)
{
if (ent2.Box.Contains (ent1.Box))
{
return true;
}
return false;
}

This function returns as true the entities 22,23,24,58,57,56 corresponding to the area marked as B that is not within the entity 0

The question is to know if there is any way of knowing only the inner entities

Kind regards
Attachments
explicacion_1.jpg
explicacion_1.jpg (237.73 KiB) Viewed 5249 times

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: inside or outside

Post by support » 18 Nov 2020, 23:10

Hello,

The bounding box in 2D drawing is a rectangular area around an entity, so the bounding box area may be greater than the entity area. Unfortunately, the library doesn't have methods for searching "inner entities" within complex polygons/curves.

Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

ditel
Posts: 31
Joined: 06 Feb 2020, 12:21

Re: inside or outside

Post by ditel » 19 Nov 2020, 12:22

OK thanks Mikhail

Sing
Posts: 48
Joined: 12 Apr 2020, 17:39

Re: inside or outside

Post by Sing » 05 Jan 2021, 12:13

I am using System.Windows.Media.Geometry.Combine() and System.Windows.Media.PathGeometry.FillContains.
I hope it can be helpful.

Code: Select all

// 1. Convert Polylines or polygons to System.Windows.Media.PathGeometry
// 2. and then try to combine them.
System.Windows.Media.Geometry.Combine(path1, path2, GeometryCombineMode.Intersect, null);
// or check FillContains(System.Windows.Point point)
System.Windows.Media.PathGeometry.FillContains(point);

Post Reply