| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
... by replacing double pointers by fixed-size `std::array`, or a return `tuple`. With gcc (and optimization enabled?), this has no effect on code size, but gives compile-time (and better runtime) checks that there are no out-of-bounds access.
... by avoiding double pointers.
It is `bool` for the Python wrapper, while internally `int`, but can be `bool` consistently. Also mark it as `inline` since it's used in a template and the compiler warns about a possible ODR violation (which isn't a problem since it's only used in one file.)
By using the existing `XY` type to replace x/y pairs, and taking advantage of struct methods.
Use `XY` type to shorten internals, and `agg::rect_d::normalize` to shorten initialization.
Sorry, something went wrong.
If I'm not mistaken, 2D line clipping uses a different algorithm: matplotlib/src/path_converters.h Lines 322 to 520 in 5b38f50 This makes some sense as it doesn't need to preserve polygon fills, but I'm not sure if the one implemented here can be "downgraded" to simple lines or whether I'd have to implement that one as well. |
Sorry, something went wrong.
|
So I went looking through the 2D code again, and surprisingly, nothing uses the Sutherland-Hodgman algorithm. The C++ code is called by Path.clip_to_bbox but the only things that use it are tests. All the 2D code uses the Liang-Barsky clipping algorithm in PathClipper that's really implemented in Agg. I tend to find Agg code a bit more obtuse, but this one doesn't look too bad to copy, though it'll need to be adjusted to 3D as well. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR summary
Based on @scottshambaugh's comment, I took the existing 2D clipping algorithm and extended it to 3D. That turned out to be quite straightforward as it already worked on each direction independently. Most of the work was actually with regards to the plumbing to get things in and out. Then I implemented it for Poly3DCollection and Patch3D.
There are still a few things to finish this:
Using the example from #8902 without clipping, the bars are quite misleading, as it seems like they are in a completely different spot initially compared to when looking at them edgewise.
Screencast.From.2025-09-12.05-24-46.mp4whereas with clipping here, we get something that isn't so weird:
Screencast.From.2025-09-12.05-25-33.mp4This is based on #30208.
PR checklist