-4

In Java, we can iterate through the vertexes of a Shape with PathIterator (and detect loops and other functionality), I have been trying to convert the following code to C# by I can't find what is the class in C# that is equivalent to PathIterator. So does anyone knows what is the equivalent class or approach in C#.

The code is:

private void processCircleShape(Circle circle, final Shape cellBoundaryPolygon) 
{
    initializeForNewCirclePrivate(circle);
    if (cellBoundaryPolygon == null) 
    {
        return;
    }
    PathIterator boundaryPathIterator = cellBoundaryPolygon.getPathIterator(null);
    double[] firstVertex = new double[2];
    double[] oldVertex = new double[2];
    double[] newVertex = new double[2];
    int segmentType = boundaryPathIterator.currentSegment(firstVertex);
    if (segmentType != PathIterator.SEG_MOVETO) 
    {
        throw new AssertionError();
    }
    System.arraycopy(firstVertex, 0, newVertex, 0, 2);
    boundaryPathIterator.next();
    System.arraycopy(newVertex, 0, oldVertex, 0, 2);
    segmentType = boundaryPathIterator.currentSegment(newVertex);
    while (segmentType != PathIterator.SEG_CLOSE) 
    {
        processSegment(oldVertex, newVertex);
        boundaryPathIterator.next();
        System.arraycopy(newVertex, 0, oldVertex, 0, 2);
        segmentType = boundaryPathIterator.currentSegment(newVertex);
    }
    processSegment(newVertex, firstVertex);
}

The code is from the following answer:

Compute the area of intersection between a circle and a triangle?

Community
  • 1
  • 1
Mr. M
  • 62
  • 1
  • 15

1 Answers1

1

I think it is Shape.RenderedGeometry (or DefiningGeometry) as descriptions match mostly on

https://docs.oracle.com/javase/7/docs/api/java/awt/geom/PathIterator.html for Java

and

https://msdn.microsoft.com/en-us/library/system.windows.shapes.shape.renderedgeometry(v=vs.110).aspx

for C#

online Thomas
  • 8,864
  • 6
  • 44
  • 85
  • After checking it, it doesn't have the same functionality. – Mr. M Nov 06 '15 at 20:10
  • @Mr.M You might have to implement some of the functions yourself, you can't expect every library to have all the same functionality – online Thomas Nov 06 '15 at 20:11
  • @Mr.M look what I stumbled upon: https://goo.gl/ys3mnP – online Thomas Nov 06 '15 at 20:18
  • indeed it is an interesting book, but the problem here is much simpler I almost finished it, it turned out that I can use a subclass of Shape (Polygon) and directly access its Points as PointCollection – Mr. M Nov 06 '15 at 20:28