28 def main(filenameIn,filenameOut,xmin,ymin,zmin,dx,dy,dz,render):
31 reader = vtk.vtkSTLReader()
32 reader.SetFileName(filenameIn)
38 [xmin+dx,ymin+dy,zmin+dz],
39 [xmin+dx,ymin+dy,zmin+dz],
40 [xmin+dx,ymin+dy,zmin+dz],
43 [[-1,0,0],[0,-1,0],[0,0,-1],[-1,0,0],[0,-1,0],[0,0,-1]],
44 [[+1,0,0],[0,-1,0],[0,0,-1],[-1,0,0],[0,-1,0],[0,0,-1]],
45 [[+1,0,0],[0,-1,0],[0,0,-1],[+1,0,0],[0,-1,0],[0,0,-1]],
46 [[-1,0,0],[0,+1,0],[0,0,-1],[-1,0,0],[0,-1,0],[0,0,-1]],
47 [[+1,0,0],[0,+1,0],[0,0,-1],[-1,0,0],[0,-1,0],[0,0,-1]],
48 [[+1,0,0],[0,+1,0],[0,0,-1],[+1,0,0],[0,-1,0],[0,0,-1]],
49 [[-1,0,0],[0,+1,0],[0,0,-1],[-1,0,0],[0,+1,0],[0,0,-1]],
50 [[+1,0,0],[0,+1,0],[0,0,-1],[-1,0,0],[0,+1,0],[0,0,-1]],
51 [[+1,0,0],[0,+1,0],[0,0,-1],[+1,0,0],[0,+1,0],[0,0,-1]],
53 [[-1,0,0],[0,-1,0],[0,0,+1],[-1,0,0],[0,-1,0],[0,0,-1]],
54 [[+1,0,0],[0,-1,0],[0,0,+1],[-1,0,0],[0,-1,0],[0,0,-1]],
55 [[+1,0,0],[0,-1,0],[0,0,+1],[+1,0,0],[0,-1,0],[0,0,-1]],
56 [[-1,0,0],[0,+1,0],[0,0,+1],[-1,0,0],[0,-1,0],[0,0,-1]],
57 [[+1,0,0],[0,+1,0],[0,0,+1],[-1,0,0],[0,-1,0],[0,0,-1]],
58 [[+1,0,0],[0,+1,0],[0,0,+1],[+1,0,0],[0,-1,0],[0,0,-1]],
59 [[-1,0,0],[0,+1,0],[0,0,+1],[-1,0,0],[0,+1,0],[0,0,-1]],
60 [[+1,0,0],[0,+1,0],[0,0,+1],[-1,0,0],[0,+1,0],[0,0,-1]],
61 [[+1,0,0],[0,+1,0],[0,0,+1],[+1,0,0],[0,+1,0],[0,0,-1]],
63 [[-1,0,0],[0,-1,0],[0,0,+1],[-1,0,0],[0,-1,0],[0,0,+1]],
64 [[+1,0,0],[0,-1,0],[0,0,+1],[-1,0,0],[0,-1,0],[0,0,+1]],
65 [[+1,0,0],[0,-1,0],[0,0,+1],[+1,0,0],[0,-1,0],[0,0,+1]],
66 [[-1,0,0],[0,+1,0],[0,0,+1],[-1,0,0],[0,-1,0],[0,0,+1]],
67 [[+1,0,0],[0,+1,0],[0,0,+1],[-1,0,0],[0,-1,0],[0,0,+1]],
68 [[+1,0,0],[0,+1,0],[0,0,+1],[+1,0,0],[0,-1,0],[0,0,+1]],
69 [[-1,0,0],[0,+1,0],[0,0,+1],[-1,0,0],[0,+1,0],[0,0,+1]],
70 [[+1,0,0],[0,+1,0],[0,0,+1],[-1,0,0],[0,+1,0],[0,0,+1]],
71 [[+1,0,0],[0,+1,0],[0,0,+1],[+1,0,0],[0,+1,0],[0,0,+1]],
110 plane.SetOrigin(Origins[i])
111 plane.SetNormal(Normals[j][i])
112 clipper = vtk.vtkClipPolyData()
113 clipper.SetInputConnection(polydata.GetOutputPort())
114 clipper.SetClipFunction(plane)
118 if polydata.GetOutput().GetLength()>0:
119 transform = vtk.vtkTransform()
120 transform.Translate(Direction[j])
121 transformFilter = vtk.vtkTransformPolyDataFilter()
122 transformFilter.SetTransform(transform)
123 transformFilter.SetInputConnection(polydata.GetOutputPort())
124 transformFilter.Update()
125 regions.append(vtk.vtkPolyData())
126 regions[j].ShallowCopy(transformFilter.GetOutput())
128 regions.append(vtk.vtkPolyData())
129 regions[j].ShallowCopy(polydata.GetOutput())
131 appendFilter = vtk.vtkAppendPolyData()
132 if vtk.VTK_MAJOR_VERSION <= 5:
134 appendFilter.AddInputConnection(regions[j].GetProducerPort())
137 appendFilter.AddInputData(regions[j])
138 appendFilter.Update()
140 cleanFilter = vtk.vtkCleanPolyData()
141 cleanFilter.SetInputConnection(appendFilter.GetOutputPort())
164 finalData=cleanFilter
166 stlWriter = vtk.vtkSTLWriter()
167 stlWriter.SetFileName(filenameOut)
168 stlWriter.SetInputConnection(finalData.GetOutputPort())
172 mapper = vtk.vtkPolyDataMapper()
173 if vtk.VTK_MAJOR_VERSION <= 5:
174 mapper.SetInput(finalData.GetOutput())
176 mapper.SetInputConnection(finalData.GetOutputPort())
177 actor = vtk.vtkActor()
178 actor.SetMapper(mapper)
180 ren = vtk.vtkRenderer()
181 renWin = vtk.vtkRenderWindow()
182 renWin.AddRenderer(ren)
184 iren = vtk.vtkRenderWindowInteractor()
185 iren.SetRenderWindow(renWin)
def main(filenameIn, filenameOut, xmin, ymin, zmin, dx, dy, dz, render)
Main function for manipulation with RVE.