// split edges longer than fMinLen // NOTE: basically the same as DGraph2Resampler.SplitToMaxEdgeLength, but updates // our internal caches. Could we merge somehow? protected void SplitToMaxEdgeLength(DGraph2 graph, double fMaxLen) { List <int> queue = new List <int>(); int NE = graph.MaxEdgeID; for (int eid = 0; eid < NE; ++eid) { if (!graph.IsEdge(eid)) { continue; } Index2i ev = graph.GetEdgeV(eid); double dist = graph.GetVertex(ev.a).Distance(graph.GetVertex(ev.b)); if (dist > fMaxLen) { DGraph2.EdgeSplitInfo splitInfo; if (graph.SplitEdge(eid, out splitInfo) == MeshResult.Ok) { if (graph_cache != null) { graph_cache.InsertPointUnsafe(splitInfo.vNew, graph.GetVertex(splitInfo.vNew)); } if (dist > 2 * fMaxLen) { queue.Add(eid); queue.Add(splitInfo.eNewBN); } } } } while (queue.Count > 0) { int eid = queue[queue.Count - 1]; queue.RemoveAt(queue.Count - 1); if (!graph.IsEdge(eid)) { continue; } Index2i ev = graph.GetEdgeV(eid); double dist = graph.GetVertex(ev.a).Distance(graph.GetVertex(ev.b)); if (dist > fMaxLen) { DGraph2.EdgeSplitInfo splitInfo; if (graph.SplitEdge(eid, out splitInfo) == MeshResult.Ok) { if (graph_cache != null) { graph_cache.InsertPointUnsafe(splitInfo.vNew, graph.GetVertex(splitInfo.vNew)); } if (dist > 2 * fMaxLen) { queue.Add(eid); queue.Add(splitInfo.eNewBN); } } } } }