Skip to content
Snippets Groups Projects
Commit c5bfe5fa authored by Ubiratan Freitas's avatar Ubiratan Freitas
Browse files

Update code for new Blender and OCC versions

 - remove hadrcoded cell file names
 - add dll path on windows and python >= 3.8
parent 3d7dfa0e
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# Lattice Tools. If not, see <https://www.gnu.org/licenses/>. # Lattice Tools. If not, see <https://www.gnu.org/licenses/>.
bl_info = { bl_info = {
"name": "Lattice Tools", "name": "Lattice Tools",
"author": "Ubiratan S. Freitas", "author": "Ubiratan S. Freitas",
...@@ -47,6 +48,11 @@ else: ...@@ -47,6 +48,11 @@ else:
PointerProperty, PointerProperty,
) )
import os
if hasattr(os, 'add_dll_directory'):
import sys
dll_path = os.path.join(sys.prefix, 'Library/bin')
dpath = os.add_dll_directory(dll_path)
from . import ( from . import (
operators, operators,
ui, ui,
......
...@@ -25,6 +25,7 @@ from mathutils.bvhtree import BVHTree ...@@ -25,6 +25,7 @@ from mathutils.bvhtree import BVHTree
import numpy as np import numpy as np
import math import math
import os import os
from glob import glob
try: try:
from scipy.spatial import Voronoi, Delaunay from scipy.spatial import Voronoi, Delaunay
...@@ -120,25 +121,16 @@ class Cell: ...@@ -120,25 +121,16 @@ class Cell:
self.name = name self.name = name
cell_files = ['hex.cell',
'type_2.cell',
'type_3.cell',
'type_4.cell',
'type_5.cell',
'type_6.cell',
'type_8.cell',
'type_9.cell',
'type_91.cell',
]
fpath = os.path.dirname(os.path.abspath(__file__)) fpath = os.path.dirname(os.path.abspath(__file__))
filepath = os.path.join(fpath, 'cells')
Cells = {} Cells = {}
cell_items = [] cell_items = []
cell_files = glob(os.path.join(fpath, 'cells/*.cell'))
cell_files.sort()
for k, cf in enumerate(cell_files): for k, cf in enumerate(cell_files):
c = Cell() c = Cell()
c.from_file(os.path.join(filepath, cf)) c.from_file(cf)
Cells[c.name] = c Cells[c.name] = c
cell_items.append((c.name, c.name, c.name, k)) cell_items.append((c.name, c.name, c.name, k))
...@@ -695,11 +687,9 @@ def occ_compute_node(ev, r=0.5, mesh_pars=(0.1, False, math.radians(60), False), ...@@ -695,11 +687,9 @@ def occ_compute_node(ev, r=0.5, mesh_pars=(0.1, False, math.radians(60), False),
location = TopLoc_Location() location = TopLoc_Location()
facing = (bt.Triangulation(face, location)) facing = (bt.Triangulation(face, location))
if facing is not None: if facing is not None:
tab = facing.Nodes()
tri = facing.Triangles()
local_index = [] local_index = []
for k in range(1, tab.Length() + 1): for k in range(1, facing.NbNodes() + 1):
pnt = tab.Value(k) pnt = facing.Node(k)
point = list(pnt.Coord()) point = list(pnt.Coord())
dpoint = tuple((np.array(point) * 100).round().astype(np.int32)) dpoint = tuple((np.array(point) * 100).round().astype(np.int32))
verts.append(point) verts.append(point)
...@@ -724,7 +714,7 @@ def occ_compute_node(ev, r=0.5, mesh_pars=(0.1, False, math.radians(60), False), ...@@ -724,7 +714,7 @@ def occ_compute_node(ev, r=0.5, mesh_pars=(0.1, False, math.radians(60), False),
plane_verts.append(local_index) plane_verts.append(local_index)
else: else:
for i in range(1, facing.NbTriangles()+1): for i in range(1, facing.NbTriangles()+1):
trian = tri.Value(i) trian = facing.Triangle(i)
np_tri = np.array(list(trian.Get()), dtype=np.int32) np_tri = np.array(list(trian.Get()), dtype=np.int32)
np_tri = np.array(local_index[np_tri - 1]) np_tri = np.array(local_index[np_tri - 1])
if (np_tri - np_tri[ind_tri]).prod() != 0 : if (np_tri - np_tri[ind_tri]).prod() != 0 :
......
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