The intersectWith() function returns the points where an entity intersects another entity in the drawing. Input values for this function are the entity and the intersection type, which can be one of the following:
For example, suppose a drawing contains the three lines shown in the following illustration. Line1 is “this” and line3 is the argument entity. If the intersection type is kExtendThis, point A is returned as the point where line1 (“this”) would intersect line3 if line1 were extended. If the intersection type is kExtendArgument and line2 is the argument entity, no data is returned because, even if it were extended, line2 would not intersect line1. If the intersection type is kExtendBoth and line2 is the argument entity, point B is returned. If the intersection type is kExtendNone and line2 is the argument entity, no data is returned.
The intersectWith() function is an overloaded function with two forms. The second form takes an additional argument, which is a projection plane for determining the apparent intersection of two entities. These are the signatures for the intersectWith() function:
virtual Acad::ErrorStatus AcDbEntity::intersectWith( const AcDbEntity* ent, AcDb::Intersect intType, AcGePoint3dArray& points, int thisGsMarker = 0, int otherGsMarker = 0) const; virtual Acad::ErrorStatus AcDbEntity::intersectWith( const AcDbEntity* ent, AcDb::Intersect intType, const AcGePlane& projPlane, AcGePoint3dArray& points, int thisGsMarker = 0, int otherGsMarker = 0) const;
The returned points are always on the entity (“this”). Therefore, in cases of apparent intersection, the intersected points are projected back to the entity before they are returned.
Both versions of the intersectWith() function allow you to supply optional GS markers to optimize performance for this function. If the entity's intersectWith() function has implemented the use of GS markers, then supplying GS markers can localize the intersection area and speed up the test. For example, in the following drawing, if the user selects one line of the polygon, passing in the GS marker for that line eliminates the need to test the other five lines of the polygon.