private static void AddPolylineWithLabels(S2Polyline polyline, EdgeType edge_type, Int32 label_begin, S2Builder builder, EdgeLabelMap edge_label_map) { for (int i = 0; i + 1 < polyline.NumVertices(); ++i) { Int32 label = label_begin + i; builder.SetLabel(label); // With undirected edges, reverse the direction of every other input edge. int dir = edge_type == EdgeType.DIRECTED ? 1 : (i & 1); builder.AddEdge(polyline.Vertex(i + (1 - dir)), polyline.Vertex(i + dir)); S2Point key = polyline.Vertex(i) + polyline.Vertex(i + 1); edge_label_map[key].Add(label); } }
private static void AddShapeWithLabels(S2Shape shape, EdgeType edge_type, S2Builder builder, EdgeLabelMap edge_label_map) { const int kLabelBegin = 1234; // Arbitrary. for (int e = 0; e < shape.NumEdges(); ++e) { Int32 label = kLabelBegin + e; builder.SetLabel(label); // For undirected edges, reverse the direction of every other input edge. S2Shape.Edge edge = shape.GetEdge(e); if (edge_type == EdgeType.UNDIRECTED && ((e & 1) != 0)) { edge = new S2Shape.Edge(edge.V1, edge.V0); } builder.AddEdge(edge.V0, edge.V1); edge_label_map[GetKey(edge, edge_type)].Add(label); } }
private static void AddPoint(S2Point p, S2Builder builder) { builder.AddEdge(p, p); }