Implementation for inspecting Eigen::Matrix and Eigen::Map
| 13 | |
| 14 | |
| 15 | class EigenXX(interface.TypeInspectorInterface): |
| 16 | """ |
| 17 | Implementation for inspecting Eigen::Matrix and Eigen::Map |
| 18 | """ |
| 19 | def get_buffer_metadata(self, obj_name, picked_obj, debugger_bridge): |
| 20 | """ |
| 21 | Gets the buffer meta data from types of the Eigen Library |
| 22 | Note that it only implements single channel matrix display, |
| 23 | which should be quite common in Eigen. |
| 24 | """ |
| 25 | |
| 26 | type_str = str(picked_obj.type) |
| 27 | is_eigen_map = 'Map' in type_str |
| 28 | # First we need the python object for the actual matrix type. When |
| 29 | # parsing a Map, the type is the first template parameter of the |
| 30 | # wrapper type. Otherwise, it is the type field of the picked_obj |
| 31 | if is_eigen_map: |
| 32 | matrix_type_obj = picked_obj.type.template_argument(0) |
| 33 | else: |
| 34 | matrix_type_obj = picked_obj.type |
| 35 | |
| 36 | current_type = str(matrix_type_obj.template_argument(0)) |
| 37 | height = int(matrix_type_obj.template_argument(1)) |
| 38 | width = int(matrix_type_obj.template_argument(2)) |
| 39 | matrix_flag = int(matrix_type_obj.template_argument(3)) |
| 40 | transpose_buffer = ((matrix_flag&0x1) == 0) |
| 41 | dynamic_buffer = False |
| 42 | |
| 43 | if height <= 0: |
| 44 | # Buffer has dynamic width |
| 45 | if is_eigen_map: |
| 46 | height = int(picked_obj['m_rows']['m_value']) |
| 47 | else: |
| 48 | height = int(picked_obj['m_storage']['m_rows']) |
| 49 | dynamic_buffer = True |
| 50 | |
| 51 | if width <= 0: |
| 52 | # Buffer has dynamic height |
| 53 | if is_eigen_map: |
| 54 | width = int(picked_obj['m_cols']['m_value']) |
| 55 | else: |
| 56 | width = int(picked_obj['m_storage']['m_cols']) |
| 57 | dynamic_buffer = True |
| 58 | |
| 59 | if transpose_buffer: |
| 60 | width, height = height, width |
| 61 | |
| 62 | # Assign the OpenImageDebugger type according to underlying type |
| 63 | if current_type == 'short': |
| 64 | type_value = symbols.OID_TYPES_INT16 |
| 65 | elif current_type == 'float': |
| 66 | type_value = symbols.OID_TYPES_FLOAT32 |
| 67 | elif current_type == 'double': |
| 68 | type_value = symbols.OID_TYPES_FLOAT64 |
| 69 | elif current_type == 'int': |
| 70 | type_value = symbols.OID_TYPES_INT32 |
| 71 | |
| 72 | # Differentiate between Map and dynamic/static Matrices |
nothing calls this directly
no outgoing calls
no test coverage detected