def load_curve(curve_file, subdivide_to=None): """" Load curve from file (optionally subdivide) and return tube.""" polyline_data = load_polyline_data(curve_file) if subdivide_to: return curve(subdivcurve.subdivide_curve(polyline_data, subdivide_to)) else: return curve(polyline_data)
def _load_io_error_curves(self, semilandmarks): subdir_abs = os.path.join(self.datafolder, self.io_error_subdir) curves = {} for curve_file in glob.glob(_unslash(subdir_abs) + '/*.asc'): logging.info(curve_file) m = re.search(r".*\/(.*)\ (\d+)\..*$", curve_file) if m: specimen_name = m.groups()[0] curve = subdivcurve.subdivide_curve( sampledata.load_polyline_data(curve_file), semilandmarks) if specimen_name not in curves: curves[specimen_name] = [] curves[specimen_name].append(curve) return curves
def _load_curves_in_dir(self, subdir, group_name, curves, names, semilandmarks): subdir_abs = os.path.join(self.datafolder, subdir) curves[group_name] = [] names[group_name] = [] for curve_file in glob.glob(_unslash(subdir_abs) + '/**/*.asc', recursive=True): logging.info(curve_file) if semilandmarks: curve = subdivcurve.subdivide_curve( sampledata.load_polyline_data(curve_file), semilandmarks) else: curve = sampledata.load_polyline_data(curve_file) curves[group_name].append(curve) names[group_name].append(curve_file) return curves
def load_sl(curve_file, sl_count): """ Load data and return vtkPolyData with (2D) points.""" polyline_data = load_polyline_data(curve_file) sls = subdivcurve.subdivide_curve(polyline_data, sl_count) points = vtk.vtkPoints() for i, sl in enumerate(sls): points.InsertPoint(i, *sl) pointspolydata = vtk.vtkPolyData() pointspolydata.SetPoints(points) vertexglyphfilter = vtk.vtkVertexGlyphFilter() vertexglyphfilter.SetInputData(pointspolydata) vertexglyphfilter.Update() polydata = vtk.vtkPolyData() polydata.ShallowCopy(vertexglyphfilter.GetOutput()) return polydata
def load_sl_balls(curve_file, sl_count, radius, color=(1, 0, 0)): """ Load data and create balls dict() list.""" points = load_polyline_data(curve_file) if sl_count: points = subdivcurve.subdivide_curve(points, sl_count) return create_balls(points, radius, color)