Good morning,
I am very new at Python and my skills are pretty limited. I am asking here for advices/libraries/functions to look at that may help me to achieve my goal.
I am trying to code a program that generates a scaffold based on a particular minimal surface named "gyroid". My final goal is to create an .obj file (that I will afterwards modify with other softwares) in order to 3D print it and proceed to mechanical tests. To visualize it better, you can look at page 3 of this publication : http://core.ac.uk/download/pdf/82090411.pdf
I already achieved to generate a gyroid surface using VTK (see below, my code is probably not well constructed). This code duplicates the surface of a gyroid unit cell (U) to build a rectangular beam (2*2*8 U)
(1) Thicken this surface and keeping it in the 2*2*8 U beam. I couldn't find any function that thicken a surface as lines can be thicken for instance.
(2) This thickness must be non-linear for mechanical reasons : small thickness around the middle of the beam and bigger thickness near the beam extreme edges.
(3) Add 2 cubes of 2*2*2 U, one at each extreme edge (for the clamping claws)
Many thanks!
Marie
I am very new at Python and my skills are pretty limited. I am asking here for advices/libraries/functions to look at that may help me to achieve my goal.
I am trying to code a program that generates a scaffold based on a particular minimal surface named "gyroid". My final goal is to create an .obj file (that I will afterwards modify with other softwares) in order to 3D print it and proceed to mechanical tests. To visualize it better, you can look at page 3 of this publication : http://core.ac.uk/download/pdf/82090411.pdf
I already achieved to generate a gyroid surface using VTK (see below, my code is probably not well constructed). This code duplicates the surface of a gyroid unit cell (U) to build a rectangular beam (2*2*8 U)
import numpy as np import vtk # VTK version 7.0 from mayavi import mlab # mayavi version 4.4.4 from mayavi.api import Engine, OffScreenEngine from tvtk.api import tvtk cos = np.cos sin = np.sin pi = np.pi def gyroid(x,y,z): return cos(x)*sin(y) + cos(y)*sin(z) + cos(z)*sin(x) [nx, ny, nz] = [2, 2, 8] # amount of unit cells # Meshgrid x, y, z = np.mgrid[0:nx*2*pi:100j,0:ny*2*pi:100j,0:nz*2*pi:100j] #engine = Engine() engine = OffScreenEngine() # do not start mayavi GUI engine.start() # create a Source : TPMS surface using mayavi.mlab fig = mlab.figure(figure=None, engine=engine) contour3d = mlab.contour3d(x, y, z, gyroid(x, y, z), figure=fig) scene = engine.scenes[0] actor = contour3d.actor.actors[0] iso_surface = scene.children[0].children[0].children[0] iso_surface.contour.minimum_contour = 0 # Minimum contour : 0 sheet / 1 skeletal iso_surface.contour.number_of_contours = 1 iso_surface.compute_normals = False iso_surface.contour.auto_update_range = False mlab.draw(fig) # mlab.show() # enable if you want to see the mayavi GUI polydata = tvtk.to_vtk(actor.mapper.input) # convert tvtkPolyData to vtkPolyData # Move object to the coordinate center to make clipping easier later on. center_coords = np.array(polydata.GetCenter()) center = vtk.vtkTransform() center.Translate(-center_coords[0], -center_coords[1], -center_coords[2]) centerFilter = vtk.vtkTransformPolyDataFilter() centerFilter.SetTransform(center) centerFilter.SetInputData(polydata) centerFilter.Update() # Render the result mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(centerFilter.GetOutputPort()) actor = vtk.vtkActor() actor.SetMapper(mapper) renderer = vtk.vtkRenderer() renderWindow = vtk.vtkRenderWindow() renderWindow.AddRenderer(renderer) renderWindowInteractor = vtk.vtkRenderWindowInteractor() renderWindowInteractor.SetRenderWindow(renderWindow) renderer.AddActor(actor) renderWindow.Render() renderWindowInteractor.Start()Now I wish to:
(1) Thicken this surface and keeping it in the 2*2*8 U beam. I couldn't find any function that thicken a surface as lines can be thicken for instance.
(2) This thickness must be non-linear for mechanical reasons : small thickness around the middle of the beam and bigger thickness near the beam extreme edges.
(3) Add 2 cubes of 2*2*2 U, one at each extreme edge (for the clamping claws)
Many thanks!
Marie