def process(self): if not any(socket.is_linked for socket in self.outputs): return if self.proportional and not self.inputs['Field'].is_linked: raise SvNoDataError(socket=self.inputs['Field'], node=self) fields_s = self.inputs['Field'].sv_get(default=[[None]]) vertices_s = self.inputs['Bounds'].sv_get() count_s = self.inputs['Count'].sv_get() min_r_s = self.inputs['MinDistance'].sv_get() threshold_s = self.inputs['Threshold'].sv_get() field_min_s = self.inputs['FieldMin'].sv_get() field_max_s = self.inputs['FieldMax'].sv_get() seed_s = self.inputs['Seed'].sv_get() if self.inputs['Field'].is_linked: fields_s = ensure_nesting_level(fields_s, 2, data_types=(SvScalarField, )) vertices_s = ensure_nesting_level(vertices_s, 4) count_s = ensure_nesting_level(count_s, 2) min_r_s = ensure_nesting_level(min_r_s, 2) threshold_s = ensure_nesting_level(threshold_s, 2) field_min_s = ensure_nesting_level(field_min_s, 2) field_max_s = ensure_nesting_level(field_max_s, 2) seed_s = ensure_nesting_level(seed_s, 2) verts_out = [] inputs = zip_long_repeat(fields_s, vertices_s, threshold_s, field_min_s, field_max_s, count_s, min_r_s, seed_s) for objects in inputs: for field, vertices, threshold, field_min, field_max, count, min_r, seed in zip_long_repeat( *objects): bbox = self.get_bounds(vertices) new_verts = field_random_probe(field, bbox, count, threshold, self.proportional, field_min, field_max, min_r, seed) verts_out.append(new_verts) self.outputs['Vertices'].sv_set(verts_out)
def generate_volume(self, solid, field, count, min_r, threshold, field_min, field_max, seed): def check(vert): point = Base.Vector(vert) return solid.isInside(point, self.get_tolerance(), self.in_surface) box = solid.BoundBox bbox = ((box.XMin, box.YMin, box.ZMin), (box.XMax, box.YMax, box.ZMax)) return field_random_probe(field, bbox, count, threshold, self.proportional, field_min, field_max, min_r, seed, predicate=check)
def process(self): if not any(socket.is_linked for socket in self.outputs): return if self.proportional and not self.inputs['Field'].is_linked: raise SvNoDataError(socket=self.inputs['Field'], node=self) fields_s = self.inputs['Field'].sv_get(default=[[None]]) if self.distance_mode == 'FIELD': radius_s = self.inputs['RadiusField'].sv_get() else: radius_s = [[None]] vertices_s = self.inputs['Bounds'].sv_get() count_s = self.inputs['Count'].sv_get() min_r_s = self.inputs['MinDistance'].sv_get() threshold_s = self.inputs['Threshold'].sv_get() field_min_s = self.inputs['FieldMin'].sv_get() field_max_s = self.inputs['FieldMax'].sv_get() seed_s = self.inputs['Seed'].sv_get() if self.inputs['Field'].is_linked: fields_s = ensure_nesting_level(fields_s, 2, data_types=(SvScalarField,)) input_level = get_data_nesting_level(fields_s, data_types=(SvScalarField,)) nested_field = input_level > 1 else: nested_field = False if self.inputs['RadiusField'].is_linked: radius_s = ensure_nesting_level(radius_s, 2, data_types=(SvScalarField,)) input_level = get_data_nesting_level(radius_s, data_types=(SvScalarField,)) nested_radius = input_level > 1 else: nested_radius = False verts_level = get_data_nesting_level(vertices_s) nested_verts = verts_level > 3 vertices_s = ensure_nesting_level(vertices_s, 4) count_s = ensure_nesting_level(count_s, 2) min_r_s = ensure_nesting_level(min_r_s, 2) threshold_s = ensure_nesting_level(threshold_s, 2) field_min_s = ensure_nesting_level(field_min_s, 2) field_max_s = ensure_nesting_level(field_max_s, 2) seed_s = ensure_nesting_level(seed_s, 2) nested_output = nested_field or nested_radius or nested_verts verts_out = [] radius_out = [] inputs = zip_long_repeat(fields_s, radius_s, vertices_s, threshold_s, field_min_s, field_max_s, count_s, min_r_s, seed_s) for objects in inputs: new_verts = [] new_radiuses = [] for field, radius_field, vertices, threshold, field_min, field_max, count, min_r, seed in zip_long_repeat(*objects): bbox = self.get_bounds(vertices) if self.distance_mode == 'FIELD': min_r = 0 verts, radiuses = field_random_probe(field, bbox, count, threshold, self.proportional, field_min, field_max, min_r = min_r, min_r_field = radius_field, random_radius = self.random_radius, seed = seed) if self.flat_output: new_verts.extend(verts) new_radiuses.extend(radiuses) else: new_verts.append(verts) new_radiuses.append(radiuses) if nested_output: verts_out.append(new_verts) radius_out.append(new_radiuses) else: verts_out.extend(new_verts) radius_out.extend(new_radiuses) self.outputs['Vertices'].sv_set(verts_out) self.outputs['Radius'].sv_set(radius_out)