Skip to content

Commit

Permalink
0.1.1
Browse files Browse the repository at this point in the history
Moved convex_hull_2d to the mesh operations
  • Loading branch information
eadf committed Nov 3, 2023
1 parent a0746df commit 3ed3cc7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 70 deletions.
6 changes: 2 additions & 4 deletions blender_addon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,21 @@
# the string "from ." will be find-and-replaced with "" if run in DEV_MODE
from . import hallr_collision
from . import hallr_ffi_utils
from . import hallr_convex_hull_2d
from . import hallr_simplify_rdp
from . import hallr_2d_delaunay_triangulation
from . import hallr_2d_outline
from . import hallr_centerline
from . import hallr_standalone_operators
from . import hallr_mesh_operators


# define modules for registration
modules = (
hallr_collision,
hallr_convex_hull_2d,
hallr_simplify_rdp,
hallr_2d_delaunay_triangulation,
hallr_2d_outline,
hallr_centerline,
hallr_standalone_operators
hallr_mesh_operators
)


Expand Down
65 changes: 0 additions & 65 deletions blender_addon/hallr_convex_hull_2d.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,47 @@
import math
import array
from collections import defaultdict
from . import hallr_ffi_utils


class MESH_OT_hallr_convex_hull_2d(bpy.types.Operator):
"""A 2D convex hull operator that works in the XY plane, remember to apply any transformations"""

bl_idname = "mesh.hallr_convex_hull_2d"
bl_label = "Hallr Convex Hull 2d"
bl_options = {'REGISTER', 'UNDO'}

@classmethod
def poll(cls, context):
return context.active_object is not None

def execute(self, context):
active_object = context.active_object
if active_object is None or active_object.type != 'MESH':
self.report({'ERROR'}, "Active object is not a mesh!")
return {'CANCELLED'}

if context.mode != 'EDIT_MESH':
self.report({'ERROR'}, "Must be in edit mode!")
return {'CANCELLED'}

# Switch to object mode to gather data without changing the user's selection
bpy.ops.object.mode_set(mode='OBJECT')

bpy.context.view_layer.update()

config = {"command": "convex_hull_2d"}

# Call the Rust function

vertices, indices, config_out = hallr_ffi_utils.call_rust(config, active_object, only_selected_vertices=True)
hallr_ffi_utils.handle_windows_line_new_object(vertices, indices)

# Switch back to edit mode
bpy.context.view_layer.objects.active = active_object
bpy.ops.object.mode_set(mode='EDIT')

return {'FINISHED'}


class Hallr_SelectEndVertices(bpy.types.Operator):
Expand Down Expand Up @@ -82,7 +123,7 @@ def execute(self, context):

angle_criteria = math.degrees(self.angle_props)

vertex_dict = defaultdict(list) # key by vertex.index to [edges]
vertex_dict = defaultdict(list) # key by vertex.index to [edges]
already_selected = set() # key by edge.index
work_queue = set() # edges

Expand Down Expand Up @@ -225,6 +266,7 @@ class VIEW3D_MT_edit_mesh_hallr_meshtools(bpy.types.Menu):
def draw(self, context):
layout = self.layout
# layout.operator("mesh.hallr_meshtools_knife_intersect")
layout.operator("mesh.hallr_convex_hull_2d")
layout.operator("mesh.hallr_meshtools_select_end_vertices")
layout.operator("mesh.hallr_meshtools_select_collinear_edges")
layout.operator("mesh.hallr_meshtools_select_vertices_until_intersection")
Expand All @@ -244,6 +286,7 @@ def menu_func(self, context):
Hallr_SelectIntersectionVertices,
Hallr_SelectVerticesUntilIntersection,
Hallr_SelectCollinearEdges,
MESH_OT_hallr_convex_hull_2d
)


Expand Down

0 comments on commit 3ed3cc7

Please sign in to comment.