Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. from utils.jobs import *
  2.  
  3. @job("apply-subdivision")
  4. class BpySubdivisionJob (BpyJob):
  5. @describe('input', type='file', ext='.obj')
  6. @describe('output', type='file', ext='.obj')
  7. @describe('subdivisions', type=intrange(1,6))
  8. def run (self, input, output, subdivisions = 2):
  9. src_obj = self.load_obj(path=input)
  10. cube = self.create_cube()
  11.  
  12. self.apply_subsurf_modifer(cube,
  13. levels=subdivisions, render_levels=subdivisions)
  14.  
  15. self.apply_shrinkwrap_modifier(cube,
  16. target=src_obj)
  17.  
  18. self.export_obj(cube, path=output)
  19.  
  20. if __name__ == '__main__':
  21. BpySubdivisionJob.run_with_sys_args()
  22.  
  23. import os
  24.  
  25. @job("load-taxonomy")
  26. class LocateTaxonomy (FileIOJob):
  27. @describe('input', type='directory')
  28. @describe('output', type='file', ext='.json')
  29. def run (self, input, output):
  30. pass
  31.  
  32. @job("find-synsets")
  33. class SynsetQuery (FileIOJob):
  34. @describe('input', type='string')
  35. @describe('output', type='list')
  36. @describe('taxonomy_path', job='load-taxonomy')
  37. def run (self, input, output, taxonomy_path):
  38. pass
  39.  
  40. @job("build-file-index")
  41. class BuildFileIndexJob (FileIOJob):
  42. @describe('input', type='directory')
  43. @describe('output', type='dict', file='file-index.pkl')
  44. def run (self, input, output):
  45. output['dirs'] = output['dirs'] or {}
  46. output['files'] = output['files'] or {}
  47.  
  48. for file in os.walk
  49. ...
  50.  
  51. @job("find-shapenet-models")
  52. class FindShapenetModels (FileIOJob):
  53. @describe('input', job='build-file-index')
  54. @describe('output', type='list')
  55. def run (self, input, output):
  56. pass
  57.  
  58. @job("find-obj")
  59. class FindObj (FileIOJob):
  60. @describe('input', type='directory')
  61. @describe('output', type='file', ext='.obj')
  62. def run (self, input, output):
  63. pass
  64.  
  65. @job("extract-shapenet-params")
  66. class ExtractShapenetParams (Job):
  67. @describe('input', job='apply-subdivision')
  68. @describe('output', type='dict', ext='.pkl')
  69. def run (self, input, output):
  70. pass
  71.  
  72. @job("collate-shapenet-params")
  73. class CollateShapenetParams (MergeJob):
  74. @describe('inputs', jobs='extract-shapenet-params')
  75. @describe('output', type='file', ext='.json|.json.zip|.pkl')
  76. def run (self, inputs, output):
  77. return {
  78. params['path']: params
  79. for params in inputs
  80. }
  81.  
  82. @job("process-models")
  83. class ProcessModels (Job):
  84. @describe('input', type='directory')
  85. @describe('output', type='file')
  86. @describe('query', type='string', default='')
  87. @describe('subdivisions', type=intrange(1,6), default=2)
  88. def run (self, input, output):
  89. shapenet_dir = self.exec("locate-shapenet-dir",
  90. input=input)
  91.  
  92. synsets = self.exec("find-synsets",
  93. input=self.exec("locate-taxonomy", shapenet_dir),
  94. query=query)
  95.  
  96. models = self.exec("find-matching-models",
  97. input=shapenet_dir,
  98. synsets=synsets)
  99.  
  100. datasets = self.map(models, "process-model-via-subdivision",
  101. subdivisions=subdivisions)
  102.  
  103. data = {
  104. params['path']: params
  105. for params in datasets
  106. }
  107. self.save(data, path=output)
  108.  
  109. if __name__ == '__main__':
  110. ProcessModels.run_with_sys_args()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement