VTK  9.7.20261205
vtkHyperTreeGridToBricksHelper.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef vtkHyperTreeGridToBricksHelper_h
5#define vtkHyperTreeGridToBricksHelper_h
6
8#include "vtkObject.h"
9#include <vector>
10
11#include "vtkSMPThreadLocal.h"
12
13VTK_ABI_NAMESPACE_BEGIN
14
17class vtkDataArray;
18
27{
28public:
31 void PrintSelf(ostream& os, vtkIndent indent) override;
32
34 vtkHyperTreeGrid* GetHyperTreeGrid() const { return this->HyperTreeGrid; }
35
36protected:
38 ~vtkHyperTreeGridToBricksHelper() override = default;
39
40 // vtkAMRToBricksHelper interface
41 void CollectInput() override;
42 void BuildBricksFromInput() override;
43 const char* GetInputTypeName() const override { return "HTG"; }
44
45private:
47 void operator=(const vtkHyperTreeGridToBricksHelper&) = delete;
48
49 // Cell collected during the octree traversal. Bounds are float (they are
50 // stored as float in the GPU brick struct anyway); interface data lives in
51 // a separate parallel array to keep this record small for large HTGs.
52 struct CollectedCell
53 {
54 float Bounds[6]; // World-space bounds
55 unsigned int Level;
56 float Scalar;
57 };
58
59 // Per-thread cell buffer (parallel traversal).
60 struct ThreadLocalCells
61 {
62 std::vector<CollectedCell> Cells;
63 std::vector<float> Interface; // 6 floats per cell, only when emitting interface data
64 unsigned int MaxLevel = 0;
65 };
66
67 // Per-thread k-d tree output.
68 struct ThreadLocalBricks
69 {
70 std::vector<vtkExaBrick> Bricks;
71 std::vector<float> Scalars;
72 std::vector<float> InterfaceData;
73 // for ABR construction
74 std::vector<float> BrickScalarMin;
75 std::vector<float> BrickScalarMax;
76
77 std::vector<char> OccupancyBuffer;
78 unsigned int MaxLevel = 0;
79 };
80
82
85 void CollectCells(std::vector<CollectedCell>& cells);
86 void CollectCellsRecursive(vtkHyperTreeGridNonOrientedGeometryCursor* cursor,
87 vtkDataArray* scalars, vtkDataArray* interfaceNormals, vtkDataArray* interfaceIntercepts,
88 std::vector<CollectedCell>& cells, std::vector<float>& interface, unsigned int& maxLevel);
90
92 // k-d tree brick building, paper ยง3.1.2 (see base class).
93 void BuildBricksKDTree(
94 std::vector<CollectedCell>& cells, size_t start, size_t end, ThreadLocalBricks& tls);
95 bool TryCreateBrick(const std::vector<CollectedCell>& cells, size_t start, size_t end,
96 const double boxMin[3], const double boxMax[3], ThreadLocalBricks& tls);
98
99 vtkHyperTreeGrid* HyperTreeGrid;
100 std::vector<CollectedCell> Cells;
101 std::vector<float> CollectedInterface; // 6 floats per cell, only when EmitInterfaceData
102 bool EmitInterfaceData = false;
103
104 // Maximum number of same-level cells processed per parallel k-d tree chunk.
105 static constexpr size_t MAX_CELLS_PER_KD_CHUNK = 500000;
106};
107
108VTK_ABI_NAMESPACE_END
109
110#endif
HTG front-end of vtkAMRToBricksHelper (Wald et al.
virtual void SetHyperTreeGrid(vtkHyperTreeGrid *htg)
~vtkHyperTreeGridToBricksHelper() override=default
void CollectInput() override
input-specific: fill BricksData + BrickScalarMin/Max + MaxLevel.
const char * GetInputTypeName() const override
static vtkHyperTreeGridToBricksHelper * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void BuildBricksFromInput() override
input-specific; default no-op (AMR patches are already bricks).
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
a simple class to control print indentation
Definition vtkIndent.h:108
#define vtkDataArray