├── README.md ├── examples ├── occ_classic_bottle.ipynb ├── .ipynb_checkpoints │ ├── occ_classic_bottle-checkpoint.ipynb │ ├── occ_helloworld-checkpoint.ipynb │ ├── occ_load_brep-checkpoint.ipynb │ ├── occ_torus_mesh_quality-checkpoint.ipynb │ ├── occ_helloworld_slider-checkpoint.ipynb │ ├── occ_load_step_ap203_one_shape-checkpoint.ipynb │ ├── occ_load_step_ap203_multiple_shapes-checkpoint.ipynb │ ├── occ_callback-checkpoint.ipynb │ ├── occ_load_step_ap203-checkpoint.ipynb │ └── occ_torus_trait-checkpoint.ipynb ├── occ_helloworld.ipynb ├── occ_load_brep.ipynb ├── occ_torus_mesh_quality.ipynb ├── occ_load_step_ap203_one_shape.ipynb ├── occ_load_step_ap203_multiple_shapes.ipynb ├── occ_callback.ipynb └── occ_helloworld_slider.ipynb └── Dockerfile /README.md: -------------------------------------------------------------------------------- 1 | Run pythonocc at mybinder.org 2 | ----------------------------- 3 | 4 | ### Available images 5 | 6 | #### Latest release 7 | pythonocc-7.8.1 [![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/tpaviot/pythonocc-binderhub/7.8.1) 8 | 9 | #### Previous releases 10 | pythonocc-7.7.2 [![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/tpaviot/pythonocc-binderhub/7.7.2) 11 | 12 | #### Current master branch 13 | pythonocc-master-build [![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/tpaviot/pythonocc-binderhub/build-master) 14 | 15 | ### About 16 | 17 | This projects provides a Dockerfile image that can be run from a binderhub jupyter environment. 18 | -------------------------------------------------------------------------------- /examples/occ_classic_bottle.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import sys\n", 10 | "sys.path.append('..')\n", 11 | "from core_classic_occ_bottle import bottle" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": null, 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "from OCC.Display.WebGl import jupyter_renderer\n", 21 | "ren = jupyter_renderer.JupyterRenderer()" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "ren.DisplayShape(bottle)" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "ren" 40 | ] 41 | } 42 | ], 43 | "metadata": { 44 | "kernelspec": { 45 | "display_name": "Python 3", 46 | "language": "python", 47 | "name": "python3" 48 | }, 49 | "language_info": { 50 | "codemirror_mode": { 51 | "name": "ipython", 52 | "version": 3 53 | }, 54 | "file_extension": ".py", 55 | "mimetype": "text/x-python", 56 | "name": "python", 57 | "nbconvert_exporter": "python", 58 | "pygments_lexer": "ipython3", 59 | "version": "3.6.4" 60 | } 61 | }, 62 | "nbformat": 4, 63 | "nbformat_minor": 2 64 | } 65 | -------------------------------------------------------------------------------- /examples/.ipynb_checkpoints/occ_classic_bottle-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import sys\n", 10 | "sys.path.append('..')\n", 11 | "from core_classic_occ_bottle import bottle" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": null, 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "from OCC.Display.WebGl import jupyter_renderer\n", 21 | "ren = jupyter_renderer.JupyterRenderer()" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "ren.DisplayShape(bottle)" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "ren" 40 | ] 41 | } 42 | ], 43 | "metadata": { 44 | "kernelspec": { 45 | "display_name": "Python 3", 46 | "language": "python", 47 | "name": "python3" 48 | }, 49 | "language_info": { 50 | "codemirror_mode": { 51 | "name": "ipython", 52 | "version": 3 53 | }, 54 | "file_extension": ".py", 55 | "mimetype": "text/x-python", 56 | "name": "python", 57 | "nbconvert_exporter": "python", 58 | "pygments_lexer": "ipython3", 59 | "version": "3.6.4" 60 | } 61 | }, 62 | "nbformat": 4, 63 | "nbformat_minor": 2 64 | } 65 | -------------------------------------------------------------------------------- /examples/occ_helloworld.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer\n", 10 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "my_renderer = JupyterRenderer()" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": null, 25 | "metadata": {}, 26 | "outputs": [], 27 | "source": [ 28 | "box_shape = BRepPrimAPI_MakeBox(10, 20, 30).Shape()" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "my_renderer.DisplayShape(box_shape)" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": null, 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "my_renderer" 47 | ] 48 | } 49 | ], 50 | "metadata": { 51 | "kernelspec": { 52 | "display_name": "Python 3", 53 | "language": "python", 54 | "name": "python3" 55 | }, 56 | "language_info": { 57 | "codemirror_mode": { 58 | "name": "ipython", 59 | "version": 3 60 | }, 61 | "file_extension": ".py", 62 | "mimetype": "text/x-python", 63 | "name": "python", 64 | "nbconvert_exporter": "python", 65 | "pygments_lexer": "ipython3", 66 | "version": "3.6.4" 67 | } 68 | }, 69 | "nbformat": 4, 70 | "nbformat_minor": 2 71 | } 72 | -------------------------------------------------------------------------------- /examples/.ipynb_checkpoints/occ_helloworld-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer\n", 10 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "my_renderer = JupyterRenderer()" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": null, 25 | "metadata": {}, 26 | "outputs": [], 27 | "source": [ 28 | "box_shape = BRepPrimAPI_MakeBox(10, 20, 30).Shape()" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "my_renderer.DisplayShape(box_shape)" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": null, 43 | "metadata": {}, 44 | "outputs": [], 45 | "source": [ 46 | "my_renderer" 47 | ] 48 | } 49 | ], 50 | "metadata": { 51 | "kernelspec": { 52 | "display_name": "Python 3", 53 | "language": "python", 54 | "name": "python3" 55 | }, 56 | "language_info": { 57 | "codemirror_mode": { 58 | "name": "ipython", 59 | "version": 3 60 | }, 61 | "file_extension": ".py", 62 | "mimetype": "text/x-python", 63 | "name": "python", 64 | "nbconvert_exporter": "python", 65 | "pygments_lexer": "ipython3", 66 | "version": "3.6.4" 67 | } 68 | }, 69 | "nbformat": 4, 70 | "nbformat_minor": 2 71 | } 72 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jupyter/scipy-notebook:latest 2 | MAINTAINER Thomas Paviot 3 | 4 | USER root 5 | 6 | ENV DEBIAN_FRONTEND=noninteractive 7 | 8 | ############## 9 | # apt update # 10 | ############## 11 | RUN apt-get update 12 | RUN apt-get install -y wget libglu1-mesa-dev libgl1-mesa-dev libxmu-dev libxi-dev 13 | RUN dpkg-reconfigure --frontend noninteractive tzdata 14 | 15 | ######################################################### 16 | # Install pythonocc-core 7.9.0 from conda-forge channel # 17 | ######################################################### 18 | RUN ls /opt 19 | RUN /opt/conda/bin/conda config --set always_yes yes --set changeps1 no 20 | RUN /opt/conda/bin/conda info -a 21 | RUN /opt/conda/bin/conda config --add channels https://conda.anaconda.org/conda-forge 22 | RUN /opt/conda/bin/conda install -c conda-forge pythonocc-core=7.9.0 23 | 24 | ############################## 25 | # Install pythonocc examples # 26 | ############################## 27 | WORKDIR /opt/build/ 28 | RUN git clone https://github.com/tpaviot/pythonocc-demos 29 | WORKDIR /opt/build/pythonocc-demos 30 | RUN cp -r /opt/build/pythonocc-demos/assets /home/jovyan/work 31 | RUN cp -r /opt/build/pythonocc-demos/jupyter_notebooks /home/jovyan/work 32 | 33 | ############# 34 | # pythreejs # 35 | ############# 36 | RUN /opt/conda/bin/conda install -c conda-forge pythreejs 37 | 38 | ######## 39 | # gmsh # 40 | ######## 41 | #RUN /opt/conda/bin/conda install -c conda-forge gmsh 42 | 43 | ################ 44 | # IfcOpenShell # 45 | ################ 46 | #RUN /opt/conda/bin/conda install -c conda-forge ifcopenshell 47 | 48 | ##################### 49 | # back to user mode # 50 | ##################### 51 | USER jovyan 52 | WORKDIR /home/jovyan/work 53 | -------------------------------------------------------------------------------- /examples/occ_load_brep.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from OCC.BRepTools import breptools_Read\n", 10 | "from OCC.TopoDS import TopoDS_Shape\n", 11 | "from OCC.BRep import BRep_Builder" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": null, 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": null, 26 | "metadata": {}, 27 | "outputs": [], 28 | "source": [ 29 | "cylinder_head = TopoDS_Shape()\n", 30 | "builder = BRep_Builder()\n", 31 | "breptools_Read(cylinder_head, '../models/cylinder_head.brep', builder)" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "my_renderer = JupyterRenderer()" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "my_renderer.DisplayShape(cylinder_head)" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": null, 55 | "metadata": {}, 56 | "outputs": [], 57 | "source": [ 58 | "my_renderer" 59 | ] 60 | } 61 | ], 62 | "metadata": { 63 | "kernelspec": { 64 | "display_name": "Python 3", 65 | "language": "python", 66 | "name": "python3" 67 | }, 68 | "language_info": { 69 | "codemirror_mode": { 70 | "name": "ipython", 71 | "version": 3 72 | }, 73 | "file_extension": ".py", 74 | "mimetype": "text/x-python", 75 | "name": "python", 76 | "nbconvert_exporter": "python", 77 | "pygments_lexer": "ipython3", 78 | "version": "3.6.4" 79 | } 80 | }, 81 | "nbformat": 4, 82 | "nbformat_minor": 2 83 | } 84 | -------------------------------------------------------------------------------- /examples/.ipynb_checkpoints/occ_load_brep-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from OCC.BRepTools import breptools_Read\n", 10 | "from OCC.TopoDS import TopoDS_Shape\n", 11 | "from OCC.BRep import BRep_Builder" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": null, 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [ 20 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": null, 26 | "metadata": {}, 27 | "outputs": [], 28 | "source": [ 29 | "cylinder_head = TopoDS_Shape()\n", 30 | "builder = BRep_Builder()\n", 31 | "breptools_Read(cylinder_head, '../models/cylinder_head.brep', builder)" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "my_renderer = JupyterRenderer()" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "my_renderer.DisplayShape(cylinder_head)" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": null, 55 | "metadata": {}, 56 | "outputs": [], 57 | "source": [ 58 | "my_renderer" 59 | ] 60 | } 61 | ], 62 | "metadata": { 63 | "kernelspec": { 64 | "display_name": "Python 3", 65 | "language": "python", 66 | "name": "python3" 67 | }, 68 | "language_info": { 69 | "codemirror_mode": { 70 | "name": "ipython", 71 | "version": 3 72 | }, 73 | "file_extension": ".py", 74 | "mimetype": "text/x-python", 75 | "name": "python", 76 | "nbconvert_exporter": "python", 77 | "pygments_lexer": "ipython3", 78 | "version": "3.6.4" 79 | } 80 | }, 81 | "nbformat": 4, 82 | "nbformat_minor": 2 83 | } 84 | -------------------------------------------------------------------------------- /examples/occ_torus_mesh_quality.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import sys\n", 10 | "\n", 11 | "from OCC.Display.WebGl import threejs_renderer\n", 12 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeTorus\n", 13 | "from OCC.gp import gp_Vec\n", 14 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer, NORMAL\n", 15 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox\n", 16 | "\n", 17 | "sys.path.append('..')\n", 18 | "from core_geometry_utils import translate_shp" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "# create 3 toruses\n", 28 | "# be careful to set copy to True or all the shapes will share the same mesh\n", 29 | "torus_shp1 = BRepPrimAPI_MakeTorus(20, 5).Shape()\n", 30 | "torus_shp2 = translate_shp(torus_shp1, gp_Vec(60, 0, 0), copy=True)\n", 31 | "torus_shp3 = translate_shp(torus_shp1, gp_Vec(-60, 0, 0), copy=True)" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "# use the NORMAL.CLIENT_SIDE in order to clearly see faces\n", 41 | "# in case the NORMAL.SERVER_SIDE option is used, vertex normals lead to\n", 42 | "# a smooth rendering\n", 43 | "my_renderer = JupyterRenderer(compute_normals_mode=NORMAL.CLIENT_SIDE)" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": null, 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [ 52 | "my_renderer.DisplayShape(torus_shp1, shape_color=\"blue\", quality=1.) # default quality\n", 53 | "my_renderer.DisplayShape(torus_shp2, shape_color=\"red\", quality=4) # lower quality\n", 54 | "my_renderer.DisplayShape(torus_shp3, shape_color=\"green\", quality=0.5) # better quality" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": null, 60 | "metadata": {}, 61 | "outputs": [], 62 | "source": [ 63 | "my_renderer.Display()" 64 | ] 65 | } 66 | ], 67 | "metadata": { 68 | "kernelspec": { 69 | "display_name": "Python 3", 70 | "language": "python", 71 | "name": "python3" 72 | }, 73 | "language_info": { 74 | "codemirror_mode": { 75 | "name": "ipython", 76 | "version": 3 77 | }, 78 | "file_extension": ".py", 79 | "mimetype": "text/x-python", 80 | "name": "python", 81 | "nbconvert_exporter": "python", 82 | "pygments_lexer": "ipython3", 83 | "version": "3.6.4" 84 | } 85 | }, 86 | "nbformat": 4, 87 | "nbformat_minor": 2 88 | } 89 | -------------------------------------------------------------------------------- /examples/.ipynb_checkpoints/occ_torus_mesh_quality-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import sys\n", 10 | "\n", 11 | "from OCC.Display.WebGl import threejs_renderer\n", 12 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeTorus\n", 13 | "from OCC.gp import gp_Vec\n", 14 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer, NORMAL\n", 15 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox\n", 16 | "\n", 17 | "sys.path.append('..')\n", 18 | "from core_geometry_utils import translate_shp" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "# create 3 toruses\n", 28 | "# be careful to set copy to True or all the shapes will share the same mesh\n", 29 | "torus_shp1 = BRepPrimAPI_MakeTorus(20, 5).Shape()\n", 30 | "torus_shp2 = translate_shp(torus_shp1, gp_Vec(60, 0, 0), copy=True)\n", 31 | "torus_shp3 = translate_shp(torus_shp1, gp_Vec(-60, 0, 0), copy=True)" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "# use the NORMAL.CLIENT_SIDE in order to clearly see faces\n", 41 | "# in case the NORMAL.SERVER_SIDE option is used, vertex normals lead to\n", 42 | "# a smooth rendering\n", 43 | "my_renderer = JupyterRenderer(compute_normals_mode=NORMAL.CLIENT_SIDE)" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": null, 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [ 52 | "my_renderer.DisplayShape(torus_shp1, shape_color=\"blue\", quality=1.) # default quality\n", 53 | "my_renderer.DisplayShape(torus_shp2, shape_color=\"red\", quality=4) # lower quality\n", 54 | "my_renderer.DisplayShape(torus_shp3, shape_color=\"green\", quality=0.5) # better quality" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": null, 60 | "metadata": {}, 61 | "outputs": [], 62 | "source": [ 63 | "my_renderer.Display()" 64 | ] 65 | } 66 | ], 67 | "metadata": { 68 | "kernelspec": { 69 | "display_name": "Python 3", 70 | "language": "python", 71 | "name": "python3" 72 | }, 73 | "language_info": { 74 | "codemirror_mode": { 75 | "name": "ipython", 76 | "version": 3 77 | }, 78 | "file_extension": ".py", 79 | "mimetype": "text/x-python", 80 | "name": "python", 81 | "nbconvert_exporter": "python", 82 | "pygments_lexer": "ipython3", 83 | "version": "3.6.4" 84 | } 85 | }, 86 | "nbformat": 4, 87 | "nbformat_minor": 2 88 | } 89 | -------------------------------------------------------------------------------- /examples/.ipynb_checkpoints/occ_helloworld_slider-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer\n", 10 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "my_renderer = JupyterRenderer()" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": null, 25 | "metadata": {}, 26 | "outputs": [], 27 | "source": [ 28 | "v1=10.\n", 29 | "v2=20.\n", 30 | "v3=30.\n", 31 | "def make_box(v1, v2, v3):\n", 32 | " box_shape = BRepPrimAPI_MakeBox(v1, v2, v3).Shape()\n", 33 | " return box_shape\n", 34 | "box_shape = make_box(10., 20., 30.)" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": null, 40 | "metadata": {}, 41 | "outputs": [], 42 | "source": [ 43 | "my_renderer.DisplayShape(box_shape, render_edges=True)\n", 44 | "my_renderer" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": {}, 51 | "outputs": [], 52 | "source": [ 53 | "from ipywidgets import FloatSlider, HBox, VBox\n", 54 | "v1_slider, v2_slider = (FloatSlider(description='v1', min=10., max=40., step=0.01, value=v1,\n", 55 | " continuous_update=False, orientation='vertical'),\n", 56 | " FloatSlider(description='v2', min=10., max=40., step=0.01, value=v2,\n", 57 | " continuous_update=False, orientation='vertical'))\n", 58 | "def update(change):\n", 59 | " box_shp = make_box(10., v1_slider.value, v2_slider.value)\n", 60 | " my_renderer.DisplayShape(box_shp)\n", 61 | " \n", 62 | "v1_slider.observe(update, names=['value'])\n", 63 | "v2_slider.observe(update, names=['value'])" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": null, 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "HBox([my_renderer._renderer, v1_slider, v2_slider])" 73 | ] 74 | } 75 | ], 76 | "metadata": { 77 | "kernelspec": { 78 | "display_name": "Python 3", 79 | "language": "python", 80 | "name": "python3" 81 | }, 82 | "language_info": { 83 | "codemirror_mode": { 84 | "name": "ipython", 85 | "version": 3 86 | }, 87 | "file_extension": ".py", 88 | "mimetype": "text/x-python", 89 | "name": "python", 90 | "nbconvert_exporter": "python", 91 | "pygments_lexer": "ipython3", 92 | "version": "3.6.4" 93 | } 94 | }, 95 | "nbformat": 4, 96 | "nbformat_minor": 2 97 | } 98 | -------------------------------------------------------------------------------- /examples/occ_load_step_ap203_one_shape.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import random\n", 10 | "import os\n", 11 | "import os.path\n", 12 | "import sys\n", 13 | "\n", 14 | "from OCC.STEPControl import STEPControl_Reader\n", 15 | "from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "def read_step_file(filename):\n", 34 | " \"\"\" read the STEP file and returns a compound\n", 35 | " \"\"\"\n", 36 | " step_reader = STEPControl_Reader()\n", 37 | " status = step_reader.ReadFile(filename)\n", 38 | "\n", 39 | " if status == IFSelect_RetDone: # check status\n", 40 | " failsonly = False\n", 41 | " step_reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity)\n", 42 | " step_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity)\n", 43 | "\n", 44 | " ok = step_reader.TransferRoot(1)\n", 45 | " _nbs = step_reader.NbShapes()\n", 46 | " aResShape = step_reader.Shape(1)\n", 47 | " else:\n", 48 | " print(\"Error: can't read file.\")\n", 49 | " sys.exit(0)\n", 50 | " return aResShape\n", 51 | "\n", 52 | "shp = read_step_file(os.path.join('..', 'models', 'RC_Buggy_2_front_suspension.stp'))" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": {}, 59 | "outputs": [], 60 | "source": [ 61 | "my_renderer = JupyterRenderer(size=(800,800))" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "metadata": {}, 68 | "outputs": [], 69 | "source": [ 70 | "my_renderer.DisplayShape(shp, render_edges=True)" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": null, 76 | "metadata": {}, 77 | "outputs": [], 78 | "source": [ 79 | "my_renderer.Display()" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "metadata": {}, 86 | "outputs": [], 87 | "source": [] 88 | } 89 | ], 90 | "metadata": { 91 | "kernelspec": { 92 | "display_name": "Python 3", 93 | "language": "python", 94 | "name": "python3" 95 | }, 96 | "language_info": { 97 | "codemirror_mode": { 98 | "name": "ipython", 99 | "version": 3 100 | }, 101 | "file_extension": ".py", 102 | "mimetype": "text/x-python", 103 | "name": "python", 104 | "nbconvert_exporter": "python", 105 | "pygments_lexer": "ipython3", 106 | "version": "3.6.4" 107 | } 108 | }, 109 | "nbformat": 4, 110 | "nbformat_minor": 2 111 | } 112 | -------------------------------------------------------------------------------- /examples/.ipynb_checkpoints/occ_load_step_ap203_one_shape-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import random\n", 10 | "import os\n", 11 | "import os.path\n", 12 | "import sys\n", 13 | "\n", 14 | "from OCC.STEPControl import STEPControl_Reader\n", 15 | "from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "def read_step_file(filename):\n", 34 | " \"\"\" read the STEP file and returns a compound\n", 35 | " \"\"\"\n", 36 | " step_reader = STEPControl_Reader()\n", 37 | " status = step_reader.ReadFile(filename)\n", 38 | "\n", 39 | " if status == IFSelect_RetDone: # check status\n", 40 | " failsonly = False\n", 41 | " step_reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity)\n", 42 | " step_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity)\n", 43 | "\n", 44 | " ok = step_reader.TransferRoot(1)\n", 45 | " _nbs = step_reader.NbShapes()\n", 46 | " aResShape = step_reader.Shape(1)\n", 47 | " else:\n", 48 | " print(\"Error: can't read file.\")\n", 49 | " sys.exit(0)\n", 50 | " return aResShape\n", 51 | "\n", 52 | "shp = read_step_file(os.path.join('..', 'models', 'RC_Buggy_2_front_suspension.stp'))" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": {}, 59 | "outputs": [], 60 | "source": [ 61 | "my_renderer = JupyterRenderer(size=(800,800))" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "metadata": {}, 68 | "outputs": [], 69 | "source": [ 70 | "my_renderer.DisplayShape(shp, render_edges=True)" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": null, 76 | "metadata": {}, 77 | "outputs": [], 78 | "source": [ 79 | "my_renderer.Display()" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "metadata": {}, 86 | "outputs": [], 87 | "source": [] 88 | } 89 | ], 90 | "metadata": { 91 | "kernelspec": { 92 | "display_name": "Python 3", 93 | "language": "python", 94 | "name": "python3" 95 | }, 96 | "language_info": { 97 | "codemirror_mode": { 98 | "name": "ipython", 99 | "version": 3 100 | }, 101 | "file_extension": ".py", 102 | "mimetype": "text/x-python", 103 | "name": "python", 104 | "nbconvert_exporter": "python", 105 | "pygments_lexer": "ipython3", 106 | "version": "3.6.4" 107 | } 108 | }, 109 | "nbformat": 4, 110 | "nbformat_minor": 2 111 | } 112 | -------------------------------------------------------------------------------- /examples/occ_load_step_ap203_multiple_shapes.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import random\n", 10 | "import os\n", 11 | "import os.path\n", 12 | "import sys\n", 13 | "\n", 14 | "from OCC.STEPControl import STEPControl_Reader\n", 15 | "from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity\n", 16 | "\n", 17 | "sys.path.append('..')\n", 18 | "from core_topology_traverse import Topo" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer, format_color" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "def read_step_file(filename):\n", 37 | " \"\"\" read the STEP file and returns a compound\n", 38 | " \"\"\"\n", 39 | " step_reader = STEPControl_Reader()\n", 40 | " status = step_reader.ReadFile(filename)\n", 41 | "\n", 42 | " if status == IFSelect_RetDone: # check status\n", 43 | " failsonly = False\n", 44 | " step_reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity)\n", 45 | " step_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity)\n", 46 | "\n", 47 | " ok = step_reader.TransferRoot(1)\n", 48 | " _nbs = step_reader.NbShapes()\n", 49 | " aResShape = step_reader.Shape(1)\n", 50 | " else:\n", 51 | " print(\"Error: can't read file.\")\n", 52 | " sys.exit(0)\n", 53 | " return aResShape\n", 54 | "\n", 55 | "shp = read_step_file(os.path.join('..', 'models', 'RC_Buggy_2_front_suspension.stp')) # this is a compound" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": null, 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [ 64 | "my_renderer = JupyterRenderer(size=(700, 700))\n", 65 | "my_renderer.Display()" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": null, 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "# loop over subshapes so that each subshape is meshed/displayed\n", 75 | "t = Topo(shp)\n", 76 | "from random import randint\n", 77 | "for solid in t.solids():\n", 78 | " random_color = format_color(randint(0,255), randint(0,255), randint(0,255))\n", 79 | " my_renderer.DisplayShape(solid, shape_color=random_color)" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "metadata": {}, 86 | "outputs": [], 87 | "source": [] 88 | } 89 | ], 90 | "metadata": { 91 | "kernelspec": { 92 | "display_name": "Python 3", 93 | "language": "python", 94 | "name": "python3" 95 | }, 96 | "language_info": { 97 | "codemirror_mode": { 98 | "name": "ipython", 99 | "version": 3 100 | }, 101 | "file_extension": ".py", 102 | "mimetype": "text/x-python", 103 | "name": "python", 104 | "nbconvert_exporter": "python", 105 | "pygments_lexer": "ipython3", 106 | "version": "3.6.4" 107 | } 108 | }, 109 | "nbformat": 4, 110 | "nbformat_minor": 2 111 | } 112 | -------------------------------------------------------------------------------- /examples/.ipynb_checkpoints/occ_load_step_ap203_multiple_shapes-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import random\n", 10 | "import os\n", 11 | "import os.path\n", 12 | "import sys\n", 13 | "\n", 14 | "from OCC.STEPControl import STEPControl_Reader\n", 15 | "from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity\n", 16 | "\n", 17 | "sys.path.append('..')\n", 18 | "from core_topology_traverse import Topo" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer, format_color" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "def read_step_file(filename):\n", 37 | " \"\"\" read the STEP file and returns a compound\n", 38 | " \"\"\"\n", 39 | " step_reader = STEPControl_Reader()\n", 40 | " status = step_reader.ReadFile(filename)\n", 41 | "\n", 42 | " if status == IFSelect_RetDone: # check status\n", 43 | " failsonly = False\n", 44 | " step_reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity)\n", 45 | " step_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity)\n", 46 | "\n", 47 | " ok = step_reader.TransferRoot(1)\n", 48 | " _nbs = step_reader.NbShapes()\n", 49 | " aResShape = step_reader.Shape(1)\n", 50 | " else:\n", 51 | " print(\"Error: can't read file.\")\n", 52 | " sys.exit(0)\n", 53 | " return aResShape\n", 54 | "\n", 55 | "shp = read_step_file(os.path.join('..', 'models', 'RC_Buggy_2_front_suspension.stp')) # this is a compound" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": null, 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [ 64 | "my_renderer = JupyterRenderer(size=(700, 700))\n", 65 | "my_renderer.Display()" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": null, 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "# loop over subshapes so that each subshape is meshed/displayed\n", 75 | "t = Topo(shp)\n", 76 | "from random import randint\n", 77 | "for solid in t.solids():\n", 78 | " random_color = format_color(randint(0,255), randint(0,255), randint(0,255))\n", 79 | " my_renderer.DisplayShape(solid, shape_color=random_color)" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "metadata": {}, 86 | "outputs": [], 87 | "source": [] 88 | } 89 | ], 90 | "metadata": { 91 | "kernelspec": { 92 | "display_name": "Python 3", 93 | "language": "python", 94 | "name": "python3" 95 | }, 96 | "language_info": { 97 | "codemirror_mode": { 98 | "name": "ipython", 99 | "version": 3 100 | }, 101 | "file_extension": ".py", 102 | "mimetype": "text/x-python", 103 | "name": "python", 104 | "nbconvert_exporter": "python", 105 | "pygments_lexer": "ipython3", 106 | "version": "3.6.4" 107 | } 108 | }, 109 | "nbformat": 4, 110 | "nbformat_minor": 2 111 | } 112 | -------------------------------------------------------------------------------- /examples/occ_callback.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import sys\n", 10 | "sys.path.append('..')\n", 11 | "\n", 12 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeTorus, BRepPrimAPI_MakeBox, BRepPrimAPI_MakeSphere\n", 13 | "from OCC.gp import gp_Vec\n", 14 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer, NORMAL\n", 15 | "from OCC.GProp import GProp_GProps\n", 16 | "from OCC.BRepGProp import brepgprop_VolumeProperties\n", 17 | "\n", 18 | "from core_geometry_utils import translate_shp" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "# create 3 toruses\n", 28 | "# be careful to set copy to True or all the shapes will share the same mesh\n", 29 | "torus_shp = BRepPrimAPI_MakeTorus(20, 5).Shape()\n", 30 | "box_shp = translate_shp(BRepPrimAPI_MakeBox(10, 20, 3).Shape(), gp_Vec(60, 0, 0))\n", 31 | "sphere_shp = translate_shp(BRepPrimAPI_MakeSphere(20.).Shape(), gp_Vec(-60, 0, 0))" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "# use the NORMAL.CLIENT_SIDE in order to clearly see faces\n", 41 | "# in case the NORMAL.SERVER_SIDE option is used, vertex normals lead to\n", 42 | "# a smooth rendering\n", 43 | "my_renderer = JupyterRenderer()" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": null, 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [ 52 | "#create and register a callback\n", 53 | "# this callback will compute and display shape volume each time a\n", 54 | "# shape is selectd\n", 55 | "def compute_volume(shp):\n", 56 | " props = GProp_GProps()\n", 57 | " brepgprop_VolumeProperties(shp, props)\n", 58 | " # Get inertia properties\n", 59 | " mass = props.Mass()\n", 60 | " cog = props.CentreOfMass()\n", 61 | " matrix_of_inertia = props.MatrixOfInertia()\n", 62 | " # Display inertia properties\n", 63 | " cog_x, cog_y, cog_z = cog.Coord()\n", 64 | " #print(\"Center of mass: x = %f;y = %f;z = %f;\" % (cog_x, cog_y, cog_z))\n", 65 | " html_value = \"Shape volumes = %s
\" % mass\n", 66 | " html_value += \"Center of mass: x = %f;y = %f;z = %f\" % (cog_x, cog_y, cog_z)\n", 67 | " my_renderer.html.value = html_value\n", 68 | "my_renderer.register_select_callback(compute_volume)" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": null, 74 | "metadata": {}, 75 | "outputs": [], 76 | "source": [ 77 | "my_renderer.DisplayShape(torus_shp, shape_color=\"blue\")\n", 78 | "my_renderer.DisplayShape(box_shp, shape_color=\"red\")\n", 79 | "my_renderer.DisplayShape(sphere_shp, shape_color=\"green\")" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "metadata": {}, 86 | "outputs": [], 87 | "source": [ 88 | "my_renderer.Display()" 89 | ] 90 | } 91 | ], 92 | "metadata": { 93 | "kernelspec": { 94 | "display_name": "Python 3", 95 | "language": "python", 96 | "name": "python3" 97 | }, 98 | "language_info": { 99 | "codemirror_mode": { 100 | "name": "ipython", 101 | "version": 3 102 | }, 103 | "file_extension": ".py", 104 | "mimetype": "text/x-python", 105 | "name": "python", 106 | "nbconvert_exporter": "python", 107 | "pygments_lexer": "ipython3", 108 | "version": "3.6.4" 109 | } 110 | }, 111 | "nbformat": 4, 112 | "nbformat_minor": 2 113 | } 114 | -------------------------------------------------------------------------------- /examples/.ipynb_checkpoints/occ_callback-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import sys\n", 10 | "sys.path.append('..')\n", 11 | "\n", 12 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeTorus, BRepPrimAPI_MakeBox, BRepPrimAPI_MakeSphere\n", 13 | "from OCC.gp import gp_Vec\n", 14 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer, NORMAL\n", 15 | "from OCC.GProp import GProp_GProps\n", 16 | "from OCC.BRepGProp import brepgprop_VolumeProperties\n", 17 | "\n", 18 | "from core_geometry_utils import translate_shp" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "# create 3 toruses\n", 28 | "# be careful to set copy to True or all the shapes will share the same mesh\n", 29 | "torus_shp = BRepPrimAPI_MakeTorus(20, 5).Shape()\n", 30 | "box_shp = translate_shp(BRepPrimAPI_MakeBox(10, 20, 3).Shape(), gp_Vec(60, 0, 0))\n", 31 | "sphere_shp = translate_shp(BRepPrimAPI_MakeSphere(20.).Shape(), gp_Vec(-60, 0, 0))" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "# use the NORMAL.CLIENT_SIDE in order to clearly see faces\n", 41 | "# in case the NORMAL.SERVER_SIDE option is used, vertex normals lead to\n", 42 | "# a smooth rendering\n", 43 | "my_renderer = JupyterRenderer()" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": null, 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [ 52 | "#create and register a callback\n", 53 | "# this callback will compute and display shape volume each time a\n", 54 | "# shape is selectd\n", 55 | "def compute_volume(shp):\n", 56 | " props = GProp_GProps()\n", 57 | " brepgprop_VolumeProperties(shp, props)\n", 58 | " # Get inertia properties\n", 59 | " mass = props.Mass()\n", 60 | " cog = props.CentreOfMass()\n", 61 | " matrix_of_inertia = props.MatrixOfInertia()\n", 62 | " # Display inertia properties\n", 63 | " cog_x, cog_y, cog_z = cog.Coord()\n", 64 | " #print(\"Center of mass: x = %f;y = %f;z = %f;\" % (cog_x, cog_y, cog_z))\n", 65 | " html_value = \"Shape volumes = %s
\" % mass\n", 66 | " html_value += \"Center of mass: x = %f;y = %f;z = %f\" % (cog_x, cog_y, cog_z)\n", 67 | " my_renderer.html.value = html_value\n", 68 | "my_renderer.register_select_callback(compute_volume)" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": null, 74 | "metadata": {}, 75 | "outputs": [], 76 | "source": [ 77 | "my_renderer.DisplayShape(torus_shp, shape_color=\"blue\")\n", 78 | "my_renderer.DisplayShape(box_shp, shape_color=\"red\")\n", 79 | "my_renderer.DisplayShape(sphere_shp, shape_color=\"green\")" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "metadata": {}, 86 | "outputs": [], 87 | "source": [ 88 | "my_renderer.Display()" 89 | ] 90 | } 91 | ], 92 | "metadata": { 93 | "kernelspec": { 94 | "display_name": "Python 3", 95 | "language": "python", 96 | "name": "python3" 97 | }, 98 | "language_info": { 99 | "codemirror_mode": { 100 | "name": "ipython", 101 | "version": 3 102 | }, 103 | "file_extension": ".py", 104 | "mimetype": "text/x-python", 105 | "name": "python", 106 | "nbconvert_exporter": "python", 107 | "pygments_lexer": "ipython3", 108 | "version": "3.6.4" 109 | } 110 | }, 111 | "nbformat": 4, 112 | "nbformat_minor": 2 113 | } 114 | -------------------------------------------------------------------------------- /examples/.ipynb_checkpoints/occ_load_step_ap203-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import random\n", 10 | "import os\n", 11 | "import os.path\n", 12 | "import sys\n", 13 | "\n", 14 | "from OCC.STEPControl import STEPControl_Reader\n", 15 | "from OCC.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 2, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 3, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "def read_step_file(filename):\n", 34 | " \"\"\" read the STEP file and returns a compound\n", 35 | " \"\"\"\n", 36 | " step_reader = STEPControl_Reader()\n", 37 | " status = step_reader.ReadFile(filename)\n", 38 | "\n", 39 | " if status == IFSelect_RetDone: # check status\n", 40 | " failsonly = False\n", 41 | " step_reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity)\n", 42 | " step_reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity)\n", 43 | "\n", 44 | " ok = step_reader.TransferRoot(1)\n", 45 | " _nbs = step_reader.NbShapes()\n", 46 | " aResShape = step_reader.Shape(1)\n", 47 | " else:\n", 48 | " print(\"Error: can't read file.\")\n", 49 | " sys.exit(0)\n", 50 | " return aResShape\n", 51 | "\n", 52 | "shp = read_step_file(os.path.join('..', 'models', 'RC_Buggy_2_front_suspension.stp'))" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 4, 58 | "metadata": {}, 59 | "outputs": [], 60 | "source": [ 61 | "my_renderer = JupyterRenderer()" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 5, 67 | "metadata": {}, 68 | "outputs": [ 69 | { 70 | "data": { 71 | "application/vnd.jupyter.widget-view+json": { 72 | "model_id": "31e8731dd2d9458cad5e2f639c9645dd", 73 | "version_major": 2, 74 | "version_minor": 0 75 | }, 76 | "text/html": [ 77 | "

Failed to display Jupyter Widget of type Renderer.

\n", 78 | "

\n", 79 | " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", 80 | " that the widgets JavaScript is still loading. If this message persists, it\n", 81 | " likely means that the widgets JavaScript library is either not installed or\n", 82 | " not enabled. See the Jupyter\n", 83 | " Widgets Documentation for setup instructions.\n", 84 | "

\n", 85 | "

\n", 86 | " If you're reading this message in another frontend (for example, a static\n", 87 | " rendering on GitHub or NBViewer),\n", 88 | " it may mean that your frontend doesn't currently support widgets.\n", 89 | "

\n" 90 | ], 91 | "text/plain": [ 92 | "Renderer(background='white', background_opacity=1.0, camera=PerspectiveCamera(children=[DirectionalLight(color='#ffffff', intensity=0.5, position=[50.0, 50.0, 50.0], scale=[1.0, 1.0, 1.0], up=[0.0, 1.0, 0.0])], position=[0.0, -319.77835558779555, 482.2885442623915], scale=[1.0, 1.0, 1.0], up=[0.0, 1.0, 0.0]), controls=[TrackballControls(controlling=PerspectiveCamera(children=[DirectionalLight(color='#ffffff', intensity=0.5, position=[50.0, 50.0, 50.0], scale=[1.0, 1.0, 1.0], up=[0.0, 1.0, 0.0])], position=[0.0, -319.77835558779555, 482.2885442623915], scale=[1.0, 1.0, 1.0], up=[0.0, 1.0, 0.0]), target=[0.0, 0.0, 0.0])], effect=None, scene=Scene(children=[Mesh(geometry=PlainBufferGeometry(faces=array([[ 0, 1, 2],\n", 93 | " [ 3, 4, 5],\n", 94 | " [ 6, 7, 8],\n", 95 | " ..., \n", 96 | " [1655790, 1655791, 1655792],\n", 97 | " [1655793, 1655794, 1655795],\n", 98 | " [1655796, 1655797, 1655798]], dtype=uint32), vertices=array([[ 13.35946369, 11.34571552, 22.5 ],\n", 99 | " [ 13.54709244, 11.3575201 , 22.5 ],\n", 100 | " [ 13.35946369, 11.34571552, 23.5 ],\n", 101 | " ..., \n", 102 | " [ 28.10727119, 26.04367065, -1.99000001],\n", 103 | " [ 28.15982437, 26.00403404, -1.99000001],\n", 104 | " [ 28.10086632, 26.03387642, -1.99000001]], dtype=float32)), material=PhongMaterial(color='#a6a6a6', envMap=None, lightMap=None, map=None, morphTargets=True, shininess=0.9, specularMap=None), position=[0.0, 0.0, 0.0], scale=[1.0, 1.0, 1.0], up=[0.0, 1.0, 0.0]), AmbientLight(color='#101010', position=[0.0, 0.0, 0.0], scale=[1.0, 1.0, 1.0], up=[0.0, 1.0, 0.0])], position=[0.0, 0.0, 0.0], scale=[1.0, 1.0, 1.0], up=[0.0, 1.0, 0.0]))" 105 | ] 106 | }, 107 | "metadata": {}, 108 | "output_type": "display_data" 109 | } 110 | ], 111 | "source": [ 112 | "my_renderer.DisplayShape(shp)" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": null, 118 | "metadata": {}, 119 | "outputs": [], 120 | "source": [] 121 | } 122 | ], 123 | "metadata": { 124 | "kernelspec": { 125 | "display_name": "Python 3", 126 | "language": "python", 127 | "name": "python3" 128 | }, 129 | "language_info": { 130 | "codemirror_mode": { 131 | "name": "ipython", 132 | "version": 3 133 | }, 134 | "file_extension": ".py", 135 | "mimetype": "text/x-python", 136 | "name": "python", 137 | "nbconvert_exporter": "python", 138 | "pygments_lexer": "ipython3", 139 | "version": "3.6.3" 140 | } 141 | }, 142 | "nbformat": 4, 143 | "nbformat_minor": 2 144 | } 145 | -------------------------------------------------------------------------------- /examples/.ipynb_checkpoints/occ_torus_trait-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from pythreejs import *\n", 10 | "from IPython.display import display, HTML\n", 11 | "from ipywidgets import HTML, Text\n", 12 | "from traitlets import link, dlink\n", 13 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer\n", 14 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeTorus\n", 15 | "from OCC.Visualization import Tesselator\n", 16 | "import numpy as np" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 2, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "def tesselate_torus(r1, r2):\n", 26 | " \"\"\" creates a torus and compute its triangular tesselation \"\"\"\n", 27 | " torus_shape = BRepPrimAPI_MakeTorus(radius_1, radius_2).Shape()\n", 28 | " tess = Tesselator(torus_shape)\n", 29 | " tess.Compute()\n", 30 | " vertices_position = tess.GetVerticesPositionAsTuple()\n", 31 | " number_of_vertices = len(vertices_position)\n", 32 | " np_vertices = np.array(vertices_position, dtype='float32').reshape(int(number_of_vertices / 3), 3)\n", 33 | " nbr_faces = number_of_vertices / 3\n", 34 | " np_faces = np.arange(np_vertices.shape[0], dtype='uint32')\n", 35 | " return np_vertices, np_faces" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 3, 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [ 44 | "radius_1 = 40.\n", 45 | "radius_2 = 10." 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": 4, 51 | "metadata": {}, 52 | "outputs": [ 53 | { 54 | "name": "stdout", 55 | "output_type": "stream", 56 | "text": [ 57 | "40.0 10.0\n" 58 | ] 59 | }, 60 | { 61 | "data": { 62 | "application/vnd.jupyter.widget-view+json": { 63 | "model_id": "4ca380a604d74ead9fbd68e49ba40a66", 64 | "version_major": 2, 65 | "version_minor": 0 66 | }, 67 | "text/html": [ 68 | "

Failed to display Jupyter Widget of type Renderer.

\n", 69 | "

\n", 70 | " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", 71 | " that the widgets JavaScript is still loading. If this message persists, it\n", 72 | " likely means that the widgets JavaScript library is either not installed or\n", 73 | " not enabled. See the Jupyter\n", 74 | " Widgets Documentation for setup instructions.\n", 75 | "

\n", 76 | "

\n", 77 | " If you're reading this message in another frontend (for example, a static\n", 78 | " rendering on GitHub or NBViewer),\n", 79 | " it may mean that your frontend doesn't currently support widgets.\n", 80 | "

\n" 81 | ], 82 | "text/plain": [ 83 | "Renderer(background='white', camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(150.0, 150.0, 150.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), position=(0.0, 100.0, 100.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[TrackballControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(150.0, 150.0, 150.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), position=(0.0, 100.0, 100.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(children=(Mesh(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[ 36.928383 , -9.481597 , -9.822872 ],\n", 84 | " [ 31.321135 , -17.218939 , -9.04827 ],\n", 85 | " [ 34.6193 , -8.888725 , -9.04827 ],\n", 86 | " ...,\n", 87 | " [-33.232265 , 13.157584 , -9.04827 ],\n", 88 | " [-28.916054 , 21.008741 , -9.04827 ],\n", 89 | " [-27.203812 , 19.764727 , -7.7051325]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 3747, 3748, 3749], dtype=uint32))}), material=MeshPhongMaterial(alphaMap=None, aoMap=None, bumpMap=None, color='red', displacementMap=None, emissiveMap=None, envMap=None, lightMap=None, map=None, normalMap=None, normalScale=(1.0, 1.0), shininess=0.9, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), AmbientLight(color='#101010', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())" 90 | ] 91 | }, 92 | "metadata": {}, 93 | "output_type": "display_data" 94 | } 95 | ], 96 | "source": [ 97 | "vert, fac = tesselate_torus(radius_1, radius_2)\n", 98 | "\n", 99 | "buffer_geometry_properties = {'position': BufferAttribute(vert),\n", 100 | " 'index' : BufferAttribute(fac)}\n", 101 | "\n", 102 | "shape_geometry = BufferGeometry(attributes=buffer_geometry_properties)\n", 103 | "shp_material = MeshPhongMaterial(color='red', shininess=0.9)\n", 104 | "shape_mesh = Mesh(geometry=shape_geometry, material = shp_material)\n", 105 | "\n", 106 | "scene_shp = Scene(children=[shape_mesh, AmbientLight(color='#101010')])\n", 107 | "# create a camera\n", 108 | "camera = PerspectiveCamera(position=[0, 100, 100],\n", 109 | " fov=50,\n", 110 | " children=[DirectionalLight(color='#ffffff', position=[150, 150, 150], intensity=0.5)])\n", 111 | "renderer_shp = Renderer(camera=camera,\n", 112 | " background='white',\n", 113 | " background_opacity=1,\n", 114 | " scene = scene_shp,\n", 115 | " controls=[TrackballControls(controlling=camera)])\n", 116 | "renderer_shp" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 5, 122 | "metadata": {}, 123 | "outputs": [], 124 | "source": [ 125 | "from ipywidgets import FloatSlider, HBox, VBox\n", 126 | "\n", 127 | "r1_slider, r2_slider = (FloatSlider(description='radius_1', min=10, max=40, step=1, value=radius_1,\n", 128 | " continuous_update=False, orientation='vertical'),\n", 129 | " FloatSlider(description='radius_2', min=10, max=40, step=0.01, value=radius_2,\n", 130 | " continuous_update=False, orientation='vertical'))" 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": 6, 136 | "metadata": {}, 137 | "outputs": [], 138 | "source": [ 139 | "def update(change):\n", 140 | " global buffer_geometry_properties, shape_geometry, shape_mesh, scene_shp\n", 141 | " \"\"\" called whenever a slide triggers and event \"\"\"\n", 142 | " vert, fac = tesselate_torus(r1_slider.value, r2_slider.value)\n", 143 | " buffer_geometry_properties['position'] = BufferAttribute(vert)\n", 144 | " buffer_geometry_properties['index'] = BufferAttribute(fac)\n", 145 | " shape_geometry = BufferGeometry(attributes=buffer_geometry_properties)\n", 146 | " shape_mesh = Mesh(geometry=shape_geometry, material = shp_material)\n", 147 | " #scene_shp.children = [shape_mesh, AmbientLight(color='#101010')]\n", 148 | " scene_shp.children = list(scene_shp.children) + [shape_mesh]\n", 149 | " \n", 150 | "\n", 151 | "r1_slider.observe(update, names=['value'])\n", 152 | "r2_slider.observe(update, names=['value'])" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": 7, 158 | "metadata": {}, 159 | "outputs": [ 160 | { 161 | "data": { 162 | "application/vnd.jupyter.widget-view+json": { 163 | "model_id": "b6a86cf348074050978586232d91e0af", 164 | "version_major": 2, 165 | "version_minor": 0 166 | }, 167 | "text/html": [ 168 | "

Failed to display Jupyter Widget of type VBox.

\n", 169 | "

\n", 170 | " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", 171 | " that the widgets JavaScript is still loading. If this message persists, it\n", 172 | " likely means that the widgets JavaScript library is either not installed or\n", 173 | " not enabled. See the Jupyter\n", 174 | " Widgets Documentation for setup instructions.\n", 175 | "

\n", 176 | "

\n", 177 | " If you're reading this message in another frontend (for example, a static\n", 178 | " rendering on GitHub or NBViewer),\n", 179 | " it may mean that your frontend doesn't currently support widgets.\n", 180 | "

\n" 181 | ], 182 | "text/plain": [ 183 | "VBox(children=(HBox(children=(Renderer(background='white', camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(150.0, 150.0, 150.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), position=(0.0, 100.0, 100.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[TrackballControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(150.0, 150.0, 150.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), position=(0.0, 100.0, 100.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(children=(Mesh(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[ 36.928383 , -9.481597 , -9.822872 ],\n", 184 | " [ 31.321135 , -17.218939 , -9.04827 ],\n", 185 | " [ 34.6193 , -8.888725 , -9.04827 ],\n", 186 | " ...,\n", 187 | " [-33.232265 , 13.157584 , -9.04827 ],\n", 188 | " [-28.916054 , 21.008741 , -9.04827 ],\n", 189 | " [-27.203812 , 19.764727 , -7.7051325]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 3747, 3748, 3749], dtype=uint32))}), material=MeshPhongMaterial(alphaMap=None, aoMap=None, bumpMap=None, color='red', displacementMap=None, emissiveMap=None, envMap=None, lightMap=None, map=None, normalMap=None, normalScale=(1.0, 1.0), shininess=0.9, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), AmbientLight(color='#101010', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap()), FloatSlider(value=40.0, continuous_update=False, description='radius_1', max=40.0, min=10.0, orientation='vertical', step=1.0), FloatSlider(value=10.0, continuous_update=False, description='radius_2', max=40.0, min=10.0, orientation='vertical', step=0.01))),))" 190 | ] 191 | }, 192 | "metadata": {}, 193 | "output_type": "display_data" 194 | }, 195 | { 196 | "name": "stdout", 197 | "output_type": "stream", 198 | "text": [ 199 | "35.0 10.0\n", 200 | "32.0 10.0\n" 201 | ] 202 | } 203 | ], 204 | "source": [ 205 | "VBox([HBox([renderer_shp, r1_slider, r2_slider])])" 206 | ] 207 | }, 208 | { 209 | "cell_type": "code", 210 | "execution_count": null, 211 | "metadata": {}, 212 | "outputs": [], 213 | "source": [] 214 | } 215 | ], 216 | "metadata": { 217 | "kernelspec": { 218 | "display_name": "Python 3", 219 | "language": "python", 220 | "name": "python3" 221 | }, 222 | "language_info": { 223 | "codemirror_mode": { 224 | "name": "ipython", 225 | "version": 3 226 | }, 227 | "file_extension": ".py", 228 | "mimetype": "text/x-python", 229 | "name": "python", 230 | "nbconvert_exporter": "python", 231 | "pygments_lexer": "ipython3", 232 | "version": "3.6.4" 233 | } 234 | }, 235 | "nbformat": 4, 236 | "nbformat_minor": 2 237 | } 238 | -------------------------------------------------------------------------------- /examples/occ_helloworld_slider.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "from OCC.Display.WebGl.jupyter_renderer import JupyterRenderer\n", 10 | "from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "my_renderer = JupyterRenderer()" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 3, 25 | "metadata": {}, 26 | "outputs": [], 27 | "source": [ 28 | "v1=10.\n", 29 | "v2=20.\n", 30 | "v3=30.\n", 31 | "def make_box(v1, v2, v3):\n", 32 | " box_shape = BRepPrimAPI_MakeBox(v1, v2, v3).Shape()\n", 33 | " return box_shape\n", 34 | "box_shape = make_box(10., 20., 30.)" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 4, 40 | "metadata": {}, 41 | "outputs": [ 42 | { 43 | "data": { 44 | "application/vnd.jupyter.widget-view+json": { 45 | "model_id": "8256b403bd69406782efc59e72612816", 46 | "version_major": 2, 47 | "version_minor": 0 48 | }, 49 | "text/html": [ 50 | "

Failed to display Jupyter Widget of type HTML.

\n", 51 | "

\n", 52 | " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", 53 | " that the widgets JavaScript is still loading. If this message persists, it\n", 54 | " likely means that the widgets JavaScript library is either not installed or\n", 55 | " not enabled. See the Jupyter\n", 56 | " Widgets Documentation for setup instructions.\n", 57 | "

\n", 58 | "

\n", 59 | " If you're reading this message in another frontend (for example, a static\n", 60 | " rendering on GitHub or NBViewer),\n", 61 | " it may mean that your frontend doesn't currently support widgets.\n", 62 | "

\n" 63 | ], 64 | "text/plain": [ 65 | "HTML(value='')" 66 | ] 67 | }, 68 | "metadata": {}, 69 | "output_type": "display_data" 70 | }, 71 | { 72 | "data": { 73 | "application/vnd.jupyter.widget-view+json": { 74 | "model_id": "66dd2846361745f2828ca34f105958ea", 75 | "version_major": 2, 76 | "version_minor": 0 77 | }, 78 | "text/html": [ 79 | "

Failed to display Jupyter Widget of type Renderer.

\n", 80 | "

\n", 81 | " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", 82 | " that the widgets JavaScript is still loading. If this message persists, it\n", 83 | " likely means that the widgets JavaScript library is either not installed or\n", 84 | " not enabled. See the Jupyter\n", 85 | " Widgets Documentation for setup instructions.\n", 86 | "

\n", 87 | "

\n", 88 | " If you're reading this message in another frontend (for example, a static\n", 89 | " rendering on GitHub or NBViewer),\n", 90 | " it may mean that your frontend doesn't currently support widgets.\n", 91 | "

\n" 92 | ], 93 | "text/plain": [ 94 | "Renderer(background='white', camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(50.0, 50.0, 50.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), position=(0.0, -50.00006, 60.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 0.0, 1.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(50.0, 50.0, 50.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), position=(0.0, -50.00006, 60.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 0.0, 1.0)), target=(5.0, 10.0, 15.0)), Picker(controlling=Group(children=(Mesh(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[ 0., 20., 0.],\n", 95 | " [ 0., 0., 30.],\n", 96 | " [ 0., 20., 30.],\n", 97 | " [ 0., 0., 0.],\n", 98 | " [ 0., 0., 30.],\n", 99 | " [ 0., 20., 0.],\n", 100 | " [10., 0., 30.],\n", 101 | " [10., 20., 0.],\n", 102 | " [10., 20., 30.],\n", 103 | " [10., 0., 30.],\n", 104 | " [10., 0., 0.],\n", 105 | " [10., 20., 0.],\n", 106 | " [10., 0., 0.],\n", 107 | " [10., 0., 30.],\n", 108 | " [ 0., 0., 0.],\n", 109 | " [ 0., 0., 0.],\n", 110 | " [10., 0., 30.],\n", 111 | " [ 0., 0., 30.],\n", 112 | " [10., 20., 30.],\n", 113 | " [10., 20., 0.],\n", 114 | " [ 0., 20., 0.],\n", 115 | " [10., 20., 30.],\n", 116 | " [ 0., 20., 0.],\n", 117 | " [ 0., 20., 30.],\n", 118 | " [ 0., 20., 0.],\n", 119 | " [10., 20., 0.],\n", 120 | " [ 0., 0., 0.],\n", 121 | " [ 0., 0., 0.],\n", 122 | " [10., 20., 0.],\n", 123 | " [10., 0., 0.],\n", 124 | " [10., 20., 30.],\n", 125 | " [ 0., 20., 30.],\n", 126 | " [ 0., 0., 30.],\n", 127 | " [10., 20., 30.],\n", 128 | " [ 0., 0., 30.],\n", 129 | " [10., 0., 30.]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 130 | " 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\n", 131 | " 34, 35], dtype=uint32)), 'normal': BufferAttribute(array=array([[-1., -0., 0.],\n", 132 | " [-1., -0., 0.],\n", 133 | " [-1., -0., 0.],\n", 134 | " [-1., -0., 0.],\n", 135 | " [-1., -0., 0.],\n", 136 | " [-1., -0., 0.],\n", 137 | " [ 1., 0., -0.],\n", 138 | " [ 1., 0., -0.],\n", 139 | " [ 1., 0., -0.],\n", 140 | " [ 1., 0., -0.],\n", 141 | " [ 1., 0., -0.],\n", 142 | " [ 1., 0., -0.],\n", 143 | " [ 0., -1., -0.],\n", 144 | " [ 0., -1., -0.],\n", 145 | " [ 0., -1., -0.],\n", 146 | " [ 0., -1., -0.],\n", 147 | " [ 0., -1., -0.],\n", 148 | " [ 0., -1., -0.],\n", 149 | " [-0., 1., 0.],\n", 150 | " [-0., 1., 0.],\n", 151 | " [-0., 1., 0.],\n", 152 | " [-0., 1., 0.],\n", 153 | " [-0., 1., 0.],\n", 154 | " [-0., 1., 0.],\n", 155 | " [-0., -0., -1.],\n", 156 | " [-0., -0., -1.],\n", 157 | " [-0., -0., -1.],\n", 158 | " [-0., -0., -1.],\n", 159 | " [-0., -0., -1.],\n", 160 | " [-0., -0., -1.],\n", 161 | " [ 0., 0., 1.],\n", 162 | " [ 0., 0., 1.],\n", 163 | " [ 0., 0., 1.],\n", 164 | " [ 0., 0., 1.],\n", 165 | " [ 0., 0., 1.],\n", 166 | " [ 0., 0., 1.]], dtype=float32))}), material=MeshPhongMaterial(alphaMap=None, aoMap=None, bumpMap=None, color='#a6a6a6', displacementMap=None, emissiveMap=None, envMap=None, lightMap=None, map=None, normalMap=None, normalScale=(1.0, 1.0), polygonOffset=True, polygonOffsetFactor=1.0, polygonOffsetUnits=1.0, shininess=0.9, specularMap=None), name='36e987559a4341aa9da72f423744c3ea', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[ 0., 0., 0.],\n", 167 | " [ 0., 0., 30.],\n", 168 | " [ 0., 0., 30.],\n", 169 | " [ 0., 20., 30.],\n", 170 | " [ 0., 20., 0.],\n", 171 | " [ 0., 20., 30.],\n", 172 | " [ 0., 0., 0.],\n", 173 | " [ 0., 20., 0.],\n", 174 | " [10., 0., 0.],\n", 175 | " [10., 0., 30.],\n", 176 | " [10., 0., 30.],\n", 177 | " [10., 20., 30.],\n", 178 | " [10., 20., 0.],\n", 179 | " [10., 20., 30.],\n", 180 | " [10., 0., 0.],\n", 181 | " [10., 20., 0.],\n", 182 | " [ 0., 0., 0.],\n", 183 | " [10., 0., 0.],\n", 184 | " [ 0., 0., 30.],\n", 185 | " [10., 0., 30.],\n", 186 | " [ 0., 20., 0.],\n", 187 | " [10., 20., 0.],\n", 188 | " [ 0., 20., 30.],\n", 189 | " [10., 20., 30.]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 190 | " 17, 18, 19, 20, 21, 22, 23], dtype=uint32))}), material=LineBasicMaterial(color='#000000', linewidth=2.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), object=None)], scene=Scene(children=(Group(children=(Mesh(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[ 0., 20., 0.],\n", 191 | " [ 0., 0., 30.],\n", 192 | " [ 0., 20., 30.],\n", 193 | " [ 0., 0., 0.],\n", 194 | " [ 0., 0., 30.],\n", 195 | " [ 0., 20., 0.],\n", 196 | " [10., 0., 30.],\n", 197 | " [10., 20., 0.],\n", 198 | " [10., 20., 30.],\n", 199 | " [10., 0., 30.],\n", 200 | " [10., 0., 0.],\n", 201 | " [10., 20., 0.],\n", 202 | " [10., 0., 0.],\n", 203 | " [10., 0., 30.],\n", 204 | " [ 0., 0., 0.],\n", 205 | " [ 0., 0., 0.],\n", 206 | " [10., 0., 30.],\n", 207 | " [ 0., 0., 30.],\n", 208 | " [10., 20., 30.],\n", 209 | " [10., 20., 0.],\n", 210 | " [ 0., 20., 0.],\n", 211 | " [10., 20., 30.],\n", 212 | " [ 0., 20., 0.],\n", 213 | " [ 0., 20., 30.],\n", 214 | " [ 0., 20., 0.],\n", 215 | " [10., 20., 0.],\n", 216 | " [ 0., 0., 0.],\n", 217 | " [ 0., 0., 0.],\n", 218 | " [10., 20., 0.],\n", 219 | " [10., 0., 0.],\n", 220 | " [10., 20., 30.],\n", 221 | " [ 0., 20., 30.],\n", 222 | " [ 0., 0., 30.],\n", 223 | " [10., 20., 30.],\n", 224 | " [ 0., 0., 30.],\n", 225 | " [10., 0., 30.]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 226 | " 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\n", 227 | " 34, 35], dtype=uint32)), 'normal': BufferAttribute(array=array([[-1., -0., 0.],\n", 228 | " [-1., -0., 0.],\n", 229 | " [-1., -0., 0.],\n", 230 | " [-1., -0., 0.],\n", 231 | " [-1., -0., 0.],\n", 232 | " [-1., -0., 0.],\n", 233 | " [ 1., 0., -0.],\n", 234 | " [ 1., 0., -0.],\n", 235 | " [ 1., 0., -0.],\n", 236 | " [ 1., 0., -0.],\n", 237 | " [ 1., 0., -0.],\n", 238 | " [ 1., 0., -0.],\n", 239 | " [ 0., -1., -0.],\n", 240 | " [ 0., -1., -0.],\n", 241 | " [ 0., -1., -0.],\n", 242 | " [ 0., -1., -0.],\n", 243 | " [ 0., -1., -0.],\n", 244 | " [ 0., -1., -0.],\n", 245 | " [-0., 1., 0.],\n", 246 | " [-0., 1., 0.],\n", 247 | " [-0., 1., 0.],\n", 248 | " [-0., 1., 0.],\n", 249 | " [-0., 1., 0.],\n", 250 | " [-0., 1., 0.],\n", 251 | " [-0., -0., -1.],\n", 252 | " [-0., -0., -1.],\n", 253 | " [-0., -0., -1.],\n", 254 | " [-0., -0., -1.],\n", 255 | " [-0., -0., -1.],\n", 256 | " [-0., -0., -1.],\n", 257 | " [ 0., 0., 1.],\n", 258 | " [ 0., 0., 1.],\n", 259 | " [ 0., 0., 1.],\n", 260 | " [ 0., 0., 1.],\n", 261 | " [ 0., 0., 1.],\n", 262 | " [ 0., 0., 1.]], dtype=float32))}), material=MeshPhongMaterial(alphaMap=None, aoMap=None, bumpMap=None, color='#a6a6a6', displacementMap=None, emissiveMap=None, envMap=None, lightMap=None, map=None, normalMap=None, normalScale=(1.0, 1.0), polygonOffset=True, polygonOffsetFactor=1.0, polygonOffsetUnits=1.0, shininess=0.9, specularMap=None), name='36e987559a4341aa9da72f423744c3ea', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[ 0., 0., 0.],\n", 263 | " [ 0., 0., 30.],\n", 264 | " [ 0., 0., 30.],\n", 265 | " [ 0., 20., 30.],\n", 266 | " [ 0., 20., 0.],\n", 267 | " [ 0., 20., 30.],\n", 268 | " [ 0., 0., 0.],\n", 269 | " [ 0., 20., 0.],\n", 270 | " [10., 0., 0.],\n", 271 | " [10., 0., 30.],\n", 272 | " [10., 0., 30.],\n", 273 | " [10., 20., 30.],\n", 274 | " [10., 20., 0.],\n", 275 | " [10., 20., 30.],\n", 276 | " [10., 0., 0.],\n", 277 | " [10., 20., 0.],\n", 278 | " [ 0., 0., 0.],\n", 279 | " [10., 0., 0.],\n", 280 | " [ 0., 0., 30.],\n", 281 | " [10., 0., 30.],\n", 282 | " [ 0., 20., 0.],\n", 283 | " [10., 20., 0.],\n", 284 | " [ 0., 20., 30.],\n", 285 | " [10., 20., 30.]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 286 | " 17, 18, 19, 20, 21, 22, 23], dtype=uint32))}), material=LineBasicMaterial(color='#000000', linewidth=2.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(50.0, 50.0, 50.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), position=(0.0, -50.00006, 60.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 0.0, 1.0)), AmbientLight(color='#101010', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())" 287 | ] 288 | }, 289 | "metadata": {}, 290 | "output_type": "display_data" 291 | }, 292 | { 293 | "data": { 294 | "text/plain": [] 295 | }, 296 | "execution_count": 4, 297 | "metadata": {}, 298 | "output_type": "execute_result" 299 | } 300 | ], 301 | "source": [ 302 | "my_renderer.DisplayShape(box_shape, render_edges=True)\n", 303 | "my_renderer" 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "execution_count": 5, 309 | "metadata": {}, 310 | "outputs": [], 311 | "source": [ 312 | "from ipywidgets import FloatSlider, HBox, VBox\n", 313 | "v1_slider, v2_slider = (FloatSlider(description='v1', min=10., max=40., step=0.01, value=v1,\n", 314 | " continuous_update=False, orientation='vertical'),\n", 315 | " FloatSlider(description='v2', min=10., max=40., step=0.01, value=v2,\n", 316 | " continuous_update=False, orientation='vertical'))\n", 317 | "def update(change):\n", 318 | " box_shp = make_box(10., v1_slider.value, v2_slider.value)\n", 319 | " my_renderer.DisplayShape(box_shp)\n", 320 | " \n", 321 | "v1_slider.observe(update, names=['value'])\n", 322 | "v2_slider.observe(update, names=['value'])" 323 | ] 324 | }, 325 | { 326 | "cell_type": "code", 327 | "execution_count": 6, 328 | "metadata": {}, 329 | "outputs": [ 330 | { 331 | "data": { 332 | "application/vnd.jupyter.widget-view+json": { 333 | "model_id": "7f61c39c3d9c4a93aa0ba4f389d6be30", 334 | "version_major": 2, 335 | "version_minor": 0 336 | }, 337 | "text/html": [ 338 | "

Failed to display Jupyter Widget of type HBox.

\n", 339 | "

\n", 340 | " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", 341 | " that the widgets JavaScript is still loading. If this message persists, it\n", 342 | " likely means that the widgets JavaScript library is either not installed or\n", 343 | " not enabled. See the Jupyter\n", 344 | " Widgets Documentation for setup instructions.\n", 345 | "

\n", 346 | "

\n", 347 | " If you're reading this message in another frontend (for example, a static\n", 348 | " rendering on GitHub or NBViewer),\n", 349 | " it may mean that your frontend doesn't currently support widgets.\n", 350 | "

\n" 351 | ], 352 | "text/plain": [ 353 | "HBox(children=(Renderer(background='white', camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(50.0, 50.0, 50.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), position=(0.0, -50.00006, 60.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 0.0, 1.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(50.0, 50.0, 50.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), position=(0.0, -50.00006, 60.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 0.0, 1.0)), target=(5.0, 10.0, 15.0)), Picker(controlling=Group(children=(Mesh(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[ 0., 20., 0.],\n", 354 | " [ 0., 0., 30.],\n", 355 | " [ 0., 20., 30.],\n", 356 | " [ 0., 0., 0.],\n", 357 | " [ 0., 0., 30.],\n", 358 | " [ 0., 20., 0.],\n", 359 | " [10., 0., 30.],\n", 360 | " [10., 20., 0.],\n", 361 | " [10., 20., 30.],\n", 362 | " [10., 0., 30.],\n", 363 | " [10., 0., 0.],\n", 364 | " [10., 20., 0.],\n", 365 | " [10., 0., 0.],\n", 366 | " [10., 0., 30.],\n", 367 | " [ 0., 0., 0.],\n", 368 | " [ 0., 0., 0.],\n", 369 | " [10., 0., 30.],\n", 370 | " [ 0., 0., 30.],\n", 371 | " [10., 20., 30.],\n", 372 | " [10., 20., 0.],\n", 373 | " [ 0., 20., 0.],\n", 374 | " [10., 20., 30.],\n", 375 | " [ 0., 20., 0.],\n", 376 | " [ 0., 20., 30.],\n", 377 | " [ 0., 20., 0.],\n", 378 | " [10., 20., 0.],\n", 379 | " [ 0., 0., 0.],\n", 380 | " [ 0., 0., 0.],\n", 381 | " [10., 20., 0.],\n", 382 | " [10., 0., 0.],\n", 383 | " [10., 20., 30.],\n", 384 | " [ 0., 20., 30.],\n", 385 | " [ 0., 0., 30.],\n", 386 | " [10., 20., 30.],\n", 387 | " [ 0., 0., 30.],\n", 388 | " [10., 0., 30.]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 389 | " 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\n", 390 | " 34, 35], dtype=uint32)), 'normal': BufferAttribute(array=array([[-1., -0., 0.],\n", 391 | " [-1., -0., 0.],\n", 392 | " [-1., -0., 0.],\n", 393 | " [-1., -0., 0.],\n", 394 | " [-1., -0., 0.],\n", 395 | " [-1., -0., 0.],\n", 396 | " [ 1., 0., -0.],\n", 397 | " [ 1., 0., -0.],\n", 398 | " [ 1., 0., -0.],\n", 399 | " [ 1., 0., -0.],\n", 400 | " [ 1., 0., -0.],\n", 401 | " [ 1., 0., -0.],\n", 402 | " [ 0., -1., -0.],\n", 403 | " [ 0., -1., -0.],\n", 404 | " [ 0., -1., -0.],\n", 405 | " [ 0., -1., -0.],\n", 406 | " [ 0., -1., -0.],\n", 407 | " [ 0., -1., -0.],\n", 408 | " [-0., 1., 0.],\n", 409 | " [-0., 1., 0.],\n", 410 | " [-0., 1., 0.],\n", 411 | " [-0., 1., 0.],\n", 412 | " [-0., 1., 0.],\n", 413 | " [-0., 1., 0.],\n", 414 | " [-0., -0., -1.],\n", 415 | " [-0., -0., -1.],\n", 416 | " [-0., -0., -1.],\n", 417 | " [-0., -0., -1.],\n", 418 | " [-0., -0., -1.],\n", 419 | " [-0., -0., -1.],\n", 420 | " [ 0., 0., 1.],\n", 421 | " [ 0., 0., 1.],\n", 422 | " [ 0., 0., 1.],\n", 423 | " [ 0., 0., 1.],\n", 424 | " [ 0., 0., 1.],\n", 425 | " [ 0., 0., 1.]], dtype=float32))}), material=MeshPhongMaterial(alphaMap=None, aoMap=None, bumpMap=None, color='#a6a6a6', displacementMap=None, emissiveMap=None, envMap=None, lightMap=None, map=None, normalMap=None, normalScale=(1.0, 1.0), polygonOffset=True, polygonOffsetFactor=1.0, polygonOffsetUnits=1.0, shininess=0.9, specularMap=None), name='36e987559a4341aa9da72f423744c3ea', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[ 0., 0., 0.],\n", 426 | " [ 0., 0., 30.],\n", 427 | " [ 0., 0., 30.],\n", 428 | " [ 0., 20., 30.],\n", 429 | " [ 0., 20., 0.],\n", 430 | " [ 0., 20., 30.],\n", 431 | " [ 0., 0., 0.],\n", 432 | " [ 0., 20., 0.],\n", 433 | " [10., 0., 0.],\n", 434 | " [10., 0., 30.],\n", 435 | " [10., 0., 30.],\n", 436 | " [10., 20., 30.],\n", 437 | " [10., 20., 0.],\n", 438 | " [10., 20., 30.],\n", 439 | " [10., 0., 0.],\n", 440 | " [10., 20., 0.],\n", 441 | " [ 0., 0., 0.],\n", 442 | " [10., 0., 0.],\n", 443 | " [ 0., 0., 30.],\n", 444 | " [10., 0., 30.],\n", 445 | " [ 0., 20., 0.],\n", 446 | " [10., 20., 0.],\n", 447 | " [ 0., 20., 30.],\n", 448 | " [10., 20., 30.]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 449 | " 17, 18, 19, 20, 21, 22, 23], dtype=uint32))}), material=LineBasicMaterial(color='#000000', linewidth=2.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), object=None)], scene=Scene(children=(Group(children=(Mesh(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[ 0., 20., 0.],\n", 450 | " [ 0., 0., 30.],\n", 451 | " [ 0., 20., 30.],\n", 452 | " [ 0., 0., 0.],\n", 453 | " [ 0., 0., 30.],\n", 454 | " [ 0., 20., 0.],\n", 455 | " [10., 0., 30.],\n", 456 | " [10., 20., 0.],\n", 457 | " [10., 20., 30.],\n", 458 | " [10., 0., 30.],\n", 459 | " [10., 0., 0.],\n", 460 | " [10., 20., 0.],\n", 461 | " [10., 0., 0.],\n", 462 | " [10., 0., 30.],\n", 463 | " [ 0., 0., 0.],\n", 464 | " [ 0., 0., 0.],\n", 465 | " [10., 0., 30.],\n", 466 | " [ 0., 0., 30.],\n", 467 | " [10., 20., 30.],\n", 468 | " [10., 20., 0.],\n", 469 | " [ 0., 20., 0.],\n", 470 | " [10., 20., 30.],\n", 471 | " [ 0., 20., 0.],\n", 472 | " [ 0., 20., 30.],\n", 473 | " [ 0., 20., 0.],\n", 474 | " [10., 20., 0.],\n", 475 | " [ 0., 0., 0.],\n", 476 | " [ 0., 0., 0.],\n", 477 | " [10., 20., 0.],\n", 478 | " [10., 0., 0.],\n", 479 | " [10., 20., 30.],\n", 480 | " [ 0., 20., 30.],\n", 481 | " [ 0., 0., 30.],\n", 482 | " [10., 20., 30.],\n", 483 | " [ 0., 0., 30.],\n", 484 | " [10., 0., 30.]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 485 | " 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\n", 486 | " 34, 35], dtype=uint32)), 'normal': BufferAttribute(array=array([[-1., -0., 0.],\n", 487 | " [-1., -0., 0.],\n", 488 | " [-1., -0., 0.],\n", 489 | " [-1., -0., 0.],\n", 490 | " [-1., -0., 0.],\n", 491 | " [-1., -0., 0.],\n", 492 | " [ 1., 0., -0.],\n", 493 | " [ 1., 0., -0.],\n", 494 | " [ 1., 0., -0.],\n", 495 | " [ 1., 0., -0.],\n", 496 | " [ 1., 0., -0.],\n", 497 | " [ 1., 0., -0.],\n", 498 | " [ 0., -1., -0.],\n", 499 | " [ 0., -1., -0.],\n", 500 | " [ 0., -1., -0.],\n", 501 | " [ 0., -1., -0.],\n", 502 | " [ 0., -1., -0.],\n", 503 | " [ 0., -1., -0.],\n", 504 | " [-0., 1., 0.],\n", 505 | " [-0., 1., 0.],\n", 506 | " [-0., 1., 0.],\n", 507 | " [-0., 1., 0.],\n", 508 | " [-0., 1., 0.],\n", 509 | " [-0., 1., 0.],\n", 510 | " [-0., -0., -1.],\n", 511 | " [-0., -0., -1.],\n", 512 | " [-0., -0., -1.],\n", 513 | " [-0., -0., -1.],\n", 514 | " [-0., -0., -1.],\n", 515 | " [-0., -0., -1.],\n", 516 | " [ 0., 0., 1.],\n", 517 | " [ 0., 0., 1.],\n", 518 | " [ 0., 0., 1.],\n", 519 | " [ 0., 0., 1.],\n", 520 | " [ 0., 0., 1.],\n", 521 | " [ 0., 0., 1.]], dtype=float32))}), material=MeshPhongMaterial(alphaMap=None, aoMap=None, bumpMap=None, color='#a6a6a6', displacementMap=None, emissiveMap=None, envMap=None, lightMap=None, map=None, normalMap=None, normalScale=(1.0, 1.0), polygonOffset=True, polygonOffsetFactor=1.0, polygonOffsetUnits=1.0, shininess=0.9, specularMap=None), name='36e987559a4341aa9da72f423744c3ea', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[ 0., 0., 0.],\n", 522 | " [ 0., 0., 30.],\n", 523 | " [ 0., 0., 30.],\n", 524 | " [ 0., 20., 30.],\n", 525 | " [ 0., 20., 0.],\n", 526 | " [ 0., 20., 30.],\n", 527 | " [ 0., 0., 0.],\n", 528 | " [ 0., 20., 0.],\n", 529 | " [10., 0., 0.],\n", 530 | " [10., 0., 30.],\n", 531 | " [10., 0., 30.],\n", 532 | " [10., 20., 30.],\n", 533 | " [10., 20., 0.],\n", 534 | " [10., 20., 30.],\n", 535 | " [10., 0., 0.],\n", 536 | " [10., 20., 0.],\n", 537 | " [ 0., 0., 0.],\n", 538 | " [10., 0., 0.],\n", 539 | " [ 0., 0., 30.],\n", 540 | " [10., 0., 30.],\n", 541 | " [ 0., 20., 0.],\n", 542 | " [10., 20., 0.],\n", 543 | " [ 0., 20., 30.],\n", 544 | " [10., 20., 30.]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 545 | " 17, 18, 19, 20, 21, 22, 23], dtype=uint32))}), material=LineBasicMaterial(color='#000000', linewidth=2.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(50.0, 50.0, 50.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), position=(0.0, -50.00006, 60.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 0.0, 1.0)), AmbientLight(color='#101010', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap()), FloatSlider(value=10.0, continuous_update=False, description='v1', max=40.0, min=10.0, orientation='vertical', step=0.01), FloatSlider(value=20.0, continuous_update=False, description='v2', max=40.0, min=10.0, orientation='vertical', step=0.01)))" 546 | ] 547 | }, 548 | "metadata": {}, 549 | "output_type": "display_data" 550 | } 551 | ], 552 | "source": [ 553 | "HBox([my_renderer._renderer, v1_slider, v2_slider])" 554 | ] 555 | } 556 | ], 557 | "metadata": { 558 | "kernelspec": { 559 | "display_name": "Python 3", 560 | "language": "python", 561 | "name": "python3" 562 | }, 563 | "language_info": { 564 | "codemirror_mode": { 565 | "name": "ipython", 566 | "version": 3 567 | }, 568 | "file_extension": ".py", 569 | "mimetype": "text/x-python", 570 | "name": "python", 571 | "nbconvert_exporter": "python", 572 | "pygments_lexer": "ipython3", 573 | "version": "3.6.4" 574 | } 575 | }, 576 | "nbformat": 4, 577 | "nbformat_minor": 2 578 | } 579 | --------------------------------------------------------------------------------