inside or outside
Moderators: SDS, support, admin
inside or outside
Is there any way to know if one entity is inside or outside of another?
Thanks
Thanks
Re: inside or outside
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:
Mikhail
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;
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: inside or outside
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
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
Re: inside or outside
Sorry, but this sentence is not quite clear to me.
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: inside or outside
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
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 (237.73 KiB) Viewed 5248 times
Re: inside or outside
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
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
Chat support on Skype: cadsofttools.support
Re: inside or outside
I am using System.Windows.Media.Geometry.Combine() and System.Windows.Media.PathGeometry.FillContains.
I hope it can be helpful.
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);