Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
a0198c53
Commit
a0198c53
authored
7 years ago
by
Mikhail Rachinskiy
Browse files
Options
Downloads
Patches
Plain Diff
Print3D: Fix (unreported) broken Clean Distorted
Distort check gave positive result with all faces.
parent
b678ef75
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
object_print3d_utils/mesh_helpers.py
+16
-0
16 additions, 0 deletions
object_print3d_utils/mesh_helpers.py
object_print3d_utils/operators.py
+7
-27
7 additions, 27 deletions
object_print3d_utils/operators.py
with
23 additions
and
27 deletions
object_print3d_utils/mesh_helpers.py
+
16
−
0
View file @
a0198c53
...
@@ -279,3 +279,19 @@ def object_merge(context, objects):
...
@@ -279,3 +279,19 @@ def object_merge(context, objects):
# return new object
# return new object
return
base_base
return
base_base
def
face_is_distorted
(
ele
,
angle_distort
):
no
=
ele
.
normal
angle_fn
=
no
.
angle
for
loop
in
ele
.
loops
:
loopno
=
loop
.
calc_normal
()
if
loopno
.
dot
(
no
)
<
0.0
:
loopno
.
negate
()
if
angle_fn
(
loopno
,
1000.0
)
>
angle_distort
:
return
True
return
False
This diff is collapsed.
Click to expand it.
object_print3d_utils/operators.py
+
7
−
27
View file @
a0198c53
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
# All Operator
# All Operator
import
array
import
bpy
import
bpy
from
bpy.types
import
Operator
from
bpy.types
import
Operator
from
bpy.props
import
(
from
bpy.props
import
(
...
@@ -129,8 +131,6 @@ class MESH_OT_Print3D_Check_Solid(Operator):
...
@@ -129,8 +131,6 @@ class MESH_OT_Print3D_Check_Solid(Operator):
@staticmethod
@staticmethod
def
main_check
(
obj
,
info
):
def
main_check
(
obj
,
info
):
import
array
bm
=
mesh_helpers
.
bmesh_copy_from_object
(
obj
,
transform
=
False
,
triangulate
=
False
)
bm
=
mesh_helpers
.
bmesh_copy_from_object
(
obj
,
transform
=
False
,
triangulate
=
False
)
edges_non_manifold
=
array
.
array
(
'
i
'
,
(
i
for
i
,
ele
in
enumerate
(
bm
.
edges
)
edges_non_manifold
=
array
.
array
(
'
i
'
,
(
i
for
i
,
ele
in
enumerate
(
bm
.
edges
)
...
@@ -173,7 +173,6 @@ class MESH_OT_Print3D_Check_Degenerate(Operator):
...
@@ -173,7 +173,6 @@ class MESH_OT_Print3D_Check_Degenerate(Operator):
@staticmethod
@staticmethod
def
main_check
(
obj
,
info
):
def
main_check
(
obj
,
info
):
import
array
scene
=
bpy
.
context
.
scene
scene
=
bpy
.
context
.
scene
print_3d
=
scene
.
print_3d
print_3d
=
scene
.
print_3d
threshold
=
print_3d
.
threshold_zero
threshold
=
print_3d
.
threshold_zero
...
@@ -202,27 +201,17 @@ class MESH_OT_Print3D_Check_Distorted(Operator):
...
@@ -202,27 +201,17 @@ class MESH_OT_Print3D_Check_Distorted(Operator):
@staticmethod
@staticmethod
def
main_check
(
obj
,
info
):
def
main_check
(
obj
,
info
):
import
array
scene
=
bpy
.
context
.
scene
scene
=
bpy
.
context
.
scene
print_3d
=
scene
.
print_3d
print_3d
=
scene
.
print_3d
angle_distort
=
print_3d
.
angle_distort
angle_distort
=
print_3d
.
angle_distort
def
face_is_distorted
(
ele
):
no
=
ele
.
normal
angle_fn
=
no
.
angle
for
loop
in
ele
.
loops
:
loopno
=
loop
.
calc_normal
()
if
loopno
.
dot
(
no
)
<
0.0
:
loopno
.
negate
()
if
angle_fn
(
loopno
,
1000.0
)
>
angle_distort
:
return
True
return
False
bm
=
mesh_helpers
.
bmesh_copy_from_object
(
obj
,
transform
=
True
,
triangulate
=
False
)
bm
=
mesh_helpers
.
bmesh_copy_from_object
(
obj
,
transform
=
True
,
triangulate
=
False
)
bm
.
normal_update
()
bm
.
normal_update
()
faces_distort
=
array
.
array
(
'
i
'
,
(
i
for
i
,
ele
in
enumerate
(
bm
.
faces
)
if
face_is_distorted
(
ele
)))
faces_distort
=
array
.
array
(
'
i
'
,
(
i
for
i
,
ele
in
enumerate
(
bm
.
faces
)
if
mesh_helpers
.
face_is_distorted
(
ele
,
angle_distort
))
)
info
.
append
((
"
Non-Flat Faces: %d
"
%
len
(
faces_distort
),
info
.
append
((
"
Non-Flat Faces: %d
"
%
len
(
faces_distort
),
(
bmesh
.
types
.
BMFace
,
faces_distort
)))
(
bmesh
.
types
.
BMFace
,
faces_distort
)))
...
@@ -418,20 +407,11 @@ class MESH_OT_Print3D_Clean_Distorted(Operator):
...
@@ -418,20 +407,11 @@ class MESH_OT_Print3D_Clean_Distorted(Operator):
print_3d
=
scene
.
print_3d
print_3d
=
scene
.
print_3d
angle_distort
=
print_3d
.
angle_distort
angle_distort
=
print_3d
.
angle_distort
def
face_is_distorted
(
ele
):
no
=
ele
.
normal
angle_fn
=
no
.
angle
for
loop
in
ele
.
loops
:
if
angle_fn
(
loop
.
calc_normal
(),
1000.0
)
>
angle_distort
:
return
True
return
False
obj
=
context
.
active_object
obj
=
context
.
active_object
bm
=
mesh_helpers
.
bmesh_from_object
(
obj
)
bm
=
mesh_helpers
.
bmesh_from_object
(
obj
)
bm
.
normal_update
()
bm
.
normal_update
()
elems_triangulate
=
[
ele
for
ele
in
bm
.
faces
if
face_is_distorted
(
ele
)]
elems_triangulate
=
[
ele
for
ele
in
bm
.
faces
if
mesh_helpers
.
face_is_distorted
(
ele
,
angle_distort
)]
# edit
if
elems_triangulate
:
if
elems_triangulate
:
bmesh
.
ops
.
triangulate
(
bm
,
faces
=
elems_triangulate
)
bmesh
.
ops
.
triangulate
(
bm
,
faces
=
elems_triangulate
)
mesh_helpers
.
bmesh_to_object
(
obj
,
bm
)
mesh_helpers
.
bmesh_to_object
(
obj
,
bm
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment