[FEATURE] Disconnect masked triangles from graphes in `compute_paths`
enhancementgood first issuepythonrustnice-to-have
### Terms
- [x] Checked the [existing issues](https://github.com/jeertmans/DiffeRT/issues?q=is%3Aissue+label%3Aenhancement) to see if my suggestion has not already been suggested;
### Description
At the moment, the `TriangleScene.compute_paths` does not reduce the number of path candidates by disconnecting inactive triangles (or quads) from the graph before generating the path candidates. This has the benefit of generating fixed-sized arrays of path candidates, regardless of the number of active triangles.
However, this also means that we always have to pay the full price of generating all the path candidates, while we could save a lot of computational time, leveraging [`DiGraph.disconnect_nodes`](https://differt.eertmans.be/latest/reference/_autosummary/differt_core.rt.DiGraph.html#differt_core.rt.DiGraph.disconnect_nodes).
I think we should add a new argument `disconnect_inactive_triangles: bool = False`, and modify the code such that it contains:
```python
# The number of path candidates generated by the 'hybrid' method already
# depends on the mask, so we will always disconnect nodes in that case.
if (disconnect_inactive_triangles or method == 'hybrid') and self.mesh.mask is not None:
mask = self.mesh.mask
if self.mesh.assume_quads:
mask = mask[0::2] & mask[1::2]
graph = graph.filter_by_mask(np.asarray(mask))
```
where `DiGraph.filter_by_mask` is a better version (**to be implemented**) of `DiGraph.disconnect_nodes` that accepts NumPy arrays. Finally, we should benchmark to see if `fast = True` or `fast = False` should be used.
### Screenshots
_No response_
### Additional information
_No response_
0 条评论