<jupyter_start><jupyter_text>dotbim + trimesh example<jupyter_code>from dotbimpy import *
import trimesh

def divide_to_chunks(list_to_divide, chunk_size):
    for i in range(0, len(list_to_divide), chunk_size):
        yield list_to_divide[i:i + chunk_size]

def convert_dotbim_mesh_to_trimesh(mesh_to_convert, element):
    faces = list(divide_to_chunks(mesh_to_convert.indices, 3))

    vertices = []
    counter = 0
    while counter < len(mesh_to_convert.coordinates):
        point = np.array([
            mesh_to_convert.coordinates[counter],
            mesh_to_convert.coordinates[counter + 1],
            mesh_to_convert.coordinates[counter + 2]])

        rotation = pyquaternion.Quaternion(
            a=element.rotation.qw,
            b=element.rotation.qx,
            c=element.rotation.qy,
            d=element.rotation.qz)
        
        point_rotated = rotation.rotate(point)
        vertices.append([point_rotated[0] + element.vector.x, point_rotated[1] + element.vector.y, point_rotated[2] + element.vector.z])
        counter += 3

    mesh = trimesh.Trimesh(vertices=vertices, faces=faces)
    mesh.visual.face_colors = [element.color.r, element.color.g, element.color.b, element.color.a]

    return mesh

def convert_file_to_trimesh_scene(file):
    scene = trimesh.scene.Scene()
    for i in file.elements:
        mesh = next((x for x in file.meshes if x.mesh_id == i.mesh_id), None)
        trimesh_mesh = convert_dotbim_mesh_to_trimesh(mesh_to_convert=mesh, element=i)
        scene.add_geometry(trimesh_mesh)
    
    return scene
file = File.read("MultipleMeshes.bim")
scene = convert_file_to_trimesh_scene(file)
scene.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1057919621749409, 'fraction_numerical': 0.005319148936170213, 'mean_word_length': 3.4203655352480418, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '612999', 'license': 'MIT', 'n_tokens_mistral': 597, 'n_tokens_neox': 589, 'n_words': 93, 'path': 'dotbimpy/other/DotbimToTrimeshScene.ipynb', 'repo_name': 'paireks/dotbimpy', 'size': '1692'}