File: vtkDataSetAttributesFieldList.h

package info (click to toggle)
vtk9 9.0.1%2Bdfsg1-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 133,688 kB
  • sloc: cpp: 1,568,287; ansic: 208,587; python: 87,847; xml: 8,022; java: 4,509; yacc: 4,027; sh: 2,515; perl: 2,183; lex: 1,766; objc: 143; makefile: 126; tcl: 59
file content (144 lines) | stat: -rw-r--r-- 5,733 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
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkDataSetAttributesFieldList.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 vtkDataSetAttributesFieldList
 * @brief helps manage arrays from multiple vtkDataSetAttributes.
 *
 * vtkDataSetAttributesFieldList, also called vtkDataSetAttributes::FieldList,
 * is used to help with filters when dealing with arrays from multiple
 * vtkDataSetAttributes instances, potentially from multiple inputs.
 *
 * Consider a filter that appends multiple inputs, e.g. vtkAppendPolyData.
 * Besides appending mesh elements, such a filter also needs to combine field
 * arrays (point, and cell data) from inputs to pass on to the output.
 * Now if all the inputs had exactly the same set of arrays, we're all set.
 * However, more often than not, the inputs will have different sets of arrays.
 * The filter will need to match up from various inputs to combine together,
 * potentially dropping arrays not in all inputs. Furthermore, it needs to
 * ensure arrays in the output are flagged as attributes consistently. All of
 * this can be done using vtkDataSetAttributesFieldList.
 *
 * @section Usage Usage
 *
 * Typical usage is as follows:
 * 1. call `IntersectFieldList` or `UnionFieldList` for all input vtkDataSetAttributes
 *   instances,
 * 2. allocate arrays for the output vtkDataSetAttributes by using `CopyAllocate`,
 * 3. call `CopyData` per input (preserving the input order used in step 1) to
 *    copy tuple(s) from input to the output.
 *
 * `vtkDataSetAttributes::InitializeFieldList` is provided for API compatibility
 * with previous implementation of this class and it not required to be called.
 * Simply calling `UnionFieldList` or `IntersectFieldList` for the first
 * vtkDataSetAttributes instance is sufficient.
 *
 * `CopyAllocate, `CopyData`, and `InterpolatePoint` methods on this class
 * are called by similarly named variants on vtkDataSetAttributes that take in a
 * FieldList instance as an argument. Hence, either forms may be used.
 *
 * Calls to `UnionFieldList` and `IntersectFieldList` cannot be mixed. Use
 * `Reset` or `InitializeFieldList` to change mode and start reinitialization.
 */

#ifndef vtkDataSetAttributesFieldList_h
#define vtkDataSetAttributesFieldList_h

#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkSmartPointer.h"          // for vtkSmartPointer
#include "vtkSystemIncludes.h"

#include <functional> // for std::function
#include <memory>     // for unique_ptr

class vtkAbstractArray;
class vtkDataSetAttributes;
class vtkIdList;

class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributesFieldList
{
public:
  /**
   * `number_of_inputs` parameter is not required and only provided for
   * backwards compatibility.
   */
  vtkDataSetAttributesFieldList(int number_of_inputs = 0);
  virtual ~vtkDataSetAttributesFieldList();
  void PrintSelf(ostream& os, vtkIndent indent);

  /**
   * Initializes the field list to empty.
   */
  void Reset();

  /**
   * Initialize the field list. This also adds the first input.
   * Calling this method is optional. The first call to `IntersectFieldList` or
   * `UnionFieldList` on a new instance or after calling `Reset()` will have the
   * same effect.
   */
  void InitializeFieldList(vtkDataSetAttributes* dsa);

  /**
   * Update the field list for an intersection of arrays registered so far and
   * those in `dsa`.
   */
  void IntersectFieldList(vtkDataSetAttributes* dsa);

  /**
   * Update the field list for an union of arrays registered so far and
   * those in `dsa`.
   */
  void UnionFieldList(vtkDataSetAttributes* dsa);

  //@{
  /**
   * These methods can called to generate and update the output
   * vtkDataSetAttributes. These match corresponding API on vtkDataSetAttributes
   * and can be called via the output vtkDataSetAttributes instance
   * instead as well.
   */
  void CopyAllocate(vtkDataSetAttributes* output, int ctype, vtkIdType sz, vtkIdType ext) const;
  void CopyData(int inputIndex, vtkDataSetAttributes* input, vtkIdType fromId,
    vtkDataSetAttributes* output, vtkIdType toId) const;
  void CopyData(int inputIdx, vtkDataSetAttributes* input, vtkIdType inputStart,
    vtkIdType numValues, vtkDataSetAttributes* output, vtkIdType outStart) const;
  void InterpolatePoint(int inputIdx, vtkDataSetAttributes* input, vtkIdList* inputIds,
    double* weights, vtkDataSetAttributes* output, vtkIdType toId) const;
  //@}

  /**
   * Use this method to provide a custom callback function to invoke for each
   * array in the input and corresponding array in the output.
   */
  void TransformData(int inputIndex, vtkDataSetAttributes* input, vtkDataSetAttributes* output,
    std::function<void(vtkAbstractArray*, vtkAbstractArray*)> op) const;

protected:
  /**
   * Called to create an output array for the given type.
   * Default implementation calls `vtkAbstractArray::CreateArray()`.
   */
  virtual vtkSmartPointer<vtkAbstractArray> CreateArray(int type) const;

private:
  class vtkInternals;
  std::unique_ptr<vtkInternals> Internals;

  vtkDataSetAttributesFieldList(const vtkDataSetAttributesFieldList&) = delete;
  void operator=(vtkDataSetAttributesFieldList&) = delete;
};

#endif
// VTK-HeaderTest-Exclude: vtkDataSetAttributesFieldList.h