def test_compatibility_generate_ctrlptsw2d_file2(nurbs_surface): fname_in = FILE_NAME + "_in.txt" fname_out = FILE_NAME + "_out.txt" fname_final = FILE_NAME + "_final.txt" exchange.export_txt(nurbs_surface, fname_in, two_dimensional=True) compatibility.generate_ctrlpts2d_weights_file(fname_in, fname_out) compatibility.generate_ctrlptsw2d_file(fname_out, fname_final) ctrlpts, size_u, size_v = exchange.import_txt(fname_final, two_dimensional=True) ctrlptsw = compatibility.generate_ctrlptsw(ctrlpts) res_array = [] for res in ctrlptsw: res_array.append(res) assert nurbs_surface.ctrlptsw == res_array assert nurbs_surface.ctrlpts_size_u == size_u assert nurbs_surface.ctrlpts_size_v == size_v # Clean up temporary file if exists if os.path.isfile(fname_in): os.remove(fname_in) os.remove(fname_out) os.remove(fname_final)
def export_evalpts(obj, file_name, export_format): """ Prints the evaluated points on the screen and optionally exports them to a file. :param obj: input curve or surface :type obj: NURBS.Curve, NURBS.Surface, Multi.CurveContainer or Multi.SurfaceContainer :param file_name: name of the export file :type file_name: str :param export_format: export file format, e.g. txt or csv :type export_format: str """ if export_format == "csv": exchange.export_csv(obj, file_name, point_type='evalpts') elif export_format == "txt": exchange.export_txt(obj, file_name, point_type='evalpts') else: if isinstance(obj, multi.AbstractContainer): sz = len(obj) for idx, opt in enumerate(obj.evalpts): for pt in opt: line = ", ".join([str(p) for p in pt]) print(line) if idx != sz - 1: print("---") else: for pt in obj.evalpts: line = ", ".join([str(p) for p in pt]) print(line)
def test_export_txt_curve(bspline_curve3d): fname = FILE_NAME + ".txt" bspline_curve3d.sample_size = SAMPLE_SIZE exchange.export_txt(bspline_curve3d, fname) assert os.path.isfile(fname) assert os.path.getsize(fname) > 0 # Clean up temporary file if exists if os.path.isfile(fname): os.remove(fname)
def test_compatibility_flip_ctrlpts2d_file3(bspline_surface): fname_in = FILE_NAME + "_in.txt" fname_out = "" bspline_surface.sample_size = SAMPLE_SIZE exchange.export_txt(bspline_surface, fname_in, two_dimensional=True) with pytest.raises(IOError): compatibility.flip_ctrlpts2d_file(fname_in, fname_out) # Clean up temporary file if exists if os.path.isfile(fname_in): os.remove(fname_in)
def test_compatibility_generate_ctrlpts2d_weights_file(nurbs_surface): fname_in = FILE_NAME + "_in.txt" fname_out = FILE_NAME + "_out.txt" nurbs_surface.sample_size = SAMPLE_SIZE exchange.export_txt(nurbs_surface, fname_in, two_dimensional=True) compatibility.generate_ctrlpts2d_weights_file(fname_in, fname_out) assert os.path.isfile(fname_out) assert os.path.getsize(fname_out) > 0 # Clean up temporary file if exists if os.path.isfile(fname_in): os.remove(fname_in) os.remove(fname_out)
def test_export_import_txt_surface1(bspline_surface): fname = FILE_NAME + ".txt" bspline_surface.sample_size = SAMPLE_SIZE exchange.export_txt(bspline_surface, fname, two_dimensional=False) # Import text file result = exchange.import_txt(fname, two_dimensional=False) res_array = [] for res in result: res_array.append(res) assert res_array == bspline_surface.ctrlpts # Clean up temporary file if exists if os.path.isfile(fname): os.remove(fname)
def test_export_import_txt_curve(bspline_curve3d): fname = FILE_NAME + ".txt" bspline_curve3d.sample_size = SAMPLE_SIZE exchange.export_txt(bspline_curve3d, fname) # Import text file result = exchange.import_txt(fname) res_array = [] for res in result: res_array.append(res) assert res_array == bspline_curve3d.ctrlpts # Clean up temporary file if exists if os.path.isfile(fname): os.remove(fname)
def test_export_import_txt_surface2(bspline_surface): fname = FILE_NAME + ".txt" bspline_surface.sample_size = SAMPLE_SIZE exchange.export_txt(bspline_surface, fname, two_dimensional=True) # Import text file result, size_u, size_v = exchange.import_txt(fname, two_dimensional=True) res_array = [] for res in result: res_array.append(tuple(res)) assert tuple(res_array) == bspline_surface.ctrlpts assert size_u == bspline_surface.ctrlpts_size_u assert size_v == bspline_surface.ctrlpts_size_v # Clean up temporary file if exists if os.path.isfile(fname): os.remove(fname)