def _split_vertex_with_new_tangents(self, vertex_index, prim_index, split_map, tangent, binormal, tan_split_tol_sq):

        def update_primitive_vertexes(primitives, prim_index, source_index, target_index):
            """Update the primitive for a cloned set of vertexes."""
            (p1, p2, p3) = primitives[prim_index]
            if p1 == source_index:
                p1 = target_index
            if p2 == source_index:
                p2 = target_index
            if p3 == source_index:
                p3 = target_index
            primitives[prim_index] = (p1, p2, p3)

        def tangents_within_tolerance(t1, b1, t2, b2, tan_split_tol_sq):
            """Test if the tangents and binormals are within tolerance."""
            tangent_within_tolerance = vmath.v3is_within_tolerance(t1, t2, tan_split_tol_sq)
            binormal_within_tolerance = vmath.v3is_within_tolerance(b1, b2, tan_split_tol_sq)
            return tangent_within_tolerance and binormal_within_tolerance

        def potential_accumulation_vertexes(vertex_index, split_map):
            """Iterator to consider all potential accumulation vertexes."""
            yield (vertex_index, vertex_index)
            for (original_index, clone_index) in split_map:
                if original_index == vertex_index:
                    yield (original_index, clone_index)

        for (original_index, index) in potential_accumulation_vertexes(vertex_index, split_map):
            if tangents_within_tolerance(self.tangents[index], self.binormals[index],
                                         tangent, binormal, tan_split_tol_sq):
                self.tangents[index] = vmath.v3add(self.tangents[index], tangent)
                self.binormals[index] = vmath.v3add(self.binormals[index], binormal)
                update_primitive_vertexes(self.primitives, prim_index, original_index, index)
                break
        else:
            # We need to split the vertex to start accumulating a different set of tangents.
            clone_index = self._clone_vertex_with_new_tangents(prim_index, vertex_index, tangent, binormal)
            update_primitive_vertexes(self.primitives, prim_index, vertex_index, clone_index)
            split_map.append( (vertex_index, clone_index) )
            LOG.debug("Splitting vertex:%i --> %i primitive[%i] is now:%s", vertex_index, clone_index, prim_index,
                      self.primitives[prim_index])
            LOG.debug("N:%s B:%s T:%s", self.normals[clone_index], self.binormals[clone_index],
                      self.tangents[clone_index])

    # pylint: disable=R0914
Split the vertex if the tangents are outside of the accumulation tolerance.
dataset/ETHPy150Open turbulenz/turbulenz_tools/turbulenz_tools/tools/mesh.py/Mesh._split_vertex_with_new_tangents