def test_meshIO(self): print("Testing Mesh I/O") try: vtkutils.writeMesh(TestVTKUtils.BALL, "ball.stl") vtkutils.writeMesh(TestVTKUtils.BALL, "ball.vtk") vtkutils.writeMesh(TestVTKUtils.BALL, "ball.ply") except: print("Bad write") self.fail("writeMesh failed") try: m = vtkutils.readMesh("ball.stl") print("Read", m.GetNumberOfPolys(), "polygons") m = vtkutils.readMesh("ball.vtk") print("Read", m.GetNumberOfPolys(), "polygons") m = vtkutils.readMesh("ball.ply") print("Read", m.GetNumberOfPolys(), "polygons") except: print("Bad read") self.fail("readMesh failed")
print("Cleaning mesh") mesh2 = vtkutils.cleanMesh(mesh, connectivityFilter) mesh = None gc.collect() if debug: print("Smoothing mesh", smoothIterations, "iterations") mesh3 = vtkutils.smoothMesh(mesh2, smoothIterations) mesh2 = None gc.collect() if debug: print("Simplifying mesh") mesh4 = vtkutils.reduceMesh(mesh3, quad) mesh3 = None gc.collect() if rotFlag: mesh5 = vtkutils.rotateMesh(mesh4, rotAxis, rotAngle) else: mesh5 = mesh4 vtkutils.writeMesh(mesh5, outname) mesh4 = None gc.collect() # remove the temp directory import shutil if cleanUp: shutil.rmtree(tempDir) print("") print('Execution Time: ', datetime.datetime.now() - begin_time) print("")
print("Cleaning mesh") mesh2 = vtkutils.cleanMesh(mesh, connectivityFilter) mesh = None gc.collect() if args.debug: print("Smoothing mesh", args.smooth, "iterations") mesh3 = vtkutils.smoothMesh(mesh2, args.smooth) mesh2 = None gc.collect() if args.debug: print("Simplifying mesh") mesh4 = vtkutils.reduceMesh(mesh3, args.reduce) mesh3 = None gc.collect() axis_map = {'X': 0, 'Y': 1, 'Z': 2} rotAxis = axis_map[args.rotaxis] if args.rotangle != 0.0: mesh5 = vtkutils.rotateMesh(mesh4, rotAxis, args.rotangle) else: mesh5 = mesh4 vtkutils.writeMesh(mesh5, args.output) mesh4 = None gc.collect() # remove the temp directory if args.clean: shutil.rmtree(tempDir) print("")
gc.collect() if rotFlag: mesh5 = vtkutils.rotateMesh(mesh4, rotAxis, rotAngle) else: mesh5 = mesh4 # Outdir verification if outname[0] == '/': if not os.path.exists(outname): os.makedirs(outname) else: if not os.path.exists(os.getcwd() + '/' + outname): os.makedirs(os.getcwd() + '/' + outname) vtkutils.writeMesh(mesh5, outname_subdir) mesh4 = None gc.collect() # remove the temp directory if cleanUp: shutil.rmtree(tempDir) tempDir = "" logging.info("") logging.info('#####') logging.info('STL FILE SAVED: ' + outname_subdir) logging.info('Execution Time: ' + str(datetime.datetime.now() - begin_time)) logging.info( str("Progress %: {0:.0%}".format(counter / len(sub_dirs))))