Skip to content

Commit 3c378eb

Browse files
committed
nothing
1 parent 592365d commit 3c378eb

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

imagepy/ipyalg/graph/sknw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ def build_graph(nodes, edges, multi=False, full=True):
120120
return graph
121121

122122
def mark_node(ske):
123-
buf = np.pad(ske, (1,1), mode='constant')
123+
buf = np.pad(ske, (1,1), mode='constant').astype(np.uint16)
124124
nbs = neighbors(buf.shape)
125125
acc = np.cumprod((1,)+buf.shape[::-1][:-1])[::-1]
126126
mark(buf, nbs)
127127
return buf
128128

129129
def build_sknw(ske, multi=False, iso=True, ring=True, full=True):
130-
buf = np.pad(ske, (1,1), mode='constant')
130+
buf = np.pad(ske, (1,1), mode='constant').astype(np.uint16)
131131
nbs = neighbors(buf.shape)
132132
acc = np.cumprod((1,)+buf.shape[::-1][:-1])[::-1]
133133
mark(buf, nbs)

sciapp/object/surface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def set_data(self, verts=None, faces=None, colors=None, **key):
8989
if not faces is None: self.faces = faces.astype(np.uint32, copy=False)
9090
if not colors is None: self.colors = colors
9191
if not faces is None: self.edge = None
92-
if sum([i is None for i in [verts, faces, colors]])<3: self.dirty = 'geom'
92+
if sum([i is None for i in [verts, faces]])<2: self.dirty = 'geom'
9393
if not self.faces is None and self.faces.ndim==1: key['mode'] = 'points'
9494
elif not self.faces is None and self.faces.shape[1]==2:
9595
if key.get('mode', self.mode)=='mesh': key['mode'] = 'grid'

sciwx/mesh/canvas.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010
# verts, faces, colors, mode, alpha, visible
1111
# light_dir, light, ambiass, background
1212

13+
from vispy.geometry import MeshData
14+
15+
def get_vertex_normals(self, indexed=None):
16+
if self._vertex_normals is None:
17+
faceNorms = self.get_face_normals()
18+
self._vertex_normals = np.zeros(self._vertices.shape, dtype=np.float32)
19+
np.add.at(self._vertex_normals, self._faces.T, faceNorms[None,:,:])
20+
v = np.linalg.norm(self._vertex_normals, axis=1)[:,None]
21+
self._vertex_normals /= np.clip(v, 1e-5, 1e5, out=v)
22+
if indexed is None: return self._vertex_normals
23+
elif indexed == 'faces': return self._vertex_normals[self.get_faces()]
24+
25+
MeshData.get_vertex_normals = get_vertex_normals
26+
1327
class MeshVisual(scene.visuals.Mesh):
1428
def __init__(self, *p, **key):
1529
scene.visuals.Mesh.__init__(self, *p, **key)
@@ -62,6 +76,7 @@ def viewmesh(mesh, view):
6276
if isinstance(mesh.cmap, str): cmap = mesh.cmap
6377
elif mesh.cmap.max()>1+1e-5: cmap = Colormap(mesh.cmap/255)
6478
else: cmap = Colormap(mesh.cmap)
79+
if isinstance(mesh.colors, tuple): view.color = mesh.colors
6580
view.cmap = cmap
6681
view.clim = [-1, 1]
6782
view.visible = mesh.visible

0 commit comments

Comments
 (0)