{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sys\n", "\n", "from OCC.Display.WebGl import threejs_renderer\n", "from OCC.BRepPrimAPI import BRepPrimAPI_MakeTorus\n", "from OCC.gp import gp_Vec\n", "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer, NORMAL\n", "from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox\n", "\n", "sys.path.append('..')\n", "from core_geometry_utils import translate_shp" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# create 3 toruses\n", "# be careful to set copy to True or all the shapes will share the same mesh\n", "torus_shp1 = BRepPrimAPI_MakeTorus(20, 5).Shape()\n", "torus_shp2 = translate_shp(torus_shp1, gp_Vec(60, 0, 0), copy=True)\n", "torus_shp3 = translate_shp(torus_shp1, gp_Vec(-60, 0, 0), copy=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# use the NORMAL.CLIENT_SIDE in order to clearly see faces\n", "# in case the NORMAL.SERVER_SIDE option is used, vertex normals lead to\n", "# a smooth rendering\n", "my_renderer = JupyterRenderer(compute_normals_mode=NORMAL.CLIENT_SIDE)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "my_renderer.DisplayShape(torus_shp1, shape_color=\"blue\", quality=1.) # default quality\n", "my_renderer.DisplayShape(torus_shp2, shape_color=\"red\", quality=4) # lower quality\n", "my_renderer.DisplayShape(torus_shp3, shape_color=\"green\", quality=0.5) # better quality" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "my_renderer.Display()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }