194
194
def bin2(self, image_iter, bin2_method_type="SLOW"):
195
195
''' this is an iterator that: Given an image iterator will yield binned lines '''
197
ignore_value = self.__ignore_value
197
199
img_props = next(image_iter)
198
200
# dimensions shrink as we remove pixels
199
201
processed_dims = img_props.processed_dims()
208
210
# Take two lists [a1, a2, a3], [b1, b2, b3] and combine them into one
209
211
# list of [a1 + b1, a2+b2, ... ] as long as both values are not ignorable
210
combine_fun = lambda a, b: a != self.__ignore_value and b != self.__ignore_value and a + b or self.__ignore_value
212
combine_fun = lambda a, b: a != ignore_value and b != ignore_value and (a + b)/2 or ignore_value
277
281
binned_data.append( IGNORE_VALUE )
279
binned_data.append( sum(ints) / len(ints) )
283
binned_data.append( sum(ints, 0.0) / len(ints) )
282
287
return binned_data
284
289
def bin6_real_fast(self, raw_data):
499
504
point_offset += len( last_line ) - last_line.count(None)
500
505
for z in last_line:
502
coords.extend([x*scale_x, 0.0, z])
507
coords.append( (x*scale_x, 0.0, z) )
579
584
last_line = dtm_line
581
586
me = bpy.data.meshes.new(img_props.name()) # create a new mesh
583
me.vertices.add(len(coords)/3)
584
me.vertices.foreach_set("co", coords)
586
me.faces.add(len(faces)/4)
587
me.faces.foreach_set("vertices_raw", faces)
587
#from_pydata(self, vertices, edges, faces)
588
#Make a mesh from a list of vertices/edges/faces
589
#Until we have a nicer way to make geometry, use this.
591
# float triplets each representing (X, Y, Z)
592
# eg: [(0.0, 1.0, 0.5), ...].
593
#:type vertices: iterable object
595
# int pairs, each pair contains two indices to the
596
# *vertices* argument. eg: [(1, 2), ...]
597
#:type edges: iterable object
599
# iterator of faces, each faces contains three or more indices to
600
# the *vertices* argument. eg: [(5, 6, 8, 9), (1, 2, 3), ...]
601
#:type faces: iterable object
602
me.from_pydata(coords, [], faces)
604
# me.vertices.add(len(coords)/3)
605
# me.vertices.foreach_set("co", coords)
606
# me.faces.add(len(faces)/4)
607
# me.faces.foreach_set("vertices_raw", faces)