Skip to content

Commit

Permalink
update examples and notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Marchais committed Jul 4, 2022
1 parent b5b3b5d commit 22f1b72
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 593,046 deletions.
14,902 changes: 0 additions & 14,902 deletions examples/fibers/fibers.csv

This file was deleted.

69 changes: 0 additions & 69 deletions examples/fibers/fibers.py

This file was deleted.

62 changes: 7 additions & 55 deletions examples/jupyter_notebooks/ellipsoid_sidecar.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,57 +19,16 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting auto display for cadquery Workplane and Shape\n",
" \n"
]
},
{
"data": {
"text/plain": [
"<cad_viewer_widget.widget.CadViewer at 0x7f669af6b2e0>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import numpy as np\n",
"import cadquery as cq\n",
"import gmsh\n",
"from microgen import *\n",
"\n",
"nx=30\n",
"ny=30\n",
"nz=30\n",
"\n",
"x_ = np.linspace(0., 1., nx)\n",
"y_ = np.linspace(0., 1., ny)\n",
"z_ = np.linspace(0., 1., nz)\n",
"\n",
"x, y, z = np.meshgrid(x_, y_, z_, indexing='ij')\n",
"\n",
"#Size of the mesh\n",
"a = 1.0\n",
"b = 1.0\n",
"c = 1.0\n",
"\n",
"periodicity = 0\n",
"Revel = Rve(a,b,c)\n",
"phases = []\n",
"\n",
"S = BasicGeometry(101,'ellipsoid', 0.5, 0.5, 0.5, 0, 0, 0, {\"a_x\": 0.3, \"a_y\": 0.3, \"a_z\": 0.4}, '')\n",
"elli = S.generate()\n",
"ellipsoid = Ellipsoid(a_x=0.3, a_y=0.3, a_z=0.4)\n",
"shape = ellipsoid.generate()\n",
"\n",
"listSolids = elli.Solids()\n",
"solids = shape.Solids()\n",
"\n",
"from jupyter_cadquery import show, set_defaults, open_viewer\n",
"from jupyter_cadquery.replay import enable_replay, disable_replay, reset_replay, get_context, replay, Replay, _CTX\n",
Expand All @@ -79,15 +38,8 @@
"\n",
"set_defaults(reset_camera=True, show_parent=False, axes=True, axes0=True)\n",
"\n",
"show(listSolids[0])"
"show(solids[0])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -106,7 +58,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.11"
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down
77 changes: 7 additions & 70 deletions examples/jupyter_notebooks/ellipsoid_vtp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,78 +23,15 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import cadquery as cq\n",
"import gmsh\n",
"from microgen import *\n",
"import pyvista as pv\n",
"\n",
"nx=30\n",
"ny=30\n",
"nz=30\n",
"ellipsoid = Ellipsoid(a_x=0.3, a_y=0.3, a_z=0.4)\n",
"polydata = ellipsoid.generateVtk()\n",
"\n",
"x_ = np.linspace(0., 1., nx)\n",
"y_ = np.linspace(0., 1., ny)\n",
"z_ = np.linspace(0., 1., nz)\n",
"\n",
"x, y, z = np.meshgrid(x_, y_, z_, indexing='ij')\n",
"\n",
"#Size of the mesh\n",
"a = 1.0\n",
"b = 1.0\n",
"c = 1.0\n",
"\n",
"periodicity = 0\n",
"Revel = Rve(a,b,c)\n",
"phases = []\n",
"\n",
"S = BasicGeometry(101,'ellipsoid', 0.5, 0.5, 0.5, 0, 0, 0, {\"a_x\": 0.3, \"a_y\": 0.3, \"a_z\": 0.4}, '')\n",
"elli = S.generate()\n",
"\n",
"listSolids = elli.Solids()\n",
"\n",
"\n",
"\n",
"compound = cq.Compound.makeCompound(listSolids)\n",
"cq.exporters.export(compound, 'compound.vtp')\n",
"\n",
"\n",
"\n",
"\n",
"import vtk\n",
"from ipyvtklink.viewer import ViewInteractiveWidget\n",
"\n",
"\n",
"colors = vtk.vtkNamedColors()\n",
"\n",
"reader = vtk.vtkXMLPolyDataReader()\n",
"reader.SetFileName('compound.vtp')\n",
"reader.Update()\n",
"\n",
"mapper = vtk.vtkPolyDataMapper()\n",
"mapper.SetInputConnection(reader.GetOutputPort())\n",
"\n",
"actor = vtk.vtkActor()\n",
"actor.SetMapper(mapper)\n",
"actor.GetProperty().SetColor(colors.GetColor3d('Tan'))\n",
"\n",
"# Create a rendering window and renderer\n",
"ren = vtk.vtkRenderer()\n",
"renWin = vtk.vtkRenderWindow()\n",
"renWin.SetOffScreenRendering(1)\n",
"renWin.SetSize(600, 600)\n",
"renWin.AddRenderer(ren)\n",
"\n",
"# Create a renderwindowinteractor\n",
"iren = vtk.vtkRenderWindowInteractor()\n",
"iren.SetRenderWindow(renWin)\n",
"style = vtk.vtkInteractorStyleTrackballCamera()\n",
"iren.SetInteractorStyle(style)\n",
"\n",
"# Assign actor to the renderer\n",
"ren.AddActor(actor)\n",
"ren.ResetCamera()\n",
"\n",
"ViewInteractiveWidget(renWin)"
"pl = pv.Plotter()\n",
"pl.add_mesh(polydata)\n",
"pl.show()"
]
}
],
Expand All @@ -117,7 +54,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.11"
"version": "3.9.13"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 22f1b72

Please sign in to comment.