* Areas outside the opened area or file wait in a lane in front of its * platforms, so the platforms hold only what lies inside.
(outside: SemanticNode[], inside: SemanticNode[], platforms: SemanticPlatform[])
| 302 | * platforms, so the platforms hold only what lies inside. |
| 303 | */ |
| 304 | function placeOutside(outside: SemanticNode[], inside: SemanticNode[], platforms: SemanticPlatform[]): SemanticPlatform | undefined { |
| 305 | if (!outside.length) return undefined; |
| 306 | const spacing = 34; |
| 307 | const extents = [...platforms.map(platform => [platform.position[0] - platform.width / 2, platform.position[0] + platform.width / 2, platform.position[2] + platform.depth / 2]), |
| 308 | ...inside.map(node => [node.position[0] - 12, node.position[0] + 12, node.position[2] + 12])]; |
| 309 | const left = extents.length ? Math.min(...extents.map(extent => extent[0])) : 0; |
| 310 | const right = extents.length ? Math.max(...extents.map(extent => extent[1])) : 0; |
| 311 | const top = (extents.length ? Math.max(...extents.map(extent => extent[2])) : 0) + 14; |
| 312 | const columns = Math.max(1, Math.min(outside.length, Math.max(Math.floor((right - left + 10) / spacing), Math.ceil(Math.sqrt(outside.length))))); |
| 313 | const rows = Math.ceil(outside.length / columns); |
| 314 | // One extra column on the left keeps the lane's own label clear of the first brick label. |
| 315 | const width = (columns + 1) * spacing + 14; const depth = rows * spacing + 18; const center = (left + right) / 2; |
| 316 | outside.forEach((node, index) => { |
| 317 | node.position = [center + (index % columns + 1 - columns / 2) * spacing, 1.68, top + 28 + Math.floor(index / columns) * spacing]; |
| 318 | }); |
| 319 | return { id: 'hierarchy:outside', path: '', label: 'Outside', position: [center, 1.6, top + depth / 2], width, depth, level: 1 }; |
| 320 | } |
| 321 | |
| 322 | /** Prune empty containers without repacking the stable unfiltered layout. */ |
| 323 | export function pruneHierarchyPlatforms(platforms: SemanticPlatform[], nodes: SemanticNode[]): SemanticPlatform[] { |
no outgoing calls
no test coverage detected