Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions meshlabxml/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ def merge_vert(script, threshold=0.0):
"""
filter_xml = ''.join([
' <filter name="Merge Close Vertices">\n',
' <Param name="Threshold" ',
' <Param ',
'value="{}" '.format(threshold),
'name="Threshold" ',
'description="Merging distance" ',
'min="0" ',
'max="1" ',
Expand Down Expand Up @@ -65,23 +66,26 @@ def close_holes(script, hole_max_edge=30, selected=False,
"""
filter_xml = ''.join([
' <filter name="Close Holes">\n',
' <Param name="MaxHoleSize" ',
'value="{:d}" '.format(hole_max_edge),
' <Param value="{:d}" '.format(hole_max_edge),
'name="MaxHoleSize" ',
'description="Max size to be closed" ',
'type="RichInt" ',
'/>\n',
' <Param name="Selected" ',
' <Param ',
'value="{}" '.format(str(selected).lower()),
'name="Selected" ',
'description="Close holes with selected faces" ',
'type="RichBool" ',
'/>\n',
' <Param name="NewFaceSelected" ',
' <Param ',
'value="{}" '.format(str(sel_new_face).lower()),
'name="NewFaceSelected" ',
'description="Select the newly created faces" ',
'type="RichBool" ',
'/>\n',
' <Param name="SelfIntersection" ',
'value="{}" '.format(str(self_intersection).lower()),
' <Param ',
'value"{}" '.format(str(self_intersection).lower()),
'name="SelfIntersection" ',
'description="Prevent creation of selfIntersecting faces" ',
'type="RichBool" ',
'/>\n',
Expand Down Expand Up @@ -113,8 +117,9 @@ def split_vert_on_nonmanifold_face(script, vert_displacement_ratio=0.0):
filter_name = 'Repair non Manifold Vertices by splitting'
filter_xml = ''.join([
' <filter name="{}">\n'.format(filter_name),
' <Param name="VertDispRatio" ',
' <Param ',
'value="{}" '.format(vert_displacement_ratio),
'name="VertDispRatio" ',
'description="Vertex Displacement Ratio" ',
'type="RichFloat" ',
'/>\n',
Expand Down Expand Up @@ -175,13 +180,15 @@ def snap_mismatched_borders(script, edge_dist_ratio=0.01, unify_vert=True):
"""
filter_xml = ''.join([
' <filter name="Snap Mismatched Borders">\n',
' <Param name="EdgeDistRatio" ',
' <Param ',
'value="{}" '.format(edge_dist_ratio),
'name="EdgeDistRatio" ',
'description="Edge Distance Ratio" ',
'type="RichFloat" ',
'/>\n',
' <Param name="UnifyVertices" ',
' <Param ',
'value="{}" '.format(str(unify_vert).lower()),
'name="UnifyVertices" ',
'description="UnifyVertices" ',
'type="RichBool" ',
'/>\n',
Expand Down
25 changes: 16 additions & 9 deletions meshlabxml/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,27 @@ def join(script, merge_visible=True, merge_vert=False, delete_layer=True,
"""
filter_xml = ''.join([
' <filter name="Flatten Visible Layers">\n',
' <Param name="MergeVisible" ',
' <Param ',
'value="{}" '.format(str(merge_visible).lower()),
'name="MergeVisible" ',
'description="Merge Only Visible Layers" ',
'type="RichBool" ',
'/>\n',
' <Param name="MergeVertices" ',
' <Param ',
'value="{}" '.format(str(merge_vert).lower()),
'name="MergeVertices" ',
'description="Merge duplicate vertices" ',
'type="RichBool" ',
'/>\n',
' <Param name="DeleteLayer" ',
' <Param ',
'value="{}" '.format(str(delete_layer).lower()),
'name="DeleteLayer" ',
'description="Delete Layers" ',
'type="RichBool" ',
'/>\n',
' <Param name="AlsoUnreferenced" ',
' <Param ',
'value="{}" '.format(str(keep_unreferenced_vert).lower()),
'name="AlsoUnreferenced" ',
'description="Keep unreferenced vertices" ',
'type="RichBool" ',
'/>\n',
Expand Down Expand Up @@ -134,8 +138,9 @@ def rename(script, label='blank', layer_num=None):
"""
filter_xml = ''.join([
' <filter name="Rename Current Mesh">\n',
' <Param name="newName" ',
' <Param ',
'value="{}" '.format(label),
'name="newName" ',
'description="New Label" ',
'type="RichString" ',
'/>\n',
Expand Down Expand Up @@ -180,17 +185,19 @@ def change(script, layer_num=None):
if script.ml_version == '1.3.4BETA' or script.ml_version == '2016.12':
filter_xml = ''.join([
' <filter name="Change the current layer">\n',
' <Param name="mesh" ',
'value="{:d}" '.format(layer_num),
' <Param ',
'value="{:f}" '.format(layer_num),
'name="mesh" ',
'description="Mesh" ',
'type="RichMesh" ',
'/>\n',
' </filter>\n'])
else:
filter_xml = ''.join([
' <filter name="Change the current layer">\n',
' <Param name="layer" ',
'value="{:d}" '.format(layer_num),
' <Param ',
'value="{:f}" '.format(layer_num),
'name="layer" ',
'description="Layer Name" ',
'type="RichMesh" ',
'/>\n',
Expand Down
75 changes: 45 additions & 30 deletions meshlabxml/smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,29 @@ def laplacian(script, iterations=1, boundary=True, cotangent_weight=True,
"""
filter_xml = ''.join([
' <filter name="Laplacian Smooth">\n',
' <Param name="stepSmoothNum" ',
' <Param ',
'value="{:d}" '.format(iterations),
'description="Smoothing steps" ',
'type="RichInt" ',
'name="stepSmoothNum" ',
'description="Smoothing steps" ',
'/>\n',
' <Param name="Boundary" ',
' <Param ',
'value="{}" '.format(str(boundary).lower()),
'description="1D Boundary Smoothing" ',
'type="RichBool" ',
'name="Boundary" ',
'description="1D Boundary Smoothing" ',
'/>\n',
' <Param name="cotangentWeight" ',
' <Param ',
'value="{}" '.format(str(cotangent_weight).lower()),
'description="Cotangent weighting" ',
'type="RichBool" ',
'name="cotangentWeight" ',
'description="Cotangent weighting" ',
'/>\n',
' <Param name="Selected" ',
' <Param ',
'value="{}" '.format(str(selected).lower()),
'description="Affect only selected faces" ',
'type="RichBool" ',
'name="Selected" ',
'description="Affect only selected faces" ',
'/>\n',
' </filter>\n'])
util.write_filter(script, filter_xml)
Expand Down Expand Up @@ -101,25 +105,29 @@ def taubin(script, iterations=10, t_lambda=0.5, t_mu=-0.53, selected=False):
"""
filter_xml = ''.join([
' <filter name="Taubin Smooth">\n',
' <Param name="lambda" ',
' <Param ',
'value="{}" '.format(t_lambda),
'name="lambda" ',
'description="Lambda" ',
'type="RichFloat" ',
'/>\n',
' <Param name="mu" ',
' <Param ',
'value="{}" '.format(t_mu),
'description="mu" ',
'type="RichFloat" ',
'name="mu" ',
'description="mu" ',
'/>\n',
' <Param name="stepSmoothNum" ',
' <Param ',
'value="{:d}" '.format(iterations),
'description="Smoothing steps" ',
'type="RichInt" ',
'name="stepSmoothNum" ',
'description="Smoothing steps" ',
'/>\n',
' <Param name="Selected" ',
' <Param ',
'value="{}" '.format(str(selected).lower()),
'description="Affect only selected faces" ',
'type="RichBool" ',
'name="Selected" ',
'description="Affect only selected faces" ',
'/>\n',
' </filter>\n'])
util.write_filter(script, filter_xml)
Expand Down Expand Up @@ -164,30 +172,35 @@ def twostep(script, iterations=3, angle_threshold=60, normal_steps=20, fit_steps
"""
filter_xml = ''.join([
' <filter name="TwoStep Smooth">\n',
' <Param name="stepSmoothNum" ',
' <Param ',
'value="{:d}" '.format(iterations),
'description="Smoothing steps" ',
'type="RichInt" ',
'name="stepSmoothNum" ',
'description="Smoothing steps" ',
'/>\n',
' <Param name="normalThr" ',
' <Param ',
'value="{}" '.format(angle_threshold),
'description="Feature Angle Threshold (deg)" ',
'type="RichFloat" ',
'name="normalThr" ',
'description="Feature Angle Threshold (deg)" ',
'/>\n',
' <Param name="stepNormalNum" ',
' <Param ',
'value="{:d}" '.format(normal_steps),
'description="Normal Smoothing steps" ',
'type="RichInt" ',
'name="stepNormalNum" ',
'description="Normal Smoothing steps" ',
'/>\n',
' <Param name="stepFitNum" ',
' <Param ',
'value="{:d}" '.format(fit_steps),
'description="Vertex Fitting steps" ',
'type="RichInt" ',
'name="stepFitNum" ',
'description="Vertex Fitting steps" ',
'/>\n',
' <Param name="Selected" ',
' <Param ',
'value="{}" '.format(str(selected).lower()),
'description="Affect only selected faces" ',
'type="RichBool" ',
'name="Selected" ',
'description="Affect only selected faces" ',
'/>\n',
' </filter>\n'])
util.write_filter(script, filter_xml)
Expand Down Expand Up @@ -217,22 +230,24 @@ def depth(script, iterations=3, viewpoint=(0, 0, 0), selected=False):
"""
filter_xml = ''.join([
' <filter name="Depth Smooth">\n',
' <Param name="stepSmoothNum" ',
' <Param ',
'value="{:d}" '.format(iterations),
'description="Smoothing steps" ',
'type="RichInt" ',
'name="stepSmoothNum" ',
'description="Smoothing steps" ',
'/>\n',
' <Param name="viewPoint" ',
' <name="viewPoint" ',
'x="{}" '.format(viewpoint[0]),
'y="{}" '.format(viewpoint[1]),
'z="{}" '.format(viewpoint[2]),
'description="Smoothing steps" ',
'type="RichPoint3f" ',
'/>\n',
' <Param name="Selected" ',
' <Param ',
'value="{}" '.format(str(selected).lower()),
'description="Affect only selected faces" ',
'type="RichBool" ',
'name="Selected" ',
'description="Affect only selected faces" ',
'/>\n',
' </filter>\n'])
util.write_filter(script, filter_xml)
Expand Down