Skip to content

Commit

Permalink
fix.
Browse files Browse the repository at this point in the history
1. remove unused elements
2. fix exception in a case with no fragments (cites)
  • Loading branch information
satabol committed Aug 13, 2023
1 parent 8cb4642 commit 9f3875c
Showing 1 changed file with 6 additions and 35 deletions.
41 changes: 6 additions & 35 deletions nodes/spatial/voronoi_on_solid_mk2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from sverchok.data_structure import updateNode, zip_long_repeat, ensure_nesting_level, get_data_nesting_level,\
ensure_min_nesting, repeat_last_for_length
from sverchok.utils.voronoi3d import voronoi_on_mesh_bmesh
from sverchok.utils.geom import scale_relative, center, diameter
from sverchok.utils.solid import BMESH, svmesh_to_solid
from sverchok.dependencies import FreeCAD

Expand Down Expand Up @@ -67,18 +66,6 @@ class SvVoronoiOnSolidNodeMK2(SverchCustomTreeNode, bpy.types.Node):
description="Distance to leave between generated Voronoi regions",
update = updateNode)

scale_types = [
('SITE', "Site", "Scale each region relative to corresponding site location", 0),
('MEAN', "Barycenter", "Scale each region relative to it's barycenter, i.e. average location of it's vertices", 1)
]

scale_center : EnumProperty(
name = "Scale around",
description = "Defines the center, along which the regions of Voronoi diagram are to be scaled in order to make inset",
items = scale_types,
default = 'SITE',
update = updateNode)

flat_output : BoolProperty(
name = "Flat output",
description = "If checked, output single flat list of fragments for all input solids; otherwise, output a separate list of fragments for each solid.",
Expand All @@ -98,26 +85,8 @@ def draw_buttons(self, context, layout):

def draw_buttons_ext(self, context, layout):
self.draw_buttons(context, layout)
layout.prop(self, 'scale_center')
layout.prop(self, 'accuracy')

def scale_cells(self, verts, sites, insets, precision):
if all(i == 0.0 for i in insets):
return verts
verts_out = []
for vs, site, inset in zip(verts, sites, insets):
if inset >= 1.0:
continue
if self.scale_center == 'SITE':
c = site
else:
c = center(vs)
vs1 = scale_relative(vs, c, 1.0 - inset)
if diameter(vs1, axis=None) <= precision:
continue
verts_out.append(vs1)
return verts_out

def process(self):

if not any(socket.is_linked for socket in self.outputs):
Expand All @@ -144,7 +113,6 @@ def process(self):
new_inner_fragments = []
new_outer_fragments = []
for solid, sites, inset in zip_long_repeat(*params):
#verts, edges, faces = voronoi_on_solid(solid, sites, do_clip=True, clipping=None)
# see more info: https://github.com/nortikin/sverchok/pull/4977
box = solid.BoundBox
clipping = 1
Expand All @@ -158,7 +126,6 @@ def process(self):
inset = repeat_last_for_length(inset, len(sites))
else:
inset = [inset for i in range(len(sites))]
#verts = self.scale_cells(verts, sites, inset, precision)
fragments = [svmesh_to_solid(vs, fs, precision, method=BMESH, remove_splitter=False) for vs, fs in zip(verts, faces)]

if self.mode == 'SURFACE':
Expand All @@ -171,14 +138,18 @@ def process(self):
src = solid

if need_inner:
inner = [src.common(fragments)]
inner = [src]
if fragments:
inner = [src.common(fragments)]
if self.flat_output:
new_inner_fragments.extend(inner)
else:
new_inner_fragments.append(inner)

if need_outer:
outer = [src.cut(fragments)]
outer = [src]
if fragments:
outer = [src.cut(fragments)]
if self.flat_output:
new_outer_fragments.extend(outer)
else:
Expand Down

0 comments on commit 9f3875c

Please sign in to comment.