25 #ifndef vtkStreamingPriorityQueue_h 26 #define vtkStreamingPriorityQueue_h 27 #ifndef VTK_WRAPPING_CXX 40 double vtkComputeScreenCoverage(
const double planes[24],
const double bounds[6],
double& distance,
41 double& centeredness,
double& itemCoverage)
52 double screen_bounds[4];
55 center[0] = (bounds[0] + bounds[1]) / 2.0;
56 center[1] = (bounds[2] + bounds[3]) / 2.0;
57 center[2] = (bounds[4] + bounds[5]) / 2.0;
58 double radius = 0.5 * sqrt((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) +
59 (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) +
60 (bounds[5] - bounds[4]) * (bounds[5] - bounds[4]));
61 for (
int i = 0; i < 6; i++)
64 double d = planes[i * 4 + 0] * center[0] + planes[i * 4 + 1] * center[1] +
65 planes[i * 4 + 2] * center[2] + planes[i * 4 + 3];
78 screen_bounds[i] = d - radius;
91 double full_w = screen_bounds[0] + screen_bounds[1] + 2.0 * radius;
92 double full_h = screen_bounds[2] + screen_bounds[3] + 2.0 * radius;
98 (screen_bounds[0] + radius) * (screen_bounds[1] + radius) / (full_w * full_w / 4.0);
100 (screen_bounds[2] + radius) * (screen_bounds[3] + radius) / (full_h * full_h / 4.0);
104 if (measure_w < 0.01)
108 if (measure_h < 0.01)
112 centeredness = measure_w * measure_h;
114 double w = 2 * radius;
115 double h = 2 * radius;
116 if (screen_bounds[0] < 0.0)
118 w += screen_bounds[0];
120 if (screen_bounds[1] < 0.0)
122 w += screen_bounds[1];
124 if (screen_bounds[2] < 0.0)
126 h += screen_bounds[2];
128 if (screen_bounds[3] < 0.0)
130 h += screen_bounds[3];
132 itemCoverage = h * w / (4 * radius * radius);
141 double part_w = full_w;
142 if (screen_bounds[0] > 0.0)
144 part_w -= screen_bounds[0];
146 if (screen_bounds[1] > 0.0)
148 part_w -= screen_bounds[1];
152 double part_h = full_h;
153 if (screen_bounds[2] > 0.0)
155 part_h -= screen_bounds[2];
157 if (screen_bounds[3] > 0.0)
159 part_h -= screen_bounds[3];
163 if ((full_w * full_h) != 0.0)
165 return (part_w * part_h) / (full_w * full_h);
211 template <
typename Comparator = vtkStreamingPriorityQueueItemComparator>
213 :
public std::priority_queue<vtkStreamingPriorityQueueItem,
214 std::vector<vtkStreamingPriorityQueueItem>, Comparator>
223 bool clamp_bounds_initialized =
229 std::swap(current_queue, *
this);
231 for (; !current_queue.empty(); current_queue.pop())
239 double block_bounds[6];
242 if (clamp_bounds_initialized)
244 if (!clampBox.
ContainsPoint(block_bounds[0], block_bounds[2], block_bounds[4]) &&
245 !clampBox.
ContainsPoint(block_bounds[1], block_bounds[3], block_bounds[5]))
253 double distance, centeredness, itemCoverage;
255 vtkComputeScreenCoverage(view_planes, block_bounds, distance, centeredness, itemCoverage);
265 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])