void set_active_op(EditOperations op) { switch (op) { case EditOperations.DeleteTriangle: activeOp = new MeshEditorDeleteTriOp(); break; case EditOperations.PokeTriangle: activeOp = new MeshEditorPokeTriOp(); break; case EditOperations.DeleteEdge: activeOp = new MeshEditorDeleteEdgeOp(); break; case EditOperations.FlipEdge: activeOp = new MeshEditorFlipEdgeOp(); break; case EditOperations.SplitEdge: activeOp = new MeshEditorSplitEdgeOp(); break; case EditOperations.CollapseEdge: activeOp = new MeshEditorCollapseEdgeOp(); break; case EditOperations.DeleteVertex: activeOp = new MeshEditorDeleteVertexOp(); break; case EditOperations.BridgeEdges: activeOp = new MeshEditorBridgeEdgesOp(); break; case EditOperations.DeleteComponent: activeOp = new MeshEditorDeleteComponentOp(); break; case EditOperations.DeleteBorderRing: activeOp = new MeshEditorDeleteRingOp(); break; } active_operation = op; }
private static EditOperations[] EditOpsFromCostMatrix(int len1, char[] c1, int p1, int o1, int len2, char[] c2, int p2, int o2, int[] matrix) { var dir = 0; var pos = matrix[len1 * len2 - 1]; var ops = new EditOperations[pos]; var i = len1 - 1; var j = len2 - 1; var ptr = len1 * len2 - 1; while (i > 0 || j > 0) { if (dir < 0 && j != 0 && matrix[ptr] == matrix[ptr - 1] + 1) { var eop = new EditOperations(); pos--; ops[pos] = eop; eop.Type = EditType.Insert; eop.Spos = i + o1; eop.Dpos = --j + o2; ptr--; continue; } if (dir > 0 && i != 0 && matrix[ptr] == matrix[ptr - len2] + 1) { var eop = new EditOperations(); pos--; ops[pos] = eop; eop.Type = EditType.Delete; eop.Spos = --i + o1; eop.Dpos = j + o2; ptr -= len2; continue; } if (i != 0 && j != 0 && matrix[ptr] == matrix[ptr - len2 - 1] && c1[p1 + i - 1] == c2[p2 + j - 1]) { i--; j--; ptr -= len2 + 1; dir = 0; continue; } if (i != 0 && j != 0 && matrix[ptr] == matrix[ptr - len2 - 1] + 1) { pos--; var eop = new EditOperations(); ops[pos] = eop; eop.Type = EditType.Replace; eop.Spos = --i + o1; eop.Dpos = --j + o2; ptr -= len2 + 1; dir = 0; continue; } if (dir == 0 && j != 0 && matrix[ptr] == matrix[ptr - 1] + 1) { pos--; var eop = new EditOperations(); ops[pos] = eop; eop.Type = EditType.Insert; eop.Spos = i + o1; eop.Dpos = --j + o2; ptr--; dir = -1; continue; } if (dir == 0 && i != 0 && matrix[ptr] == matrix[ptr - len2] + 1) { pos--; var eop = new EditOperations(); ops[pos] = eop; eop.Type = EditType.Delete; eop.Spos = --i + o1; eop.Dpos = j + o2; ptr -= len2; dir = 1; continue; } throw new ArgumentException(@"¯\_(ツ)_/¯"); } return(ops); }