File: vtkCellGridRangeQuery.h

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 205,984 kB
  • sloc: cpp: 2,336,570; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 181; javascript: 165; objc: 153; tcl: 59
file content (123 lines) | stat: -rw-r--r-- 4,580 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkCellGridRangeQuery
 * @brief   Compute the range of a component of some vtkCellAttribute.
 *
 * If \a FiniteRange is true, then the range will omit any NaN or ±Inf
 * values present in the data. Otherwise (the default), the range may
 * contain these exceptional values.
 *
 * If \a Component is
 * + -2 (the default), the range of L₂-norms is computed.
 * + -1, the range of L₁-norms is computed.
 * + out of bounds, then an invalid range will be returned ([1, 0]).
 *
 * Note that this query is intended to be run by vtkCellGrid::GetRange()
 * since the cell-grid holds a cache of ranges. You may run it outside
 * of this method, but that may cause unnecessary re-computation of ranges.
 */

#ifndef vtkCellGridRangeQuery_h
#define vtkCellGridRangeQuery_h

#include "vtkCellAttribute.h" // For Attribute ivar.
#include "vtkCellGridQuery.h"

#include <array>  // For Ranges ivar.
#include <vector> // For Ranges ivar.

VTK_ABI_NAMESPACE_BEGIN

class VTKCOMMONDATAMODEL_EXPORT vtkCellGridRangeQuery : public vtkCellGridQuery
{
public:
  static vtkCellGridRangeQuery* New();
  vtkTypeMacro(vtkCellGridRangeQuery, vtkCellGridQuery);
  void PrintSelf(ostream& os, vtkIndent indent) override;

  /// Set/get the component whose range should be computed.
  ///
  /// This must be modified before the query is evaluated.
  vtkSetMacro(Component, int);
  vtkGetMacro(Component, int);

  /// Set/get whether component whose range should be computed.
  ///
  /// This must be modified before the query is evaluated.
  vtkSetMacro(FiniteRange, vtkTypeBool);
  vtkGetMacro(FiniteRange, vtkTypeBool);

  /// Set/get the cell-grid that holds the cell-attribute's arrays.
  ///
  /// This must be set before the query is evaluated.
  virtual void SetCellGrid(vtkCellGrid* grid);
  vtkGetObjectMacro(CellGrid, vtkCellGrid);

  /// Set/get the cell-attribute whose range should be computed.
  ///
  /// This must be modified before the query is evaluated.
  vtkSetObjectMacro(CellAttribute, vtkCellAttribute);
  vtkGetObjectMacro(CellAttribute, vtkCellAttribute);

  /// Invoked during evaluation before any cell-grid responders are run.
  bool Initialize() override;

  /// Invoked during evaluation after all cell-grid responders are run.
  bool Finalize() override;

  /// Return the computed range (after the query is evaluated).
  void GetRange(int component, double* range) VTK_SIZEHINT(2);
  const std::array<double, 2>& GetRange(int component) const;
  void GetRange(double* range) VTK_SIZEHINT(2) { this->GetRange(this->Component, range); }
  const std::array<double, 2>& GetRange() const { return this->GetRange(this->Component); }

  /// Used by query-responders to update the range during evaluation.
  ///
  /// Calling \a AddRange() with an invalid range has no effect.
  void AddRange(const std::array<double, 2>& other);

  /// This is an additional call that responders can use to provide range
  /// for components not currently queried.
  void AddRange(int component, const std::array<double, 2>& other);

  /// Store the finite/entire range for a single component of a cell-attribute.
  ///
  /// Each vtkCellGrid instance holds a map of these structures to accelerate
  /// range lookups and passes in the address of this map to us before running
  /// the query. This way the object holding the cell-attributes holds their
  /// cached ranges.
  ///
  /// The vtkCellAttribute itself cannot hold its cached component-ranges because
  /// it may be referenced by multiple vtkCellGrid instances.
  struct ComponentRange
  {
    /// When was the finite range last computed?
    vtkTimeStamp FiniteRangeTime;
    /// What is the finite-valued range?
    std::array<double, 2> FiniteRange;

    /// When was the entire range last computed?
    vtkTimeStamp EntireRangeTime;
    /// What is the true range (including possible NaN or Inf values)?
    std::array<double, 2> EntireRange;
  };
  using CacheMap = std::map<vtkCellAttribute*, std::vector<ComponentRange>>;

protected:
  vtkCellGridRangeQuery() = default;
  ~vtkCellGridRangeQuery() override;

  int Component{ -2 };
  vtkTypeBool FiniteRange{ false };
  vtkCellGrid* CellGrid{ nullptr };
  vtkCellAttribute* CellAttribute{ nullptr };
  std::vector<std::array<double, 2>> Ranges;

private:
  vtkCellGridRangeQuery(const vtkCellGridRangeQuery&) = delete;
  void operator=(const vtkCellGridRangeQuery&) = delete;
};

VTK_ABI_NAMESPACE_END
#endif // vtkCellGridRangeQuery_h