70000196 I would like SelfIntersect of Vertexes to return the intersection points

Article 70000196
Type Wish
Product Engine
Version 7002
Date Added 12/5/2014
Fixed (12/8/2014)
Submitted by Thomas Müller

Summary

I would like SelfIntersect of Vertexes to return the intersection points

Solution

A new SelfIntersect overload was added. Using this someone can get the number of self intersections in the Vertexes collection as well as a gPoint list of where these intersections are withing the model.

*Attention! You should always use this method with 2D polylines laying on XY plane.*

If for any reason you need to check a line that is not on the X,Y plane, you could use the code below in order to successfuly get the intersection points.

   
    gPoints points = new gPoints();    
    points.Add(new gPoint(1, 1, 0));
    points.Add(new gPoint(-1, -1, 1));
    points.Add(new gPoint(1, -1, 0));
    points.Add(new gPoint(-1, 1, 1));
    points.Add(new gPoint(0, 1.5, 0.5));
    Vertexes verts = new Vertexes(points);
    //Create a poly for testing
    vdPolyline poly = new vdPolyline(doc, verts);
    doc.ActiveLayOut.Entities.AddItem(poly);
    doc.Invalidate();
    //Solution to the problem , we must transform the points so they are in xy plane , you should use this code always since if the points are already in the xy plane they will not change.

    //Calculate Extrusion of the points from the first 3 points. The Extrusion is the Vector perpedicular to the plane of the points.
    Vector Extrusion = new Vector();
    Vector.CalculateNormal3P(points[0], points[1], points[2], out Extrusion);
    //Create a matrix from this extrusion
    Matrix matt = new Matrix();
    matt.ApplyWCS2ECS(Extrusion);
    //Create a copy of the points so we do not mess the original points
    Vertexes copy = new Vertexes(points);
    matt.Transform(copy);
    //Now the copy points arte in the xy plane
    //So now you can take your result!!!!
    gPoints pts;
    int res2 = copy.SelfIntersect(out pts);
                
    //You need to restore the points by transforming them with the invertion of the matrix.
    //If you don't do that the points will be wrong.
    matt.GetInvertion().Transform(pts);

Send comments on this topic.