// Decodes the faces, returning true on success. public bool Decode(int num_vertices, Decoder decoder) { int num_faces_parsed = 0; while (num_faces_parsed < num_vertices) { if (!FaceRun.Decode(decoder, out var face_run)) { return(false); } faces_.Add(face_run); num_faces_parsed += face_run.Count; } return(true); }
public static bool Decode(Decoder decoder, out FaceRun fr) { fr = null; if (!decoder.TryGetVarUInt64(out var face_and_count)) { return(false); } var face = (int)(face_and_count % S2CellId.kNumFaces); // Make sure large counts don't wrap on malicious or random input. UInt64 count64 = face_and_count / S2CellId.kNumFaces; var count = (int)count64; var res = count > 0 && (UInt64)count == count64; if (!res) { return(false); } fr = new FaceRun(face, count); return(true); }