public static bool EqualIgnoreDir(Edge e0, Edge e1) { VoxelPos v0, v1, v2, v3; v0 = new VoxelPos(); v1 = new VoxelPos(); v2 = new VoxelPos(); v3 = new VoxelPos(); e0.GetVertecs(ref v0, ref v1); e1.GetVertecs(ref v2, ref v3); return (v0 == v2 && v1 == v3) || (v0 == v3 && v1 == v2); }
void __FindAllEdges2Ring__(Edge e, List<Edge> AllEdges, Dictionary<int, int> Degrees, List<VoxelPos> Ring) { VoxelPos v1, v2; v1 = new VoxelPos(); v2 = new VoxelPos(); e.GetVertecs(ref v1, ref v2); int rc = Ring.Count; if (rc == 0) Ring.Add(v1); if (Ring[0] == v2) return; int ldx = e.X1 - e.X0; int ldy = e.Y1 - e.Y0; int ldx0, ldy0; rc = Ring.Count; if (rc > 1) { ldx0 = Ring[rc - 1].X - Ring[rc - 2].X; ldy0 = Ring[rc - 1].Y - Ring[rc - 2].Y; if (ldx0 * ldy + ldx * ldy0 == 0) { Ring.RemoveAt(rc - 1); } } Ring.Add(v2); int ec = AllEdges.Count; VoxelPos sv = new VoxelPos(); ldx = v2.X - v1.X; ldy = v2.Y - v1.Y; int dd = Degrees[v2.X * VoxelCount + v2.Y]; for (int i = 0; i < ec; ++i) { Edge _e = AllEdges[i]; sv.X = _e.X0; sv.Y = _e.Y0; if (sv == v2) { if (dd == 4 && (((_e.X1 - _e.X0 == 0) && (_e.Y1 - _e.Y0) * ldx < 0) || ((_e.Y1 - _e.Y0 == 0) && (_e.X1 - _e.X0) * ldy > 0))) continue; AllEdges.RemoveAt(i); __FindAllEdges2Ring__(_e, AllEdges, Degrees, Ring); break; } } }