COLLADA Interoperability#

This notebook demonstrates how to interoperate tqec with COLLADA(.dae) files. COLLADA files can be imported/exported to/from SketchUp, which is a common used 3D modeling tool in QEC paper.

tqec relies on PyCollada under the hood to realize the interoperability with COLLADA files.

Import COLLADA model#

A common workflow starting from SketchUp is:

  1. Open the template file in SketchUp.

  2. Construct the model representing the logical computation.

  3. Export the model as a COLLADA(.dae) file from SketchUp.

  4. Import the COLLADA file to tqec as a BlockGraph, which can be compiled to circuits.

tqec provides the function tqec.interop.read_block_graph_from_dae_file to import a COLLADA file as a BlockGraph. Or you can call BlockGraph.from_dae_file directly.

[1]:
from tqec import BlockGraph

graph = BlockGraph.from_dae_file("../media/user_guide/logical_cnot.dae")

Export COLLADA model#

If you start with building the logical computation in tqec and build a BlockGraph, you can export the BlockGraph to a COLLADA file by calling BlockGraph.to_dae_file.

[2]:
graph.to_dae_file("logical_cnot.dae")

Display COLLADA model#

tqec provides the function tqec.interop.display_collada_model to view the COLLADA model as html and render it with three.js. It can be used in IPython environment to display and play with the model interactively. You can also call BlockGraph.view_as_html directly to first convert it to a COLLADA model then display it.

[3]:
graph.view_as_html()
[3]: