(rep)
| 103 | |
| 104 | |
| 105 | def _summarize_rep(rep) -> dict: |
| 106 | rep_type = rep.RepresentationType or "" |
| 107 | result: dict[str, Any] = {"representation_type": rep_type} |
| 108 | items = list(rep.Items) |
| 109 | |
| 110 | if rep_type == "MappedRepresentation": |
| 111 | for item in items: |
| 112 | if item.is_a("IfcMappedItem"): |
| 113 | return _summarize_rep(item.MappingSource.MappedRepresentation) |
| 114 | |
| 115 | elif rep_type == "SweptSolid": |
| 116 | result["solids"] = [_swept_solid_dict(item) for item in items] |
| 117 | |
| 118 | elif rep_type == "Clipping": |
| 119 | solids = [] |
| 120 | for item in items: |
| 121 | base, planes = _walk_clipping(item) |
| 122 | solid = _swept_solid_dict(base) |
| 123 | if planes: |
| 124 | solid["clipping_planes"] = planes |
| 125 | solids.append(solid) |
| 126 | result["solids"] = solids |
| 127 | |
| 128 | elif rep_type == "CSG": |
| 129 | ops = [] |
| 130 | for item in items: |
| 131 | if hasattr(item, "Operator"): |
| 132 | ops.append({"operator": str(item.Operator), "type": item.is_a()}) |
| 133 | if ops: |
| 134 | result["operations"] = ops |
| 135 | |
| 136 | elif rep_type in ("Brep", "Tessellation", "SolidModel"): |
| 137 | face_count = 0 |
| 138 | vertex_count = 0 |
| 139 | for item in items: |
| 140 | if item.is_a("IfcPolygonalFaceSet"): |
| 141 | face_count += len(item.Faces) |
| 142 | vertex_count += len(item.Coordinates.CoordList) |
| 143 | elif item.is_a("IfcFacetedBrep"): |
| 144 | face_count += len(item.Outer.CfsFaces) |
| 145 | if face_count: |
| 146 | result["face_count"] = face_count |
| 147 | if vertex_count: |
| 148 | result["vertex_count"] = vertex_count |
| 149 | |
| 150 | return result |
| 151 | |
| 152 | |
| 153 | def _geometry_summary(element) -> dict | None: |
no test coverage detected