def main(): """Read the file, build the tree. Write a Binary.""" start_time = bu.timer() parser = bu.parser_args("*.asc / *.xyz / *.txt") parser = bu.add_reverse(parser) args = parser.parse_args() # Parse directories or filenames, whichever you want! if os.path.isdir(args.input): filenames = glob.glob(os.path.join(args.input, '*.xyz')) filenames.extend(glob.glob(os.path.join(args.input, '*.asc'))) filenames.extend(glob.glob(os.path.join(args.input, '*.txt'))) else: filenames = glob.glob(args.input) print("processing: ", ' '.join(filenames)) for filename in filenames: if args.dense: outfilename = bu.sub(filename, "dvol") else: outfilename = bu.sub(filename, "vol") if os.path.isfile(outfilename): print("File already exists!") continue print("converting", filename, "to", outfilename) bbox, points, pointsdata = parse_xyz(filename, args.nbits) if args.reverse_zy: points = np.array([points[:, 0], points[:, 2], points[:, 1]]).transpose() # work out how many chunks are required for the data if args.nbits: print("nbits set, adding metadata to occupancy grid") div, mod = divmod(len(pointsdata[0]), 8) if mod > 0: nbits = div + 1 else: nbits = div else: print("Only occupancy data being set! Use -n flag to add metadata") nbits = 0 if len(points) > 0: volatree = VolaTree(args.depth, bbox, args.crs, args.dense, nbits) volatree.cubify(points, pointsdata) volatree.countlevels() volatree.writebin(outfilename) bu.print_ratio(filename, outfilename) else: print("The points file is empty!") bu.timer(start_time)
def main(): """Read the file, build the tree. Write a Binary.""" start_time = bu.timer() parser = bu.parser_args("*.asc / *.xyz") args = parser.parse_args() # Parse directories or filenames, whichever you want! if os.path.isdir(args.input): filenames = glob.glob(os.path.join(args.input, '*.txt')) filenames.extend(glob.glob(os.path.join(args.input, '*.asc'))) else: filenames = glob.glob(args.input) print("processing: ", ' '.join(filenames)) for filename in filenames: if args.dense: outfilename = bu.sub(filename, "dvol") else: outfilename = bu.sub(filename, "vol") if os.path.isfile(outfilename): print("File already exists!") continue print("converting", filename, "to", outfilename) bbox, points, pointsdata = parse_xyz(filename, args.nbits) # work out how many chunks are required for the data if args.nbits: div, mod = divmod(len(pointsdata[0]), 8) if mod > 0: nbits = div + 1 else: nbits = div else: nbits = 0 if len(points) > 0: volatree = VolaTree(args.depth, bbox, args.crs, args.dense, nbits) volatree.cubify(points, pointsdata) volatree.countlevels() volatree.writebin(outfilename) bu.print_ratio(filename, outfilename) else: print("The points file is empty!") bu.timer(start_time)
def main(): """Read the file, build the tree. Write a Binary.""" start_time = bu.timer() parser = bu.parser_args("*.ply") parser = bu.add_reverse(parser) args = parser.parse_args() # Parse directories or filenames, whichever you want! if os.path.isdir(args.input): filenames = glob.glob(os.path.join(args.input, '*.ply')) else: filenames = glob.glob(args.input) print("processing: ", ' '.join(filenames)) for filename in filenames: if args.dense: outfilename = bu.sub(filename, "dvol") else: outfilename = bu.sub(filename, "vol") if os.path.isfile(outfilename): print("File already exists!") continue print("converting", filename, "to", outfilename) bbox, points, pointsdata = parse_ply(filename, args.nbits) if args.reverse_zy: points = np.array([points[:, 0], points[:, 2], points[:, 1]]).transpose() # work out how many chunks are required for the data print("PLY only has occupancy data," + " no additional data is being added") nbits = 0 volatree = VolaTree(args.depth, bbox, args.crs, args.dense, nbits) volatree.cubify(points) volatree.countlevels() volatree.writebin(outfilename) bu.print_ratio(filename, outfilename) bu.timer(start_time)
def main(): """Read the file, build the tree. Write a Binary.""" start_time = bu.timer() parser = bu.parser_args("*.npy") args = parser.parse_args() # Parse directories or filenames, whichever you want! if os.path.isdir(args.input): filenames = glob.glob(os.path.join(args.input, '*.npy')) else: filenames = glob.glob(args.input) print("processing: ", ' '.join(filenames)) for filename in filenames: if args.dense: outfilename = bu.sub(filename, "dvol") else: outfilename = bu.sub(filename, "vol") if os.path.isfile(outfilename): print("File already exists!") continue print("converting", filename, "to", outfilename) bbox, points, pointsdata = parse_npy(filename) print("npy only has occupancy data," + " no additional data is being added") nbits = 0 if len(points) > 0: volatree = VolaTree(args.depth, bbox, args.crs, args.dense, nbits) volatree.cubify(points, pointsdata) volatree.writebin(outfilename) bu.print_ratio(filename, outfilename) else: print("The points file is empty!") bu.timer(start_time)