----------------------------------------------------------------------------------------------
| 275 | |
| 276 | //---------------------------------------------------------------------------------------------- |
| 277 | bool vtkHyperTreeGridFeatureEdges::ShouldAddEdge3D( |
| 278 | vtkHyperTreeGridNonOrientedMooreSuperCursor* cursor, unsigned int edgeId) |
| 279 | { |
| 280 | auto neighborVisible = [&cursor](unsigned int neighborId) |
| 281 | { return cursor->HasTree(neighborId) && !cursor->IsMasked(neighborId); }; |
| 282 | |
| 283 | auto neighborVisibleAndInf = [&cursor, &neighborVisible](unsigned int neighborId) |
| 284 | { return neighborVisible(neighborId) && cursor->GetLevel(neighborId) < cursor->GetLevel(); }; |
| 285 | |
| 286 | auto neighborVisibleAndLeaf = [&cursor, &neighborVisible](unsigned int neighborId) |
| 287 | { return neighborVisible(neighborId) && cursor->IsLeaf(neighborId); }; |
| 288 | |
| 289 | const unsigned int* neighborIds = MOORE_NEIGH_IDS_3D[edgeId]; |
| 290 | |
| 291 | // For a given level, visible cells will generate edges only shared with other visible |
| 292 | // neighboring leaf cells (by definition, such cell is necessarily a cell of same level). |
| 293 | // Current visible cell will generate an edge if: |
| 294 | // - no other cell sharing this edge is visible (we have a "corner" edge), |
| 295 | // - only the "diagonal" cell sharing the edge is visible (the edge represents the |
| 296 | // intersection between the two cells), |
| 297 | // - only 2 neighbouring cells sharing are visible (we have 3 cells sharing the edge, |
| 298 | // forming a 90 degrees angle). |
| 299 | bool noneVisible = !neighborVisible(neighborIds[0]) && !neighborVisible(neighborIds[1]) && |
| 300 | !neighborVisible(neighborIds[2]); |
| 301 | bool onlyDiag = !neighborVisible(neighborIds[0]) && neighborVisibleAndLeaf(neighborIds[1]) && |
| 302 | !neighborVisible(neighborIds[2]); |
| 303 | bool onlyTwo = (!neighborVisible(neighborIds[0]) && neighborVisibleAndLeaf(neighborIds[1]) && |
| 304 | neighborVisibleAndLeaf(neighborIds[2])) || |
| 305 | (neighborVisibleAndLeaf(neighborIds[0]) && !neighborVisible(neighborIds[1]) && |
| 306 | neighborVisibleAndLeaf(neighborIds[2])) || |
| 307 | (neighborVisibleAndLeaf(neighborIds[0]) && neighborVisibleAndLeaf(neighborIds[1]) && |
| 308 | !neighborVisible(neighborIds[2])); |
| 309 | bool visibleShouldAdd = !cursor->IsMasked() && (noneVisible || onlyDiag || onlyTwo); |
| 310 | |
| 311 | // For a given level, masked cells will generate edges only shared with other visible |
| 312 | // neighboring cells of inferior level (by definition, such cell is necessarily a leaf). |
| 313 | // Current masked cell will generate an edge if: |
| 314 | // - only one of the neighboring cells sharing the edge is visible (we have a "corner edge"), |
| 315 | // - the 2 neighboring cells sharing the edge except the "diagonal" are visible (the edge |
| 316 | // represents the intersection between the 2 neighboring cells), |
| 317 | // - all neighboring cells sharing the edge are visible (we have 3 cells sharing the edge, |
| 318 | // forming a 90 degrees angle). |
| 319 | bool onlyOne = (neighborVisibleAndInf(neighborIds[0]) && !neighborVisible(neighborIds[1]) && |
| 320 | !neighborVisible(neighborIds[2])) || |
| 321 | (!neighborVisible(neighborIds[0]) && neighborVisibleAndInf(neighborIds[1]) && |
| 322 | !neighborVisible(neighborIds[2])) || |
| 323 | (!neighborVisible(neighborIds[0]) && !neighborVisible(neighborIds[1]) && |
| 324 | neighborVisibleAndInf(neighborIds[2])); |
| 325 | bool twoExceptDiag = neighborVisibleAndInf(neighborIds[0]) && !neighborVisible(neighborIds[1]) && |
| 326 | neighborVisibleAndInf(neighborIds[2]); |
| 327 | bool allVisible = neighborVisibleAndInf(neighborIds[0]) && |
| 328 | neighborVisibleAndInf(neighborIds[1]) && neighborVisibleAndInf(neighborIds[2]); |
| 329 | bool maskedShouldAdd = cursor->IsMasked() && (onlyOne || twoExceptDiag || allVisible); |
| 330 | |
| 331 | return visibleShouldAdd || maskedShouldAdd; |
| 332 | } |
| 333 | |
| 334 | //---------------------------------------------------------------------------------------------- |
no test coverage detected