Коммит d02ef06c создал по автору Ilya Portnov's avatar Ilya Portnov
Просмотр файлов

Optimization for "voronoi on solid".

владелец 3d28cf5d
...@@ -43,9 +43,9 @@ class SvSolidPolygonFaceNode(bpy.types.Node, SverchCustomTreeNode): ...@@ -43,9 +43,9 @@ class SvSolidPolygonFaceNode(bpy.types.Node, SverchCustomTreeNode):
for face_i in face_idxs: for face_i in face_idxs:
face_i = list(face_i) face_i = list(face_i)
face_i.append(face_i[0]) face_i.append(face_i[0])
verts = [verts[idx] for idx in face_i] fc_verts = [verts[idx] for idx in face_i]
verts = [Base.Vector(*vert) for vert in verts] fc_verts = [Base.Vector(*vert) for vert in fc_verts]
wire = Part.makePolygon(verts) wire = Part.makePolygon(fc_verts)
face = Part.Face(wire) face = Part.Face(wire)
surface = SvSolidFaceSurface(face)#.to_nurbs() surface = SvSolidFaceSurface(face)#.to_nurbs()
result.append(surface) result.append(surface)
......
...@@ -29,7 +29,7 @@ from sverchok.data_structure import updateNode, zip_long_repeat, throttle_and_up ...@@ -29,7 +29,7 @@ from sverchok.data_structure import updateNode, zip_long_repeat, throttle_and_up
from sverchok.utils.sv_bmesh_utils import recalc_normals from sverchok.utils.sv_bmesh_utils import recalc_normals
from sverchok.utils.voronoi3d import voronoi_on_solid from sverchok.utils.voronoi3d import voronoi_on_solid
from sverchok.utils.geom import scale_relative from sverchok.utils.geom import scale_relative
from sverchok.utils.solid import svmesh_to_solid, SvSolidTopology, SvGeneralFuse from sverchok.utils.solid import BMESH, svmesh_to_solid, SvSolidTopology, SvGeneralFuse
from sverchok.utils.surface.freecad import SvSolidFaceSurface from sverchok.utils.surface.freecad import SvSolidFaceSurface
from sverchok.utils.dummy_nodes import add_dummy from sverchok.utils.dummy_nodes import add_dummy
from sverchok.dependencies import scipy, FreeCAD from sverchok.dependencies import scipy, FreeCAD
......
...@@ -454,7 +454,10 @@ def mefisto_mesher(solids, max_edge_length): ...@@ -454,7 +454,10 @@ def mefisto_mesher(solids, max_edge_length):
return verts, faces return verts, faces
def svmesh_to_solid(verts, faces, precision, remove_splitter=True): FCMESH = 'FCMESH'
BMESH = 'BMESH'
def svmesh_to_solid(verts, faces, precision=1e-6, remove_splitter=True, method=FCMESH):
""" """
input: input:
verts: list of 3element iterables, [vector, vector...] verts: list of 3element iterables, [vector, vector...]
...@@ -465,17 +468,33 @@ def svmesh_to_solid(verts, faces, precision, remove_splitter=True): ...@@ -465,17 +468,33 @@ def svmesh_to_solid(verts, faces, precision, remove_splitter=True):
a FreeCAD solid a FreeCAD solid
""" """
tri_faces = ensure_triangles(verts, faces, True) if method == FCMESH:
faces_t = [[verts[c] for c in f] for f in tri_faces] tri_faces = ensure_triangles(verts, faces, True)
mesh = Mesh.Mesh(faces_t) faces_t = [[verts[c] for c in f] for f in tri_faces]
shape = Part.Shape() mesh = Mesh.Mesh(faces_t)
shape.makeShapeFromMesh(mesh.Topology, precision) shape = Part.Shape()
shape.makeShapeFromMesh(mesh.Topology, precision)
if remove_splitter:
# may slow it down, or be totally necessary if remove_splitter:
shape = shape.removeSplitter() # may slow it down, or be totally necessary
shape = shape.removeSplitter()
return Part.makeSolid(shape)
return Part.makeSolid(shape)
elif method == BMESH:
fc_faces = []
for face in faces:
face_i = list(face) + [face[0]]
face_verts = [Base.Vector(verts[i]) for i in face_i]
wire = Part.makePolygon(face_verts)
fc_face = Part.Face(wire)
fc_faces.append(fc_face)
shell = Part.makeShell(fc_faces)
solid = Part.makeSolid(shell)
if remove_splitter:
solid = solid.removeSplitter()
return solid
else:
raise Exception("Unsupported method")
def mesh_from_solid_faces(solid): def mesh_from_solid_faces(solid):
verts = [(v.X, v.Y, v.Z) for v in solid.Vertexes] verts = [(v.X, v.Y, v.Z) for v in solid.Vertexes]
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать