cart: empty [ Login ]

2D area of CadLib Entities

1 
eap
12/22/2007 5:02 AM
Once I have loaded a DXF using CadLib, what would the code look like to determine if one Entity is within another. My application only uses 2D objects. So for example I have two AcDb2dPolylines. When viewed they represent the inside and outside edges of the letter O. Mathematically if I add/union the 2D areas of both entities, the result should equal the area one of the entities if one is completely within the other (area of the larger of the two = X). If they are 'outside' of each other, the area of the add/union of the two entities should be equal to the two entities areas added together (Y). If they intersect each other, the area of the union should be greaten then X but less then Y. 
Wout
12/22/2007 12:37 PM
Hi, So what you really need is the area, correct? Then you don't need to know whether one is within the other, the polygon union algorithm takes care of that. You just make sure all the polygons are counter clockwise (so they're filled, not holes), and then union them. Afterwards you can use Polygon2D.GetArea() to get the area of the unioned polygons. Wout
eap
12/24/2007 5:52 PM
Well maybe I'm not familiar enough with DXF or the DxfEntity. I'm trying to determine if the entity is a hole/has a hole. What I'm not concerned with is the entities relation to each other, just if the entity is a hole or not a hole. The problem is that the DXFs I run into were not made by professionals so they may not know how to create on correctly. What I'm concerned about is determining that an entity is in one of three states; on the outside (with a hole or not), on the inside of another object, or if it overlaps (meaning an invalid object). I know that looping through each entity and comparing it to any that have not been compared with yet, and adding the area of the two entities I can determine these facts. So it really comes down to, is the Entity on the ?outside? (with or without entities within it), is the Entity on the ?inside? of another entity, or is the entity overlapping/union (invalid in my case).
Wout
12/24/2007 6:14 PM
Aah ok. You'll need some 2D polygon-polygon intersection detection, which CadLib / WW.Math doesn't have at the moment but I could write it ofcourse. Wout
1