def stitch_vertices(self):

        num_points = len(self.positions)
        points = sorted(enumerate(self.positions), key=lambda (_, x): x)

        mapping = [0] * num_points
        new_index = -1
        prev_p = None
        for (index, p) in points:
            if p != prev_p:
                new_index += 1
                prev_p = p
            mapping[index] = new_index

        self.primitives = [(mapping[i1], mapping[i2], mapping[i3]) for (i1, i2, i3) in self.primitives]
        new_positions = [0] * (new_index + 1)
        for (i, to) in enumerate(mapping):
            new_positions[to] = self.positions[i]
        self.positions = new_positions

    ###################################################################################################################
Combine equal vertices together, adjusting indices of primitives where appropriate
dataset/ETHPy150Open turbulenz/turbulenz_tools/turbulenz_tools/tools/mesh.py/Mesh.stitch_vertices