Skip to content
Snippets Groups Projects
Commit b1c4b46f authored by ojs1g14's avatar ojs1g14
Browse files

import ipywidgets

parent ccf4681b
No related branches found
No related tags found
No related merge requests found
Pipeline #226 passed
No preview for this file type
No preview for this file type
This diff is collapsed.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Test Output # Test Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import matplotlib as plt import matplotlib as plt
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import numpy as np import numpy as np
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print("Hello world") print("Hello world")
``` ```
%% Output %% Output
Hello world Hello world
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
This is a paragraph This is a paragraph
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
from IPython.display import Image from IPython.display import Image
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Image(url='http://jupyter.org/assets/nav_logo.svg') Image(url='http://jupyter.org/assets/nav_logo.svg')
``` ```
%% Output %% Output
<IPython.core.display.Image object> <IPython.core.display.Image object>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
from pythreejs import * from pythreejs import *
from math import pi from math import pi
import ipywidgets
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
CylinderGeometry( cg = CylinderGeometry(
radiusTop=5, radiusTop=5,
radiusBottom=10, radiusBottom=10,
height=15, height=15,
radialSegments=6, radialSegments=6,
heightSegments=10, heightSegments=10,
openEnded=False, openEnded=False,
thetaStart=0, thetaStart=0,
thetaLength=2.0*pi) thetaLength=2.0*pi)
display(cg)
``` ```
%% Output %% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
vertices = [ vertices = [
[0, 0, 0], [0, 0, 0],
[0, 0, 1], [0, 0, 1],
[0, 1, 0], [0, 1, 0],
[0, 1, 1], [0, 1, 1],
[1, 0, 0], [1, 0, 0],
[1, 0, 1], [1, 0, 1],
[1, 1, 0], [1, 1, 0],
[1, 1, 1] [1, 1, 1]
] ]
faces = [ faces = [
[0, 1, 3], [0, 1, 3],
[0, 3, 2], [0, 3, 2],
[0, 2, 4], [0, 2, 4],
[2, 6, 4], [2, 6, 4],
[0, 4, 1], [0, 4, 1],
[1, 4, 5], [1, 4, 5],
[2, 3, 6], [2, 3, 6],
[3, 7, 6], [3, 7, 6],
[1, 5, 3], [1, 5, 3],
[3, 5, 7], [3, 5, 7],
[4, 6, 5], [4, 6, 5],
[5, 6, 7] [5, 6, 7]
] ]
vertexcolors = ['#000000', '#0000ff', '#00ff00', '#ff0000', vertexcolors = ['#000000', '#0000ff', '#00ff00', '#ff0000',
'#00ffff', '#ff00ff', '#ffff00', '#ffffff'] '#00ffff', '#ff00ff', '#ffff00', '#ffffff']
# Map the vertex colors into the 'color' slot of the faces # Map the vertex colors into the 'color' slot of the faces
faces = [f + [None, [vertexcolors[i] for i in f]] for f in faces] faces = [f + [None, [vertexcolors[i] for i in f]] for f in faces]
# Create the geometry: # Create the geometry:
cubeGeometry = Geometry(vertices=vertices, cubeGeometry = Geometry(vertices=vertices,
faces=faces, faces=faces,
colors=vertexcolors) colors=vertexcolors)
# Calculate normals per face, for nice crisp edges: # Calculate normals per face, for nice crisp edges:
cubeGeometry.exec_three_obj_method('computeFaceNormals') cubeGeometry.exec_three_obj_method('computeFaceNormals')
# Create a mesh. Note that the material need to be told to use the vertex colors. # Create a mesh. Note that the material need to be told to use the vertex colors.
myobjectCube = Mesh( myobjectCube = Mesh(
geometry=cubeGeometry, geometry=cubeGeometry,
material=MeshLambertMaterial(vertexColors='VertexColors'), material=MeshLambertMaterial(vertexColors='VertexColors'),
position=[-0.5, -0.5, -0.5], # Center the cube position=[-0.5, -0.5, -0.5], # Center the cube
) )
# Set up a scene and render it: # Set up a scene and render it:
cCube = PerspectiveCamera(position=[3, 3, 3], fov=20, cCube = PerspectiveCamera(position=[3, 3, 3], fov=20,
children=[DirectionalLight(color='#ffffff', position=[-3, 5, 1], intensity=0.5)]) children=[DirectionalLight(color='#ffffff', position=[-3, 5, 1], intensity=0.5)])
sceneCube = Scene(children=[myobjectCube, cCube, AmbientLight(color='#dddddd')]) sceneCube = Scene(children=[myobjectCube, cCube, AmbientLight(color='#dddddd')])
rendererCube = Renderer(camera=cCube, background='black', background_opacity=1, rendererCube = Renderer(camera=cCube, background='black', background_opacity=1,
scene=sceneCube, controls=[OrbitControls(controlling=cCube)]) scene=sceneCube, controls=[OrbitControls(controlling=cCube)])
display(rendererCube) display(rendererCube)
``` ```
%% Output %% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
from AmpScan import AmpObject from AmpScan import AmpObject
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Amp = AmpObject("sample_stl_sphere_BIN.stl") Amp = AmpObject("sample_stl_sphere_BIN.stl")
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Amp.vert Amp.vert
``` ```
%% Output %% Output
array([[-1. , 0. , 0. ], array([[-1. , 0. , 0. ],
[-0.9904389, -0.1379523, 0. ], [-0.9904389, -0.1379523, 0. ],
[-0.9904389, 0.1379523, 0. ], [-0.9904389, 0.1379523, 0. ],
..., ...,
[ 0.9904389, -0.1379523, 0. ], [ 0.9904389, -0.1379523, 0. ],
[ 0.9904389, 0.1379523, 0. ], [ 0.9904389, 0.1379523, 0. ],
[ 1. , 0. , 0. ]], dtype=float32) [ 1. , 0. , 0. ]], dtype=float32)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Amp.faces Amp.faces
``` ```
%% Output %% Output
array([[454, 453, 412], array([[454, 453, 412],
[406, 454, 412], [406, 454, 412],
[496, 453, 454], [496, 453, 454],
..., ...,
[ 57, 77, 87], [ 57, 77, 87],
[101, 109, 77], [101, 109, 77],
[133, 87, 109]]) [133, 87, 109]])
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
vertices = list(Amp.vert) vertices = list(Amp.vert)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Amp.vert Amp.vert
``` ```
%% Output %% Output
array([[-1. , 0. , 0. ], array([[-1. , 0. , 0. ],
[-0.9904389, -0.1379523, 0. ], [-0.9904389, -0.1379523, 0. ],
[-0.9904389, 0.1379523, 0. ], [-0.9904389, 0.1379523, 0. ],
..., ...,
[ 0.9904389, -0.1379523, 0. ], [ 0.9904389, -0.1379523, 0. ],
[ 0.9904389, 0.1379523, 0. ], [ 0.9904389, 0.1379523, 0. ],
[ 1. , 0. , 0. ]], dtype=float32) [ 1. , 0. , 0. ]], dtype=float32)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import numpy import numpy
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
vertices = Amp.vert vertices = Amp.vert
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
vertices=vertices.tolist() vertices=vertices.tolist()
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
faces = Amp.faces faces = Amp.faces
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
faces = faces.tolist() faces = faces.tolist()
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Geometry(vertices=vertices, faces=faces) Geometry(vertices=vertices, faces=faces)
``` ```
%% Output %% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Amp2 = AmpObject("M8_Cast1_Scan1.stl") Amp2 = AmpObject("M8_Cast1_Scan1.stl")
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
scanvert=Amp2.vert scanvert=Amp2.vert
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
scanvert=scanvert.tolist() scanvert=scanvert.tolist()
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
scanfaces=Amp2.faces scanfaces=Amp2.faces
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
scanfaces=scanfaces.tolist() scanfaces=scanfaces.tolist()
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
vertexcolors = ['#000000', '#0000ff', '#00ff00', '#ff0000', vertexcolors = ['#000000', '#0000ff', '#00ff00', '#ff0000',
'#00ffff', '#ff00ff', '#ffff00', '#ffffff'] '#00ffff', '#ff00ff', '#ffff00', '#ffffff']
Geometry(vertices=scanvert, faces=scanfaces, colors=vertexcolors) Geometry(vertices=scanvert, faces=scanfaces, colors=vertexcolors)
``` ```
%% Output %% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
scangeom =Geometry(vertices=scanvert, faces=scanfaces, colors=vertexcolors) scangeom =Geometry(vertices=scanvert, faces=scanfaces, colors=vertexcolors)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
myobject = Mesh( myobject = Mesh(
geometry=scangeom, geometry=scangeom,
material=MeshLambertMaterial(color='red') material=MeshLambertMaterial(color='red')
) )
scene.background="#ffffff" scene.background="#ffffff"
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
myobject myobject
``` ```
%% Output %% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment