Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Rachinskiy <mikhail.rachinskiy@gmail.com>2019-09-18 16:14:08 +0300
committerMikhail Rachinskiy <mikhail.rachinskiy@gmail.com>2019-09-18 16:14:21 +0300
commit9f7b301a9b0ac97de56854dec81d7be5f8900e12 (patch)
tree0faaa69a6f7b88da300b7ab0664e63ec833ebf09 /object_print3d_utils/mesh_helpers.py
parent11fdc251a15310aae74f7eb981e45d631d11e080 (diff)
Print3D: PEP8 cleanup
Diffstat (limited to 'object_print3d_utils/mesh_helpers.py')
-rw-r--r--object_print3d_utils/mesh_helpers.py58
1 files changed, 14 insertions, 44 deletions
diff --git a/object_print3d_utils/mesh_helpers.py b/object_print3d_utils/mesh_helpers.py
index cda8c005..d585d125 100644
--- a/object_print3d_utils/mesh_helpers.py
+++ b/object_print3d_utils/mesh_helpers.py
@@ -24,9 +24,7 @@ import bmesh
def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False):
- """
- Returns a transformed, triangulated copy of the mesh
- """
+ """Returns a transformed, triangulated copy of the mesh"""
assert obj.type == 'MESH'
@@ -61,47 +59,39 @@ def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifier
def bmesh_from_object(obj):
- """
- Object/Edit Mode get mesh, use bmesh_to_object() to write back.
- """
+ """Object/Edit Mode get mesh, use bmesh_to_object() to write back."""
me = obj.data
- is_editmode = (obj.mode == 'EDIT')
- if is_editmode:
+
+ if obj.mode == 'EDIT':
bm = bmesh.from_edit_mesh(me)
else:
bm = bmesh.new()
bm.from_mesh(me)
+
return bm
def bmesh_to_object(obj, bm):
- """
- Object/Edit Mode update the object.
- """
+ """Object/Edit Mode update the object."""
me = obj.data
- is_editmode = (obj.mode == 'EDIT')
- if is_editmode:
+
+ if obj.mode == 'EDIT':
bmesh.update_edit_mesh(me, True)
else:
bm.to_mesh(me)
+
# grr... cause an update
if me.vertices:
me.vertices[0].co[0] = me.vertices[0].co[0]
def bmesh_calc_area(bm):
- """
- Calculate the surface area.
- """
+ """Calculate the surface area."""
return sum(f.calc_area() for f in bm.faces)
def bmesh_check_self_intersect_object(obj):
- """
- Check if any faces self intersect
-
- returns an array of edge index values.
- """
+ """Check if any faces self intersect returns an array of edge index values."""
import array
import mathutils
@@ -147,6 +137,7 @@ def bmesh_check_thick_object(obj, thickness):
# Triangulate
bm = bmesh_copy_from_object(obj, transform=True, triangulate=False)
+
# map original faces to their index.
face_index_map_org = {f: i for i, f in enumerate(bm.faces)}
ret = bmesh.ops.triangulate(bm, faces=bm.faces)
@@ -166,27 +157,14 @@ def bmesh_check_thick_object(obj, thickness):
bm.to_mesh(me_tmp)
# bm.free() # delay free
obj_tmp = bpy.data.objects.new(name=me_tmp.name, object_data=me_tmp)
- # base = scene.objects.link(obj_tmp)
scene_collection.objects.link(obj_tmp)
- # Add new object to local view layer
- # XXX28
- '''
- v3d = None
- if context.space_data and context.space_data.type == 'VIEW_3D':
- v3d = context.space_data
-
- if v3d and v3d.local_view:
- base.layers_from_view(context.space_data)
- '''
-
layer.update()
ray_cast = obj_tmp.ray_cast
EPS_BIAS = 0.0001
faces_error = set()
-
bm_faces_new = bm.faces[:]
for f in bm_faces_new:
@@ -209,8 +187,7 @@ def bmesh_check_thick_object(obj, thickness):
f_org_index = face_index_map_org[f_org]
faces_error.add(f_org_index)
- # finished with bm
- bm.free()
+ bm.free() # finished with bm
scene_collection.objects.unlink(obj_tmp)
bpy.data.objects.remove(obj_tmp)
@@ -222,9 +199,7 @@ def bmesh_check_thick_object(obj, thickness):
def object_merge(context, objects):
- """
- Caller must remove.
- """
+ """Caller must remove."""
import bpy
@@ -279,10 +254,6 @@ def object_merge(context, objects):
bpy.ops.object.join(fake_context)
del base_new, obj_new
- # remove object and its mesh, join does this
- # scene_collection.objects.unlink(obj_new)
- # bpy.data.objects.remove(obj_new)
-
obj_eval.to_mesh_clear()
layer.update()
@@ -291,7 +262,6 @@ def object_merge(context, objects):
return obj_base
-
def face_is_distorted(ele, angle_distort):
no = ele.normal
angle_fn = no.angle