Surface thickening VTK - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Surface thickening VTK (/thread-15101.html) |
Surface thickening VTK - mPirs - Jan-04-2019 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) 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 RE: Surface thickening VTK - Larz60+ - Jan-04-2019 A good place to look for libraries (packages) is https://pypi.org/ There are 163,577 projects to choose from. A quick search for gyroid brings up: https://pypi.org/project/gyroid/ You can do a better search as you are more familiar with the terminology. RE: Surface thickening VTK - mPirs - Jan-07-2019 Thank you Larz60+ for your reply. I tried to use the gyroid.py package as you suggested but I get a error message. Plus, this package generates a gyroid surface and I wish to thicken this surface to create a solid, I am not sure this package is relevant for my work. I keep searching! RE: Surface thickening VTK - Larz60+ - Jan-07-2019 Quote:but I get a error messageA bit more detail would be appreciated. I only pointed to that package as an example of what's available, it was not a recommendation as I have never used it. |