Skip to content
Snippets Groups Projects
Commit b8c3dff1 authored by wangg12's avatar wangg12
Browse files

fix #17

parent 8ca7d3e0
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,6 @@ import os ...@@ -3,7 +3,6 @@ import os
import os.path as osp import os.path as osp
import cv2 import cv2
import fastfunc
import mmcv import mmcv
import numpy as np import numpy as np
import pyassimp import pyassimp
...@@ -30,6 +29,12 @@ support model_loadfn to load objects ...@@ -30,6 +29,12 @@ support model_loadfn to load objects
""" """
def _fast_add_at(target, idx, vals):
# https://github.com/ml31415/numpy-groupies/issues/24
# https://github.com/numpy/numpy/issues/5922
return target + np.bincount(idx, weights=vals, minlength=target.shape[0])
class Model3D: class Model3D:
"""""" """"""
...@@ -333,11 +338,11 @@ class Model3D: ...@@ -333,11 +338,11 @@ class Model3D:
num_neighbors = np.zeros(len(mesh.node_coords), dtype=int) num_neighbors = np.zeros(len(mesh.node_coords), dtype=int)
idx = mesh.edges["nodes"] idx = mesh.edges["nodes"]
fastfunc.add.at(num_neighbors, idx, np.ones(idx.shape, dtype=int)) num_neighbors = _fast_add_at(num_neighbors, idx, np.ones(idx.shape, dtype=int))
new_points = np.zeros(mesh.node_coords.shape) new_points = np.zeros(mesh.node_coords.shape)
fastfunc.add.at(new_points, idx[:, 0], mesh.node_coords[idx[:, 1]]) new_points = _fast_add_at(new_points, idx[:, 0], mesh.node_coords[idx[:, 1]])
fastfunc.add.at(new_points, idx[:, 1], mesh.node_coords[idx[:, 0]]) new_points = _fast_add_at(new_points, idx[:, 1], mesh.node_coords[idx[:, 0]])
new_points /= num_neighbors[:, None] new_points /= num_neighbors[:, None]
idx = mesh.is_boundary_node idx = mesh.is_boundary_node
......
...@@ -9,7 +9,6 @@ ninja ...@@ -9,7 +9,6 @@ ninja
black black
docformatter docformatter
setproctitle setproctitle
fastfunc
meshplex meshplex
OpenEXR OpenEXR
vispy>=0.6.4 vispy>=0.6.4
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment