Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Copyright (c) 2019 Hamza Merzic
  4.  
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11.  
  12. # The above copyright notice and this permission notice shall be included in all
  13. # copies or substantial portions of the Software.
  14.  
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. # SOFTWARE.
  22.  
  23. if [ "$#" -ne 1 ] || ! [ -f "$1" ]; then
  24. echo "Usage: $0 FILE" >&2
  25. exit 1
  26. fi
  27.  
  28. mkdir -p results
  29.  
  30. clean_mesh='<!DOCTYPE FilterScript>
  31. <FilterScript>
  32. <filter name="Remove Duplicate Faces"/>
  33. <filter name="Remove Duplicate Vertices"/>
  34. <filter name="Remove Faces from Non Manifold Edges"/>
  35. <filter name="Re-Compute Face Normals"/>
  36. <filter name="Re-Compute Vertex Normals">
  37. <Param enum_val1="By Angle" type="RichEnum" enum_val2="By Area" value="0" enum_val3="As defined by N. Max" description="Weighting Mode:" tooltip="" name="weightMode" enum_cardinality="4" enum_val0="None (avg)"/>
  38. </filter>
  39. </FilterScript>'
  40.  
  41.  
  42. compute_geometry='<!DOCTYPE FilterScript>
  43. <FilterScript>
  44. <filter name="Transform: Scale, Normalize">
  45. <Param description="X Axis" type="RichFloat" tooltip="Scaling" value="100" name="axisX"/>
  46. <Param description="Y Axis" type="RichFloat" tooltip="Scaling" value="1" name="axisY"/>
  47. <Param description="Z Axis" type="RichFloat" tooltip="Scaling" value="1" name="axisZ"/>
  48. <Param description="Uniform Scaling" type="RichBool" tooltip="If selected an uniform scaling (the same for all the three axis) is applied (the X axis value is used)" value="true" name="uniformFlag"/>
  49. <Param description="Center of scaling:" enum_cardinality="3" type="RichEnum" enum_val1="barycenter" tooltip="Choose a method" value="0" enum_val2="custom point" name="scaleCenter" enum_val0="origin"/>
  50. <Param description="Custom center" type="RichPoint3f" x="0" tooltip="This scaling center is used only if the custom point option is chosen." z="0" name="customCenter" y="0"/>
  51. <Param description="Scale to Unit bbox" type="RichBool" tooltip="If selected, the object is scaled to a box whose sides are at most 1 unit lenght" value="false" name="unitFlag"/>
  52. <Param description="Freeze Matrix" type="RichBool" tooltip="The transformation is explicitly applied, and the vertex coordinates are actually changed" value="true" name="Freeze"/>
  53. <Param description="Apply to all visible Layers" type="RichBool" tooltip="If selected the filter will be applied to all visible mesh layers" value="false" name="allLayers"/>
  54. </filter>
  55. <xmlfilter name="Compute Geometric Measures"/>
  56. </FilterScript>'
  57.  
  58. {
  59. infile=$1
  60. bname=$(basename "$infile")
  61. outfile="results/${bname%.*}.dae"
  62. outfile_tmp="results/${bname%.*}.stl"
  63. logfile1="results/${bname%.*}_tmp.log"
  64. logfile2="results/${bname%.*}.log"
  65. rm -f $outfile $outfile_tmp $logfile1 $logfile2
  66. assimp export $infile $outfile_tmp
  67. assimp export $outfile_tmp $outfile
  68. meshlabserver -l $logfile1 -i $outfile -o $outfile -s <(echo -e $clean_mesh)
  69. meshlabserver -l $logfile2 -i $outfile -s <(echo -e $compute_geometry)
  70. } &> /dev/null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement