-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added "checks" before exporting project folders. Made changes in "Mesh2Input.py" #141
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,6 +11,8 @@ | |||||||||||
from bpy.props import StringProperty, BoolProperty, EnumProperty, \ | ||||||||||||
IntProperty, FloatProperty | ||||||||||||
from bpy_extras.io_utils import ExportHelper | ||||||||||||
import re | ||||||||||||
from object_print3d_utils import report | ||||||||||||
|
||||||||||||
bl_info = { | ||||||||||||
"name": "Mesh2HRTF export add-on", | ||||||||||||
|
@@ -83,6 +85,13 @@ class ExportMesh2HRTF(bpy.types.Operator, ExportHelper): | |||||||||||
description="Render pictures of the 3D mesh", | ||||||||||||
default=True, | ||||||||||||
) | ||||||||||||
|
||||||||||||
checkall: BoolProperty( | ||||||||||||
name="3D-Print Checks", | ||||||||||||
description= ("Check geometry"), #Added by Sanket | ||||||||||||
default=True, | ||||||||||||
) | ||||||||||||
|
||||||||||||
# post-processing --------------------------------------------------------- | ||||||||||||
reference: BoolProperty( | ||||||||||||
name="Reference", | ||||||||||||
|
@@ -200,6 +209,7 @@ def draw(self, context): | |||||||||||
row.prop(self, "programPath") | ||||||||||||
row = layout.row() | ||||||||||||
row.prop(self, "pictures") | ||||||||||||
row.prop(self, "checkall") #Added by Sanket | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case we add separate parameters for different checks, this should get its own subcategory |
||||||||||||
# post-processing | ||||||||||||
layout.label(text="Post-processing:") | ||||||||||||
row = layout.row() | ||||||||||||
|
@@ -244,6 +254,7 @@ def save(operator, | |||||||||||
frequencyVectorType='Step size', | ||||||||||||
frequencyVectorValue=100, | ||||||||||||
pictures=True, | ||||||||||||
checkall=True, #Added by Sanket | ||||||||||||
evaluationGrids='ARI', | ||||||||||||
materialSearchPaths='None', | ||||||||||||
method='ML-FMM BEM', | ||||||||||||
|
@@ -318,6 +329,10 @@ def save(operator, | |||||||||||
if os.path.exists(os.path.join(filepath1, "NumCalc")): | ||||||||||||
raise ValueError((f"Project folder {filepath1} already exists. " | ||||||||||||
"Choose another folder or delete files.")) | ||||||||||||
if checkall: | ||||||||||||
_write_checkall_txt(filepath1) #Added by Sanket | ||||||||||||
|
||||||||||||
Comment on lines
+332
to
+334
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest to move this up, where we test for a triangular mesh. It might even make sense to include rthe triangular check only if the user wants to do the checks. Can you benchmark how long those checks take? This would help to decide if it would make sense to include separate parameters for different checks. |
||||||||||||
|
||||||||||||
# create sub-folders | ||||||||||||
subfolders = ["ObjectMeshes", "EvaluationGrids", "NumCalc"] | ||||||||||||
for subfolder in subfolders: | ||||||||||||
|
@@ -1160,6 +1175,48 @@ def _render_pictures(filepath1, unitFactor): | |||||||||||
nameRender = ("%d_deg_azimuth" % azim[ii]) | ||||||||||||
bpy.data.images['Render Result'].save_render( | ||||||||||||
os.path.join(dirRender, "%s.png" % nameRender)) | ||||||||||||
|
||||||||||||
|
||||||||||||
#Added by Sanket | ||||||||||||
def _write_checkall_txt(filepath1): | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets find a more descriptive function name (see comment on |
||||||||||||
"""check all before export""" | ||||||||||||
#check for geometry is solid | ||||||||||||
bpy.ops.mesh.print3d_check_solid() | ||||||||||||
info = report.info() | ||||||||||||
non_manifold = info[0][0] | ||||||||||||
non_manifold_num = int(re.search(r'\d+', non_manifold).group()) | ||||||||||||
bad_contiguous = info[1][0] | ||||||||||||
bad_contiguous_num = int(re.search(r'\d+', bad_contiguous).group()) | ||||||||||||
#check geometry for self intersections | ||||||||||||
bpy.ops.mesh.print3d_check_intersect() | ||||||||||||
info = report.info() | ||||||||||||
intersect_face = info[0][0] | ||||||||||||
intersect_face_num = int(re.search(r'\d+', intersect_face).group()) | ||||||||||||
#check edges are below the sharpness preference | ||||||||||||
bpy.ops.mesh.print3d_check_sharp() | ||||||||||||
info = report.info() | ||||||||||||
sharp_edge = info[0][0] | ||||||||||||
sharp_edge_num = int(re.search(r'\d+', sharp_edge).group()) | ||||||||||||
Comment on lines
+1195
to
+1199
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sharp edges might indeed be a problem in the BEM. Wolfgang might have an idea about how critical this is. Can the threshold for reporting a sharp edge be set? |
||||||||||||
|
||||||||||||
#If there is non-zero number after check-all then raise an error | ||||||||||||
if non_manifold_num != 0 or bad_contiguous_num != 0 or intersect_face_num != 0 or sharp_edge_num != 0: | ||||||||||||
file = open(os.path.join(filepath1, "Error_Checkall_info.txt"), "w", | ||||||||||||
encoding="utf8", newline="\n") | ||||||||||||
Comment on lines
+1203
to
+1204
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any file operations should use the
Suggested change
Lets also think about a good filename. |
||||||||||||
fw = file.write | ||||||||||||
# header -------------------------------------------------------------- | ||||||||||||
fw("##-------------------------------------------\n") | ||||||||||||
fw("## This file was created by mesh2input, export failed because of non-zero values during check-all\n") | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be more illustrative. Maybe add line breaks for readibility:
Suggested change
|
||||||||||||
fw("##\n") | ||||||||||||
fw("##\n") | ||||||||||||
fw("## %s\n" % non_manifold) | ||||||||||||
fw("## %s\n" % bad_contiguous) | ||||||||||||
fw("## %s\n" % intersect_face) | ||||||||||||
fw("## %s\n" % sharp_edge) | ||||||||||||
Comment on lines
+1212
to
+1214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two suggestions:
|
||||||||||||
fw("##\n") | ||||||||||||
fw("##\n") | ||||||||||||
fw("Please make sure the object doesn't have non manifold edges/bad contiguous edges/intersect faces/sharp edges before export") | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line can be deleted if following the comment above |
||||||||||||
file.close() | ||||||||||||
raise ValueError(("Export failed, please refer to Error_checkall_info.txt in defined folder for details")) | ||||||||||||
|
||||||||||||
|
||||||||||||
def _write_nc_inp(filepath1, version, title, | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkall
this could be anything#Added by Sanket
or similar comments. Git keeps track of who added which code...