srecord noeq G22MeshMapper_v2(G22Mesh mesh1, G22Mesh mesh2) { // import the important classes delegate Anchor, Curve to G22Mesh. // index structures MultiMap anchorsByArity2; // MAPPING VARS // these are in mesh1 new LinkedHashSet curvesToLookAt; // keys are the anchors from mesh1, values are the anchors from mesh2 new Map anchorMap; // keys are the curves from mesh1, values are the curves from mesh2 new Map mappedCurves; // EXCEPTIONS (e.g. meshes don't match in signature) // set to the reason why when a mapping is deemed impossible settable O rejectedBecause; bool rejected() { ret rejectedBecause != null; } // INTERNAL VARS bool prechecksDone; S sig1, sig2; void searchForMapping { prechecks(); if (rejected()) ret; anchorsByArity2 = multiMapIndex(mesh2.anchors(), a -> a.arity()); Anchor anchor1 = random(mesh1.anchors()); Anchor anchor2 = random(anchorsByArity2.get(anchor1.arity()); assignAnchor(anchor1, anchor2); } void assignAnchor(Anchor anchor1, Anchor anchor2) { anchorMap.put(anchor1, anchor2); curvesToLookAt.addAll(anchor1.curves()); } protected void prechecks { set prechecksDone; sig1 = mesh1.signature(); sig2 = mesh1.signature(); if (!eq(sig1, sig2)) ret with rejectedBecause(G22SignatureMismatch(mesh1, mesh2)); } }