-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
20 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,24 @@ | ||
""" | ||
in in_points v | ||
in in_faces s | ||
out out_verts v | ||
out out_faces s | ||
""" | ||
import logging | ||
|
||
logger = logging.getLogger('sverchok') | ||
|
||
try: | ||
import scipy | ||
from scipy.spatial import Voronoi | ||
except ImportError as e: | ||
logger.info("SciPy module is not available. Please refer to https://github.com/nortikin/sverchok/wiki/Non-standard-Python-modules-installation for how to install it.") | ||
raise e | ||
import numpy as np | ||
from sverchok.data_structure import zip_long_repeat | ||
|
||
out_verts = [] | ||
out_edges = [] | ||
out_faces = [] | ||
|
||
for points in in_points: | ||
vor = Voronoi(points) | ||
for verts, faces in zip_long_repeat(in_points, in_faces): | ||
verts = np.array(verts) | ||
faces = np.array(faces) | ||
tris = verts[faces] | ||
v1s = tris[:,1] - tris[:,0] | ||
v2s = tris[:,2] - tris[:,1] | ||
normals = np.cross(v1s, v2s) | ||
|
||
new_verts = vor.vertices.tolist() | ||
new_faces = [e for e in vor.ridge_vertices if not -1 in e] | ||
out_verts.append(normals.tolist()) | ||
|
||
|
||
out_verts.append(new_verts) | ||
out_faces.append(new_faces) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters