Example #1
0
 def test_saved_equals_original_binary(self):
     '''Tests if saved binary file is identical to the loaded one'''
     stl1 = Stl(asset('block.stl'))
     stl1.write_binary(asset('block_binary.stl'))
     stl2 = Stl(asset('block_binary.stl'))
     stl2.write_binary(asset('block_binary2.stl'))
     assert filecmp.cmp(asset('block_binary.stl'), asset('block_binary2.stl'))
Example #2
0
 def test_saved_binary_is_binary(self):
     '''Tests if saved binary file is identical to the loaded one'''
     stl1 = Stl(asset('block.stl'))
     stl1.write_binary(asset('block_binary.stl'))
     stl2 = Stl(asset('block_binary.stl'))
     assert stl2.stats['type'] == Stl.BINARY
Example #3
0
if __name__ == '__main__':
  # Determines the feasibitily of an STL model

  if len(sys.argv) < 1:
    print "Need at least a file name"
    exit(1)
  print "=" * 80
  print "Analyzing model ", sys.argv[1]
  stl = Stl(sys.argv[1])

  # Although stl_repair provided a function that can repair errors in one shot,
  # it does not give error messages. Here we report each steps.
  tolerance = 0.0000001

  stl.check_facets_exact()

  stats = stl.stats
  if stats['facets_w_1_bad_edge'] > 0 or stats['facets_w_2_bad_edge'] >0 or stats['facets_w_3_bad_edge'] > 0:
    print "Bad edges on facets"

  shortest_edge = stats['shortest_edge']
  if shortest_edge < tolerance:
    print "Edge too short, cannot print"

  stl.repair(fill_holes_flag = True, iterations = 4)
  print sys.argv
  if len(sys.argv) == 3:
    stl.write_binary(sys.argv[2]) 
  # pprint.pprint(stl.stats)
  print