File: vtkCompositeDataDisplayAttributes.h

package info (click to toggle)
paraview 5.11.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 497,236 kB
  • sloc: cpp: 3,171,290; ansic: 1,315,072; python: 134,290; xml: 103,324; sql: 65,887; sh: 5,286; javascript: 4,901; yacc: 4,383; java: 3,977; perl: 2,363; lex: 1,909; f90: 1,255; objc: 143; makefile: 119; tcl: 59; pascal: 50; fortran: 29
file content (252 lines) | stat: -rw-r--r-- 7,694 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkCompositeDataDisplayAttributes.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
/**
 * @class   vtkCompositeDataDisplayAttributes
 * @brief   Rendering attributes for a multi-block dataset.
 *
 * The vtkCompositeDataDisplayAttributes class stores display attributes
 * for individual blocks in a multi-block dataset. It uses the actual data
 * block's pointer as a key (vtkDataObject*).
 *
 * @warning It is considered unsafe to dereference key pointers at any time,
 * they should only serve as keys to access the internal map.
 */

#ifndef vtkCompositeDataDisplayAttributes_h
#define vtkCompositeDataDisplayAttributes_h
#include <functional>    // for std::function
#include <unordered_map> // for std::unordered_map

#include "vtkColor.h" // for vtkColor3d
#include "vtkObject.h"
#include "vtkRenderingCoreModule.h" // for export macro

VTK_ABI_NAMESPACE_BEGIN
class vtkBoundingBox;
class vtkDataObject;

class VTKRENDERINGCORE_EXPORT vtkCompositeDataDisplayAttributes : public vtkObject
{
public:
  static vtkCompositeDataDisplayAttributes* New();
  vtkTypeMacro(vtkCompositeDataDisplayAttributes, vtkObject);
  void PrintSelf(ostream& os, vtkIndent indent) override;

  /**
   * Returns true if any block has any block visibility is set.
   */
  bool HasBlockVisibilities() const;

  ///@{
  /**
   * Set/get the visibility for the block with \p data_object.
   */
  void SetBlockVisibility(vtkDataObject* data_object, bool visible);
  bool GetBlockVisibility(vtkDataObject* data_object) const;
  ///@}

  /**
   * Returns true if the block with the given data_object has a visibility
   * set.
   */
  bool HasBlockVisibility(vtkDataObject* data_object) const;

  /**
   * Removes the block visibility flag for the block with data_object.
   */
  void RemoveBlockVisibility(vtkDataObject* data_object);

  /**
   * Removes all block visibility flags. This effectively sets the visibility
   * for all blocks to true.
   */
  void RemoveBlockVisibilities();

  /**
   * Returns true if any block has any block pickability is set.
   */
  bool HasBlockPickabilities() const;

  ///@{
  /**
   * Set/get the pickability for the block with \p data_object.
   */
  void SetBlockPickability(vtkDataObject* data_object, bool visible);
  bool GetBlockPickability(vtkDataObject* data_object) const;
  ///@}

  /**
   * Returns true if the block with the given data_object has a pickability
   * set.
   */
  bool HasBlockPickability(vtkDataObject* data_object) const;

  /**
   * Removes the block pickability flag for the block with data_object.
   */
  void RemoveBlockPickability(vtkDataObject* data_object);

  /**
   * Removes all block pickability flags. This effectively sets the pickability
   * for all blocks to true.
   */
  void RemoveBlockPickabilities();

  ///@{
  /**
   * Set/get the color for the block with \p data_object.
   */
  void SetBlockColor(vtkDataObject* data_object, const double color[3]);
  void GetBlockColor(vtkDataObject* data_object, double color[3]) const;
  vtkColor3d GetBlockColor(vtkDataObject* data_object) const;
  ///@}

  /**
   * Returns true if any block has any block color is set.
   */
  bool HasBlockColors() const;

  /**
   * Returns true if the block with the given \p data_object has a color.
   */
  bool HasBlockColor(vtkDataObject* data_object) const;

  /**
   * Removes the block color for the block with \p data_object.
   */
  void RemoveBlockColor(vtkDataObject* data_object);

  /**
   * Removes all block colors.
   */
  void RemoveBlockColors();

  ///@{
  /**
   * Set/get the opacity for the block with data_object.
   */
  void SetBlockOpacity(vtkDataObject* data_object, double opacity);
  double GetBlockOpacity(vtkDataObject* data_object) const;
  ///@}

  /**
   * Returns true if any block has an opacity set.
   */
  bool HasBlockOpacities() const;

  /**
   * Returns true if the block with data_object has an opacity set.
   */
  bool HasBlockOpacity(vtkDataObject* data_object) const;

  /**
   * Removes the set opacity for the block with data_object.
   */
  void RemoveBlockOpacity(vtkDataObject* data_object);

  /**
   * Removes all block opacities.
   */
  void RemoveBlockOpacities();

  ///@{
  /**
   * Set/get the material for the block with data_object.
   * Only rendering backends that support advanced materials need to respect these.
   */
  void SetBlockMaterial(vtkDataObject* data_object, const std::string& material);
  const std::string& GetBlockMaterial(vtkDataObject* data_object) const;
  ///@}

  /**
   * Returns true if any block has an material set.
   */
  bool HasBlockMaterials() const;

  /**
   * Returns true if the block with data_object has an material set.
   */
  bool HasBlockMaterial(vtkDataObject* data_object) const;

  /**
   * Removes the set material for the block with data_object.
   */
  void RemoveBlockMaterial(vtkDataObject* data_object);

  /**
   * Removes all block materialss.
   */
  void RemoveBlockMaterials();

  /**
   * If the input \a dobj is a vtkCompositeDataSet, we will loop over the
   * hierarchy recursively starting from initial index 0 and use only visible
   * blocks, which is specified in the vtkCompositeDataDisplayAttributes \a cda,
   * to compute the \a bounds.
   */
  static void ComputeVisibleBounds(
    vtkCompositeDataDisplayAttributes* cda, vtkDataObject* dobj, double bounds[6]);

  /**
   * Get the DataObject corresponding to the node with index flat_index under
   * parent_obj. Traverses the entire hierarchy recursively.
   */
  static vtkDataObject* DataObjectFromIndex(
    const unsigned int flat_index, vtkDataObject* parent_obj, unsigned int current_flat_index = 0);

  void VisitVisibilities(std::function<bool(vtkDataObject*, bool)> visitor)
  {
    for (auto entry : this->BlockVisibilities)
    {
      if (visitor(entry.first, entry.second))
      {
        break;
      }
    }
  }

protected:
  vtkCompositeDataDisplayAttributes();
  ~vtkCompositeDataDisplayAttributes() override;

private:
  vtkCompositeDataDisplayAttributes(const vtkCompositeDataDisplayAttributes&) = delete;
  void operator=(const vtkCompositeDataDisplayAttributes&) = delete;

  /**
   * If the input data \a dobj is a vtkCompositeDataSet, we will
   * loop over the hierarchy recursively starting from the initial block
   * and use only visible blocks, which is specified in the
   * vtkCompositeDataDisplayAttributes \a cda, to compute bounds and the
   * result bounds will be set to the vtkBoundingBox \a bbox. The \a parentVisible
   * is the visibility for the starting block.
   */
  static void ComputeVisibleBoundsInternal(vtkCompositeDataDisplayAttributes* cda,
    vtkDataObject* dobj, vtkBoundingBox* bbox, bool parentVisible = true);

  using BoolMap = std::unordered_map<vtkDataObject*, bool>;
  using DoubleMap = std::unordered_map<vtkDataObject*, double>;
  using ColorMap = std::unordered_map<vtkDataObject*, vtkColor3d>;
  using StringMap = std::unordered_map<vtkDataObject*, std::string>;

  BoolMap BlockVisibilities;
  ColorMap BlockColors;
  DoubleMap BlockOpacities;
  StringMap BlockMaterials;
  BoolMap BlockPickabilities;
};

VTK_ABI_NAMESPACE_END
#endif // vtkCompositeDataDisplayAttributes_h