VTK  9.3.0
vtkCellAttribute.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
14 #ifndef vtkCellAttribute_h
15 #define vtkCellAttribute_h
16 
17 #include "vtkCommonDataModelModule.h" // for export
18 #include "vtkObject.h"
19 #include "vtkScalarsToColors.h" // for colormap
20 #include "vtkSmartPointer.h" // for maps
21 #include "vtkStringToken.h" // for vtkStringToken::Hash
22 
23 #include <unordered_map>
24 
25 VTK_ABI_NAMESPACE_BEGIN
26 class vtkAbstractArray;
27 class vtkCellAttribute;
28 class vtkCellGrid;
30 
31 class VTKCOMMONDATAMODEL_EXPORT vtkCellAttribute : public vtkObject
32 {
33 public:
34  using ArraysForCellType = std::unordered_map<vtkStringToken, vtkSmartPointer<vtkAbstractArray>>;
35  using Arrays = std::unordered_map<vtkStringToken, ArraysForCellType>;
36 
37  vtkTypeMacro(vtkCellAttribute, vtkObject);
38  static vtkCellAttribute* New();
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
42  virtual vtkStringToken GetName() const { return this->Name; }
43 
50  vtkGetMacro(Id, int);
51  vtkSetMacro(Id, int);
52 
72  virtual vtkStringToken GetAttributeType() const { return this->AttributeType; }
73 
95  virtual vtkStringToken GetSpace() const { return this->Space; }
96 
103  virtual int GetNumberOfComponents() const { return this->NumberOfComponents; }
104 
112  virtual bool Initialize(vtkStringToken name, vtkStringToken attributeType, vtkStringToken space,
113  int numberOfComponents);
114 
120  virtual vtkStringToken::Hash GetHash() const;
121 
127 
137  virtual bool SetArraysForCellType(vtkStringToken cellType, const ArraysForCellType& arrays);
138 
139  vtkScalarsToColors* GetColormap() const { return this->Colormap; }
141 
157  virtual void ShallowCopy(vtkCellAttribute* other);
158  virtual void DeepCopy(vtkCellAttribute* other,
159  const std::map<vtkAbstractArray*, vtkAbstractArray*>& arrayRewrites = {});
160 
161 protected:
162  vtkCellAttribute() = default;
163  ~vtkCellAttribute() override = default;
164 
168  int NumberOfComponents = 1;
170  int Id = -1;
172 
173 private:
174  vtkCellAttribute(const vtkCellAttribute&) = delete;
175  void operator=(const vtkCellAttribute&) = delete;
176 };
177 
178 VTK_ABI_NAMESPACE_END
179 #endif
Abstract superclass for all arrays.
A function defined over the physical domain of a vtkCellGrid.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void ShallowCopy(vtkCellAttribute *other)
Copy data from an other attribute instance into this instance.
vtkStringToken AttributeType
virtual void DeepCopy(vtkCellAttribute *other, const std::map< vtkAbstractArray *, vtkAbstractArray * > &arrayRewrites={})
virtual vtkStringToken GetAttributeType() const
Return a (user-presentable) type for this attribute.
virtual int GetNumberOfComponents() const
Return the number of components this function provides at each point in space.
std::unordered_map< vtkStringToken, ArraysForCellType > Arrays
vtkStringToken Space
~vtkCellAttribute() override=default
vtkCellAttribute()=default
vtkStringToken Name
virtual vtkStringToken GetSpace() const
Return a token identifying the space containing all field values.
virtual vtkStringToken::Hash GetHash() const
Hash this attribute so it can be inserted into unordered containers.
virtual vtkStringToken GetName() const
Return the (user-presentable) name of this attribute.
virtual bool SetArraysForCellType(vtkStringToken cellType, const ArraysForCellType &arrays)
Set the arrays required to evaluate this attribute on cells of the given type.
virtual ArraysForCellType GetArraysForCellType(vtkStringToken cellType) const
Return the arrays required to evaluate this attribute on cells of the given type.
vtkScalarsToColors * GetColormap() const
bool SetColormap(vtkScalarsToColors *colormap)
virtual bool Initialize(vtkStringToken name, vtkStringToken attributeType, vtkStringToken space, int numberOfComponents)
Initialize an attribute.
static vtkCellAttribute * New()
vtkSmartPointer< vtkScalarsToColors > Colormap
std::unordered_map< vtkStringToken, vtkSmartPointer< vtkAbstractArray > > ArraysForCellType
Visualization data composed of cells of arbitrary type.
Definition: vtkCellGrid.h:42
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition: vtkIndent.h:29
abstract base class for most VTK objects
Definition: vtkObject.h:52
Superclass for mapping scalar values to colors.
Represent a string by its integer hash.
std::uint32_t Hash
@ name
Definition: vtkX3D.h:219