Helper to get the material for a given label.
(label: TDF_Label)
| 45 | |
| 46 | |
| 47 | def _get_material(label: TDF_Label) -> Material | None: |
| 48 | """ |
| 49 | Helper to get the material for a given label. |
| 50 | """ |
| 51 | |
| 52 | rv = None |
| 53 | |
| 54 | material_ref_guid = XCAFDoc.MaterialRefGUID_s() |
| 55 | |
| 56 | if label.IsAttribute(material_ref_guid): |
| 57 | attr = TDataStd_TreeNode() |
| 58 | label.FindAttribute(material_ref_guid, attr) |
| 59 | material_label = attr.Father().Label() |
| 60 | |
| 61 | material_attr = XCAFDoc_Material() |
| 62 | |
| 63 | material_label.FindAttribute(XCAFDoc_Material.GetID_s(), material_attr) |
| 64 | name = material_attr.GetName().ToCString() |
| 65 | description = material_attr.GetDescription().ToCString() |
| 66 | density = material_attr.GetDensity() |
| 67 | density_unit = material_attr.GetDensValType().ToCString() |
| 68 | |
| 69 | rv = Material( |
| 70 | name=name, |
| 71 | description=description, |
| 72 | density=density, |
| 73 | densityUnit=density_unit, |
| 74 | ) |
| 75 | |
| 76 | return rv |
| 77 | |
| 78 | |
| 79 | def _get_ref_color(label: TDF_Label) -> Color | None: |
no test coverage detected