- fixed a borderline issue in CNCJob UI Autolevelling - Voronoi polygons calculations
This commit is contained in:
parent
eee4595449
commit
c43b70cba5
|
@ -21,6 +21,7 @@ CHANGELOG for FlatCAM beta
|
||||||
- Tool Isolation - on Tool start it will attempt to load the Preferences set tools by diameter from Tools Database. If it can't find one there it will add a default tool.
|
- Tool Isolation - on Tool start it will attempt to load the Preferences set tools by diameter from Tools Database. If it can't find one there it will add a default tool.
|
||||||
- in Tools: Transform, SUb, RulesCheck, DistanceMin, Distance - moved the Tool UI in its own class
|
- in Tools: Transform, SUb, RulesCheck, DistanceMin, Distance - moved the Tool UI in its own class
|
||||||
- some small fixes
|
- some small fixes
|
||||||
|
- fixed a borderline issue in CNCJob UI Autolevelling - Voronoi polygons calculations
|
||||||
|
|
||||||
26.08.2020
|
26.08.2020
|
||||||
|
|
||||||
|
|
|
@ -843,25 +843,31 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||||
|
|
||||||
def calculate_voronoi_diagram(self, pts):
|
def calculate_voronoi_diagram(self, pts):
|
||||||
env = self.solid_geo.envelope
|
env = self.solid_geo.envelope
|
||||||
# fact = 1 if self.units == 'MM' else 0.039
|
fact = 1 if self.units == 'MM' else 0.039
|
||||||
# env = env.buffer(fact).exterior
|
env = env.buffer(fact)
|
||||||
|
|
||||||
new_pts = deepcopy(pts)
|
new_pts = deepcopy(pts)
|
||||||
for pt_index in range(len(pts)):
|
try:
|
||||||
try:
|
pts_union = MultiPoint(pts)
|
||||||
pts_union = MultiPoint(pts)
|
voronoi_union = voronoi_diagram(geom=pts_union, envelope=env)
|
||||||
voronoi_union = voronoi_diagram(geom=pts_union, envelope=env)
|
except Exception as e:
|
||||||
break
|
log.debug("CNCJobObject.calculate_voronoi_diagram() --> %s" % str(e))
|
||||||
except Exception as e:
|
for pt_index in range(len(pts)):
|
||||||
log.debug("CNCJobObject.calculate_voronoi_diagram() --> %s" % str(e))
|
|
||||||
new_pts[pt_index] = affinity.translate(
|
new_pts[pt_index] = affinity.translate(
|
||||||
new_pts[pt_index], random.random() * 1e-07, random.random() * 1e-07)
|
new_pts[pt_index], random.random() * 1e-09, random.random() * 1e-09)
|
||||||
|
|
||||||
pts_union = MultiPoint(new_pts)
|
pts_union = MultiPoint(new_pts)
|
||||||
|
try:
|
||||||
voronoi_union = voronoi_diagram(geom=pts_union, envelope=env)
|
voronoi_union = voronoi_diagram(geom=pts_union, envelope=env)
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
|
|
||||||
|
new_voronoi = []
|
||||||
|
for p in voronoi_union:
|
||||||
|
new_voronoi.append(p.intersection(env))
|
||||||
|
|
||||||
for pt_key in list(self.al_geometry_dict.keys()):
|
for pt_key in list(self.al_geometry_dict.keys()):
|
||||||
for poly in voronoi_union:
|
for poly in new_voronoi:
|
||||||
if self.al_geometry_dict[pt_key]['point'].within(poly):
|
if self.al_geometry_dict[pt_key]['point'].within(poly):
|
||||||
self.al_geometry_dict[pt_key]['geo'] = poly
|
self.al_geometry_dict[pt_key]['geo'] = poly
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue