def write_property(prop, filename, prop_name, undefined_value, indicator_values=[]): if (prop.data.ndim == 3): sh = _create_hpgl_shape(prop.data.shape) else: sh = _create_hpgl_shape((prop.data.size, 1, 1)) if isinstance(prop, ContProperty): marr = _HPGL_CONT_MASKED_ARRAY( data = prop.data.ctypes.data_as(C.POINTER(C.c_float)), mask = prop.mask.ctypes.data_as(C.POINTER(C.c_ubyte)), shape = sh) _hpgl_so.hpgl_write_inc_file_float( filename, C.byref(marr), undefined_value, prop_name) else: marr = _HPGL_IND_MASKED_ARRAY( data = prop.data.ctypes.data_as(C.POINTER(C.c_ubyte)), mask = prop.mask.ctypes.data_as(C.POINTER(C.c_ubyte)), shape = sh, indicator_count = prop.indicator_count) _hpgl_so.hpgl_write_inc_file_byte( filename, C.byref(marr), undefined_value, prop_name, numpy.array(indicator_values).ctypes.data_as(C.POINTER(C.c_ubyte)), len(indicator_values))
def _create_hpgl_ind_masked_array(prop, grid): if (grid is None): sh = _create_hpgl_shape(prop.data.shape, __get_strides(prop.data)) assert(prop.data.strides == prop.mask.strides) else: sh = _create_hpgl_shape((grid.x, grid.y, grid.z)) return _HPGL_IND_MASKED_ARRAY( data=prop.data.ctypes.data_as(C.POINTER(C.c_ubyte)), mask=prop.mask.ctypes.data_as(C.POINTER(C.c_ubyte)), shape = sh, indicator_count = prop.indicator_count)