parameters: (shell)
docstring: Translates a shell
docstring_summary: Translates a shell
docstring_tokens: Translates a shell
function: def translate_shell(shell):
      """Translates a shell"""
      if 'href' in shell.attrib:
          # Do href here
          return {
              'id': shell.attrib['id'],
              'size': int(shell.attrib['size']),
              'bbox': [float(x) for x in shell.attrib['bbox'].split(" ")],
              'href': shell.attrib['href'].replace("xml", "json")
          }
      else:
          # Convert XML point/vert/color to new way
          points = load_points(shell.iter("verts"))
          default_color = parse_color(shell.attrib.get('color', DEFAULT_COLOR))
          data = dict(id=shell.attrib['id'], size=0)
          data.update({x: [] for x in ('points', 'normals', 'colors')})
          for facet in shell.iter('facets'):
              color = default_color
              if 'color' in facet.attrib:
                  color = parse_color(facet.attrib['color'])
              for f in facet.iter('f'):
                  # Get every vertex index and convert using points array
                  index_vals = f.attrib['v'].split(" ")
                  for i in range(3):
                      ival = int(index_vals[i]) * 3
                      data['points'].append(float(points[ival]))
                      data['points'].append(float(points[ival + 1]))
                      data['points'].append(float(points[ival + 2]))
  
                  # Get the vertex normals
                  norms = [x for x in f.iter('n')]
                  for i in range(3):
                      norm_coordinates = norms[i].attrib['d'].split(" ")
                      for j in range(3):
                          data['normals'].append(float(norm_coordinates[j]))
  
                  # Get the vertex colors
                  for i in range(3):
                      for c in ('r', 'g', 'b'):
                          data['colors'].append(color[c])
  
          data['size'] = len(data['points']) / 9
          indexing = [x for x in CONFIG if x.startswith('index') and CONFIG[x]]
          for i in indexing:
              data['precision'] = CONFIG['roundPrecision']
              if 'values' not in data:
                  data['values'] = {}
              globals()[i](data)
          if indexing:
              sorted_vals = sorted(data['values'].items(), key=itemgetter(1))
              data['values'] = map(itemgetter(0), sorted_vals)
          if CONFIG.get('compressColors'):
              compress_shell_colors(data)
          return data
function_tokens: def translate_shell ( shell ) : if 'href' in shell . attrib : # Do href here return { 'id' : shell . attrib [ 'id' ] , 'size' : int ( shell . attrib [ 'size' ] ) , 'bbox' : [ float ( x ) for x in shell . attrib [ 'bbox' ] . split ( " " ) ] , 'href' : shell . attrib [ 'href' ] . replace ( "xml" , "json" ) } else : # Convert XML point/vert/color to new way points = load_points ( shell . iter ( "verts" ) ) default_color = parse_color ( shell . attrib . get ( 'color' , DEFAULT_COLOR ) ) data = dict ( id = shell . attrib [ 'id' ] , size = 0 ) data . update ( { x : [ ] for x in ( 'points' , 'normals' , 'colors' ) } ) for facet in shell . iter ( 'facets' ) : color = default_color if 'color' in facet . attrib : color = parse_color ( facet . attrib [ 'color' ] ) for f in facet . iter ( 'f' ) : # Get every vertex index and convert using points array index_vals = f . attrib [ 'v' ] . split ( " " ) for i in range ( 3 ) : ival = int ( index_vals [ i ] ) * 3 data [ 'points' ] . append ( float ( points [ ival ] ) ) data [ 'points' ] . append ( float ( points [ ival + 1 ] ) ) data [ 'points' ] . append ( float ( points [ ival + 2 ] ) ) # Get the vertex normals norms = [ x for x in f . iter ( 'n' ) ] for i in range ( 3 ) : norm_coordinates = norms [ i ] . attrib [ 'd' ] . split ( " " ) for j in range ( 3 ) : data [ 'normals' ] . append ( float ( norm_coordinates [ j ] ) ) # Get the vertex colors for i in range ( 3 ) : for c in ( 'r' , 'g' , 'b' ) : data [ 'colors' ] . append ( color [ c ] ) data [ 'size' ] = len ( data [ 'points' ] ) / 9 indexing = [ x for x in CONFIG if x . startswith ( 'index' ) and CONFIG [ x ] ] for i in indexing : data [ 'precision' ] = CONFIG [ 'roundPrecision' ] if 'values' not in data : data [ 'values' ] = { } globals ( ) [ i ] ( data ) if indexing : sorted_vals = sorted ( data [ 'values' ] . items ( ) , key = itemgetter ( 1 ) ) data [ 'values' ] = map ( itemgetter ( 0 ) , sorted_vals ) if CONFIG . get ( 'compressColors' ) : compress_shell_colors ( data ) return data