Skip to content

Commit 395598d

Browse files
committed
Fix invalid profiles after subdividing edges near arcs #4471
1 parent 813518b commit 395598d

3 files changed

Lines changed: 24 additions & 18 deletions

File tree

src/blenderbim/blenderbim/bim/module/geometry/helper.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import mathutils
2222
import ifcopenshell
2323
import ifcopenshell.util.unit
24+
import blenderbim.tool as tool
2425
from math import pi, pow
2526
from mathutils import Vector, Matrix, geometry
2627
from typing import Union
@@ -141,13 +142,14 @@ def auto_detect_arbitrary_profile_with_voids(
141142
total_groups = 0
142143
is_circle = False
143144
for group_type, group_indices in groups.items():
144-
for group_index in group_indices:
145-
if group_index in vert[deform_layer]:
146-
if group_type == "IFCCIRCLE":
147-
is_circle = True
148-
group_verts[group_type].setdefault(group_index, 0)
149-
group_verts[group_type][group_index] += 1
150-
total_groups += 0
145+
is_special, group_index = tool.Blender.bmesh_check_vertex_in_groups(vert, deform_layer, group_indices)
146+
if not is_special:
147+
continue
148+
if group_type == "IFCCIRCLE":
149+
is_circle = True
150+
group_verts[group_type].setdefault(group_index, 0)
151+
group_verts[group_type][group_index] += 1
152+
total_groups += 0
151153
if total_groups > 1: # A vert can only belong to one group
152154
return (False, "AMBIGUOUS_SPECIAL_VERTEX")
153155
elif is_circle:

src/blenderbim/blenderbim/bim/module/model/decorator.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from bpy.types import SpaceView3D
2424
from mathutils import Vector, Matrix
2525
from gpu_extras.batch import batch_for_shader
26+
from typing import Union
2627

2728

2829
ERROR_ELEMENTS_COLOR = (1, 0.2, 0.322, 1) # RED
@@ -35,15 +36,6 @@ def transparent_color(color, alpha=0.1):
3536
return color
3637

3738

38-
def bm_check_vertex_in_groups(vertex, deform_layer, groups):
39-
"""returns tuple boolean (whether vertex is in any of the groups)
40-
and related group index"""
41-
for group_index in vertex[deform_layer].keys():
42-
if group_index in groups:
43-
return True, group_index
44-
return False, None
45-
46-
4739
class ProfileDecorator:
4840
installed = None
4941

@@ -148,12 +140,12 @@ def __call__(self, context, get_custom_bmesh=None, draw_faces=False, exit_edit_m
148140
# deform_layer is None if there are no verts assigned to vertex groups
149141
# even if there are vertex groups in the obj.vertex_groups
150142
if deform_layer:
151-
is_arc, group_index = bm_check_vertex_in_groups(vertex, deform_layer, arc_groups)
143+
is_arc, group_index = tool.Blender.bmesh_check_vertex_in_groups(vertex, deform_layer, arc_groups)
152144
if is_arc:
153145
arcs.setdefault(group_index, []).append(vertex)
154146
special_vertex_indices[vertex.index] = group_index
155147

156-
is_circle, group_index = bm_check_vertex_in_groups(vertex, deform_layer, circle_groups)
148+
is_circle, group_index = tool.Blender.bmesh_check_vertex_in_groups(vertex, deform_layer, circle_groups)
157149
if is_circle:
158150
circles.setdefault(group_index, []).append(vertex)
159151
special_vertex_indices[vertex.index] = group_index

src/blenderbim/blenderbim/tool/blender.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,18 @@ def bmesh_join(
569569

570570
return bm_a
571571

572+
@classmethod
573+
def bmesh_check_vertex_in_groups(
574+
cls, vertex: bmesh.types.BMVert, deform_layer: bmesh.types.BMLayerItem, groups: list[int]
575+
) -> Union[tuple[Literal[True], int], tuple[Literal[False], None]]:
576+
"""returns tuple boolean (whether vertex is in any of the groups) and related group index"""
577+
for group_index in vertex[deform_layer].keys():
578+
# ignore vertex groups assignments produced by edge subdivision near arcs
579+
# they usually have weight = 0.5
580+
if group_index in groups and vertex[deform_layer][group_index] == 1.0:
581+
return True, group_index
582+
return False, None
583+
572584
@classmethod
573585
def toggle_edit_mode(cls, context: bpy.types.Context) -> set:
574586
ao = context.active_object

0 commit comments

Comments
 (0)