Page 1 of 1
inside or outside
Posted: 12 Nov 2020, 20:11
by ditel
Is there any way to know if one entity is inside or outside of another?
Thanks
Re: inside or outside
Posted: 13 Nov 2020, 00:25
by support
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
Re: inside or outside
Posted: 17 Nov 2020, 12:25
by ditel
thanks Mikhail
Re: inside or outside
Posted: 17 Nov 2020, 13:28
by ditel
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
Re: inside or outside
Posted: 17 Nov 2020, 23:10
by support
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
Re: inside or outside
Posted: 18 Nov 2020, 13:15
by ditel
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
Re: inside or outside
Posted: 18 Nov 2020, 23:10
by support
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
Re: inside or outside
Posted: 19 Nov 2020, 12:22
by ditel
OK thanks Mikhail
Re: inside or outside
Posted: 05 Jan 2021, 12:13
by Sing
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);