/** Creates a circular doubly linked list using polygon points. The order is governed by the specified winding order */ private static Node createDoublyLinkedList(final Polygon polygon, int startIndex, final WindingOrder windingOrder) { Node lastNode = null; // Link points into the circular doubly-linked list in the specified winding order if (windingOrder == polygon.getWindingOrder()) { for (int i = 0; i < polygon.numPoints(); ++i) { lastNode = insertNode(polygon, startIndex++, i, lastNode); } } else { for (int i = polygon.numPoints() - 1; i >= 0; --i) { lastNode = insertNode(polygon, startIndex++, i, lastNode); } } // if first and last node are the same then remove the end node and set lastNode to the start if (lastNode != null && isVertexEquals(lastNode, lastNode.next)) { removeNode(lastNode); lastNode = lastNode.next; } // Return the last node in the Doubly-Linked List return filterPoints(lastNode, null); }
/** Creates a circular doubly linked list using polygon points. The order is governed by the specified winding order */ private static final Node createDoublyLinkedList(final Polygon polygon, int startIndex, final WindingOrder windingOrder) { Node lastNode = null; // Link points into the circular doubly-linked list in the specified winding order if (windingOrder == polygon.getWindingOrder()) { for (int i = 0; i < polygon.numPoints(); ++i) { lastNode = insertNode(polygon, startIndex++, i, lastNode); } } else { for (int i = polygon.numPoints() - 1; i >= 0; --i) { lastNode = insertNode(polygon, startIndex++, i, lastNode); } } // if first and last node are the same then remove the end node and set lastNode to the start if (lastNode != null && isVertexEquals(lastNode, lastNode.next)) { removeNode(lastNode); lastNode = lastNode.next; } // Return the last node in the Doubly-Linked List return filterPoints(lastNode, null); }