C#中的PathIterator

时间:2015-11-06 19:56:03

标签: java c# geometry polygon

在Java中,我们可以使用PathIterator遍历Shape的顶点(并检测循环和其他功能),我一直在尝试将以下代码转换为C#,因为我无法找到类中的内容与PathIterator等效的C#。那么有谁知道C#中的等价类或方法是什么。

代码是:

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);
}

代码来自以下答案:

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

1 个答案:

答案 0 :(得分:1)

我认为它是Shape.RenderedGeometry(或DefiningGeometry),因为描述主要与

相匹配

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

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

代表C#