mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 00:03:17 +00:00
Fix invalid profiles after subdividing edges near arcs #4471
This commit is contained in:
@@ -21,6 +21,7 @@ import bmesh
|
|||||||
import mathutils
|
import mathutils
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.unit
|
import ifcopenshell.util.unit
|
||||||
|
import blenderbim.tool as tool
|
||||||
from math import pi, pow
|
from math import pi, pow
|
||||||
from mathutils import Vector, Matrix, geometry
|
from mathutils import Vector, Matrix, geometry
|
||||||
from typing import Union
|
from typing import Union
|
||||||
@@ -141,13 +142,14 @@ class Helper:
|
|||||||
total_groups = 0
|
total_groups = 0
|
||||||
is_circle = False
|
is_circle = False
|
||||||
for group_type, group_indices in groups.items():
|
for group_type, group_indices in groups.items():
|
||||||
for group_index in group_indices:
|
is_special, group_index = tool.Blender.bmesh_check_vertex_in_groups(vert, deform_layer, group_indices)
|
||||||
if group_index in vert[deform_layer]:
|
if not is_special:
|
||||||
if group_type == "IFCCIRCLE":
|
continue
|
||||||
is_circle = True
|
if group_type == "IFCCIRCLE":
|
||||||
group_verts[group_type].setdefault(group_index, 0)
|
is_circle = True
|
||||||
group_verts[group_type][group_index] += 1
|
group_verts[group_type].setdefault(group_index, 0)
|
||||||
total_groups += 0
|
group_verts[group_type][group_index] += 1
|
||||||
|
total_groups += 0
|
||||||
if total_groups > 1: # A vert can only belong to one group
|
if total_groups > 1: # A vert can only belong to one group
|
||||||
return (False, "AMBIGUOUS_SPECIAL_VERTEX")
|
return (False, "AMBIGUOUS_SPECIAL_VERTEX")
|
||||||
elif is_circle:
|
elif is_circle:
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from math import sin, cos, radians
|
|||||||
from bpy.types import SpaceView3D
|
from bpy.types import SpaceView3D
|
||||||
from mathutils import Vector, Matrix
|
from mathutils import Vector, Matrix
|
||||||
from gpu_extras.batch import batch_for_shader
|
from gpu_extras.batch import batch_for_shader
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
|
||||||
ERROR_ELEMENTS_COLOR = (1, 0.2, 0.322, 1) # RED
|
ERROR_ELEMENTS_COLOR = (1, 0.2, 0.322, 1) # RED
|
||||||
@@ -35,15 +36,6 @@ def transparent_color(color, alpha=0.1):
|
|||||||
return color
|
return color
|
||||||
|
|
||||||
|
|
||||||
def bm_check_vertex_in_groups(vertex, deform_layer, groups):
|
|
||||||
"""returns tuple boolean (whether vertex is in any of the groups)
|
|
||||||
and related group index"""
|
|
||||||
for group_index in vertex[deform_layer].keys():
|
|
||||||
if group_index in groups:
|
|
||||||
return True, group_index
|
|
||||||
return False, None
|
|
||||||
|
|
||||||
|
|
||||||
class ProfileDecorator:
|
class ProfileDecorator:
|
||||||
installed = None
|
installed = None
|
||||||
|
|
||||||
@@ -148,12 +140,12 @@ class ProfileDecorator:
|
|||||||
# deform_layer is None if there are no verts assigned to vertex groups
|
# deform_layer is None if there are no verts assigned to vertex groups
|
||||||
# even if there are vertex groups in the obj.vertex_groups
|
# even if there are vertex groups in the obj.vertex_groups
|
||||||
if deform_layer:
|
if deform_layer:
|
||||||
is_arc, group_index = bm_check_vertex_in_groups(vertex, deform_layer, arc_groups)
|
is_arc, group_index = tool.Blender.bmesh_check_vertex_in_groups(vertex, deform_layer, arc_groups)
|
||||||
if is_arc:
|
if is_arc:
|
||||||
arcs.setdefault(group_index, []).append(vertex)
|
arcs.setdefault(group_index, []).append(vertex)
|
||||||
special_vertex_indices[vertex.index] = group_index
|
special_vertex_indices[vertex.index] = group_index
|
||||||
|
|
||||||
is_circle, group_index = bm_check_vertex_in_groups(vertex, deform_layer, circle_groups)
|
is_circle, group_index = tool.Blender.bmesh_check_vertex_in_groups(vertex, deform_layer, circle_groups)
|
||||||
if is_circle:
|
if is_circle:
|
||||||
circles.setdefault(group_index, []).append(vertex)
|
circles.setdefault(group_index, []).append(vertex)
|
||||||
special_vertex_indices[vertex.index] = group_index
|
special_vertex_indices[vertex.index] = group_index
|
||||||
|
|||||||
@@ -569,6 +569,18 @@ class Blender(blenderbim.core.tool.Blender):
|
|||||||
|
|
||||||
return bm_a
|
return bm_a
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def bmesh_check_vertex_in_groups(
|
||||||
|
cls, vertex: bmesh.types.BMVert, deform_layer: bmesh.types.BMLayerItem, groups: list[int]
|
||||||
|
) -> Union[tuple[Literal[True], int], tuple[Literal[False], None]]:
|
||||||
|
"""returns tuple boolean (whether vertex is in any of the groups) and related group index"""
|
||||||
|
for group_index in vertex[deform_layer].keys():
|
||||||
|
# ignore vertex groups assignments produced by edge subdivision near arcs
|
||||||
|
# they usually have weight = 0.5
|
||||||
|
if group_index in groups and vertex[deform_layer][group_index] == 1.0:
|
||||||
|
return True, group_index
|
||||||
|
return False, None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def toggle_edit_mode(cls, context: bpy.types.Context) -> set:
|
def toggle_edit_mode(cls, context: bpy.types.Context) -> set:
|
||||||
ao = context.active_object
|
ao = context.active_object
|
||||||
|
|||||||
Reference in New Issue
Block a user