

def attach_surface(self, primitives, primitive_type, shape=DEFAULT_SHAPE_NAME, name=None):
    'Attach a surface to the JSON representation. Primitive type should be:\n                SurfaceLines = 0\n                SurfaceTriangles = 1\n                SurfaceQuads = 2\n        The primitives will be added to the specified `shape`.\n\n        If a `name` is also specified then the primitives will be put into a named surfaces dictionary.'
    num_primitives = len(primitives)
    indices = []
    for p in primitives:
        indices.extend(p)
    if (0 == len(indices)):
        LOG.error('No indices for %s on %s', name, shape)
    if isinstance(indices[0], (tuple, list)):
        indices = list(itertools_chain(*indices))
    self.__set_shape(shape, 'numPrimitives', num_primitives, name)
    if (primitive_type == JsonAsset.SurfaceLines):
        self.__set_shape(shape, 'lines', indices, name)
    elif (name == JsonAsset.SurfaceTriangles):
        self.__set_shape(shape, 'triangles', indices, name)
    elif (primitive_type == JsonAsset.SurfaceQuads):
        self.__set_shape(shape, 'quads', indices, name)
    else:
        LOG.error('Unsupported primitive type:%i', primitive_type)

dataset/ETHPy150Open turbulenz/turbulenz_tools/turbulenz_tools/tools/asset2json.py JsonAsset.attach_surface/VarMisuse@144/312 `primitive_type`->`name`