13 #ifndef vtkStreamingPriorityQueue_h 14 #define vtkStreamingPriorityQueue_h 15 #ifndef VTK_WRAPPING_CXX 27 inline double vtkComputeScreenCoverage(
const double planes[24],
const double bounds[6],
28 double& distance,
double& centeredness,
double& itemCoverage)
39 double screen_bounds[4];
42 center[0] = (bounds[0] + bounds[1]) / 2.0;
43 center[1] = (bounds[2] + bounds[3]) / 2.0;
44 center[2] = (bounds[4] + bounds[5]) / 2.0;
46 sqrt((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) +
47 (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) +
48 (bounds[5] - bounds[4]) * (bounds[5] - bounds[4]));
49 for (
int i = 0; i < 6; i++)
52 double d = planes[i * 4 + 0] * center[0] + planes[i * 4 + 1] * center[1] +
53 planes[i * 4 + 2] * center[2] + planes[i * 4 + 3];
66 screen_bounds[i] = d - radius;
79 double full_w = screen_bounds[0] + screen_bounds[1] + 2.0 * radius;
80 double full_h = screen_bounds[2] + screen_bounds[3] + 2.0 * radius;
86 (screen_bounds[0] + radius) * (screen_bounds[1] + radius) / (full_w * full_w / 4.0);
88 (screen_bounds[2] + radius) * (screen_bounds[3] + radius) / (full_h * full_h / 4.0);
100 centeredness = measure_w * measure_h;
102 double w = 2 * radius;
103 double h = 2 * radius;
104 if (screen_bounds[0] < 0.0)
106 w += screen_bounds[0];
108 if (screen_bounds[1] < 0.0)
110 w += screen_bounds[1];
112 if (screen_bounds[2] < 0.0)
114 h += screen_bounds[2];
116 if (screen_bounds[3] < 0.0)
118 h += screen_bounds[3];
120 itemCoverage = h * w / (4 * radius * radius);
129 double part_w = full_w;
130 if (screen_bounds[0] > 0.0)
132 part_w -= screen_bounds[0];
134 if (screen_bounds[1] > 0.0)
136 part_w -= screen_bounds[1];
140 double part_h = full_h;
141 if (screen_bounds[2] > 0.0)
143 part_h -= screen_bounds[2];
145 if (screen_bounds[3] > 0.0)
147 part_h -= screen_bounds[3];
151 if ((full_w * full_h) != 0.0)
153 return (part_w * part_h) / (full_w * full_h);
199 template <
typename Comparator = vtkStreamingPriorityQueueItemComparator>
201 :
public std::priority_queue<vtkStreamingPriorityQueueItem,
202 std::vector<vtkStreamingPriorityQueueItem>, Comparator>
211 bool clamp_bounds_initialized =
217 std::swap(current_queue, *
this);
219 for (; !current_queue.empty(); current_queue.pop())
227 double block_bounds[6];
230 if (clamp_bounds_initialized)
232 if (!clampBox.
ContainsPoint(block_bounds[0], block_bounds[2], block_bounds[4]) &&
233 !clampBox.
ContainsPoint(block_bounds[1], block_bounds[3], block_bounds[5]))
241 double distance, centeredness, itemCoverage;
243 vtkComputeScreenCoverage(view_planes, block_bounds, distance, centeredness, itemCoverage);
253 item.
Priority = coverage * coverage * centeredness / (1 + refinement2 + distance);
void GetBounds(double bounds[6]) const
int ContainsPoint(double p[3]) const
void UpdatePriorities(const double view_planes[24], const double clamp_bounds[6])
Updates the priorities of items in the queue.
vtkStreamingPriorityQueueItem()
bool operator()(const vtkStreamingPriorityQueueItem &me, const vtkStreamingPriorityQueueItem &other) const
provides a datastructure for building priority queues.
static vtkTypeBool AreBoundsInitialized(double bounds[6])