Overlap detection for plotter#3969
Conversation
paulromano
left a comment
There was a problem hiding this comment.
@viktormai Thanks a lot for the PR here, which is a really great start!. In my comments below, I've proposed a different way of handling the storage of the overlaps. It would also be good if you could put a draft PR on the plotter that uses this branch so that I can test it out in practice there.
| // Vector for storing overlaps to later be flattened and sent through the API | ||
| std::vector<std::vector<OverlapKey>> pixel_overlaps_; |
There was a problem hiding this comment.
I see here that currently we're storing this vector of overlap results for each pixel in the image. I have a different concept in my head for how we can store and reference the overlap results. First, we would have a global variable of type std::vector<OverlapKey>. Then, rather than having check_cell_overlap return an OverlapResult, it would return an index into that global vector of OverlapKey. See my next comment about how that index would be used.
| auto overlap = check_cell_overlap(p, false); | ||
| if (!overlap.pairs.empty()) { | ||
| data.set_overlap(y, x, overlap.pairs); |
There was a problem hiding this comment.
Here, if check_cell_overlap returns an index into a global vector of OverlapKey, we can pass that index to set_overlap, which will be used in RasterData::set_overlap to set one of the entries in id_data_ to OVERLAP - index - 1. That is, if the index 0 in the global vector is 0 will result in the pixel being set to -4, index 1 in the vector will result in the pixel being set to -5, etc. Then the openmc_slice_data_overlap_info function can be used to get the corresponding data from the OverlapKey -- rather than passing the x/y pixel indices, it would be passed the index into the global vector of OverlapKey. Each time openmc_slice_data is called, the global vector of OverlapKey should be cleared.
Now that I'm thinking about it, one alternative could be to have the overlap info function return all the data in the global vector:
int openmc_slice_data_overlap_count(size_t* count);
int openmc_slice_data_overlap_info(size_t count, int32_t* overlap_info);
where count is the size of the global vector, and overlap_info would be an array allocated from openmc.lib of size 3*count that has the data written into it as [universe_0, cell1_0, cell2_0, universe_1, cell1_1, cell2_1, ..., universe_count, cell1_count, cell2_count]. That would allow us to minimize the number of calls that are needed through the C API (rather than having to call the overlap info function once for each pixel where there is an overlap, we would call it only once).
Description
This PR adds overlap detection support to the slice data API, enabling
the OpenMC plotter to identify and display which specific cells are
overlapping at a given pixel.
Changes
of a simple boolean, containing a list of OverlapKey pairs (cell1_id,
cell2_id, universe_id) for each detected overlap
pair data during raster plot generation
of overlapping cell pairs at a given pixel
overlapping cell IDs and universe ID at a given pixel
Previously the plotter could color overlap pixels but had no way to tell
the user which cells were overlapping. This change stores the overlap
pair data during plot generation so the plotter can display meaningful
overlap information when a user hovers over an overlap pixel.
Checklist