Skip to content

Instantly share code, notes, and snippets.

@show0k
Created December 9, 2015 06:48
Show Gist options
  • Save show0k/bd9481d2e221d203aa5b to your computer and use it in GitHub Desktop.
Save show0k/bd9481d2e221d203aa5b to your computer and use it in GitHub Desktop.
Clean STL for 3D simulator
#!/bin/bash
# Delete 80% of meshes
# you need to install meshlab before :
# -> sudo apt-get install meshlab on Debian
# -> brew install meshlab on OSX
for f in `ls *.STL`; do
echo $f
meshlabserver -i "$f" -s script.mlx -o "$f"
done
<!DOCTYPE FilterScript>
<FilterScript>
<filter name="Snap Mismatched Borders">
<Param type="RichFloat" value="0.01" name="EdgeDistRatio"/>
<Param type="RichBool" value="true" name="UnifyVertices"/>
</filter>
<filter name="Merge Close Vertices">
<Param type="RichAbsPerc" value="0.000250233" min="0" name="Threshold" max="0.000521319"/>
</filter>
<filter name="Quadric Edge Collapse Decimation">
<Param type="RichInt" value="0" name="TargetFaceNum"/>
<Param type="RichFloat" value="0.2" name="TargetPerc"/>
<Param type="RichFloat" value="0.3" name="QualityThr"/>
<Param type="RichBool" value="false" name="PreserveBoundary"/>
<Param type="RichFloat" value="1" name="BoundaryWeight"/>
<Param type="RichBool" value="true" name="PreserveNormal"/>
<Param type="RichBool" value="true" name="PreserveTopology"/>
<Param type="RichBool" value="true" name="OptimalPlacement"/>
<Param type="RichBool" value="true" name="PlanarQuadric"/>
<Param type="RichBool" value="false" name="QualityWeight"/>
<Param type="RichBool" value="true" name="AutoClean"/>
<Param type="RichBool" value="false" name="Selected"/>
</filter>
</FilterScript>
@show0k
Copy link
Author

show0k commented Jan 28, 2016

To use it:

wget https://gist.githubusercontent.com/show0k/bd9481d2e221d203aa5b/raw/1f8cac11cd7c1c8c4f20f6364cd459f8d4226c3f/script.mlx
wget https://gist.githubusercontent.com/show0k/bd9481d2e221d203aa5b/raw/1f8cac11cd7c1c8c4f20f6364cd459f8d4226c3f/mesh_decimation.bash
bash mesh_decimation.bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment