VTK  9.3.20240918
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
17#ifndef vtkCellAttribute_h
18#define vtkCellAttribute_h
19
20#include "vtkCommonDataModelModule.h" // for export
21#include "vtkObject.h"
22#include "vtkScalarsToColors.h" // for colormap
23#include "vtkSmartPointer.h" // for maps
24#include "vtkStringToken.h" // for vtkStringToken::Hash
25
26#include <unordered_map>
27
28VTK_ABI_NAMESPACE_BEGIN
31class vtkCellGrid;
33
34class VTKCOMMONDATAMODEL_EXPORT vtkCellAttribute : public vtkObject
35{
36public:
38 using ArraysForCellType = std::unordered_map<vtkStringToken, vtkSmartPointer<vtkAbstractArray>>;
39
41 {
42 // The array-group name holding shared degree-of-freedom (DOF)
43 // data if the attribute is shared. This is invalid for
44 // discontinuous attributes
65 int Order;
71
73 bool operator!=(const CellTypeInfo& other) const;
74
76 CellTypeInfo() = default;
77 CellTypeInfo(const CellTypeInfo& other) = default;
78 CellTypeInfo& operator=(const CellTypeInfo& other) = default;
79 };
80
81 using Arrays = std::unordered_map<vtkStringToken, CellTypeInfo>;
82
85 void PrintSelf(ostream& os, vtkIndent indent) override;
86
88 virtual vtkStringToken GetName() const { return this->Name; }
89
96 vtkGetMacro(Id, int);
97 vtkSetMacro(Id, int);
98
123 virtual vtkStringToken GetSpace() const { return this->Space; }
124
131 virtual int GetNumberOfComponents() const { return this->NumberOfComponents; }
132
140 virtual bool Initialize(vtkStringToken name, vtkStringToken space, int numberOfComponents);
141
148
154
161 vtkStringToken cellType, vtkStringToken arrayRole) const;
162
172 virtual bool SetCellTypeInfo(vtkStringToken cellType, const CellTypeInfo& cellTypeInfo);
173
175 vtkScalarsToColors* GetColormap() const { return this->Colormap; }
177
195 virtual void ShallowCopy(vtkCellAttribute* other, bool copyArrays = true);
196 virtual void DeepCopy(vtkCellAttribute* other,
197 const std::map<vtkAbstractArray*, vtkAbstractArray*>& arrayRewrites = {});
198
209 static bool DecodeSpace(
210 const std::string& space, std::string& base, double& exp, int& halfspace, bool quiet = false);
211
213 static std::string EncodeSpace(const std::string& base, unsigned int, int halfspace = 0);
214
215protected:
216 vtkCellAttribute() = default;
217 ~vtkCellAttribute() override = default;
218
221 int NumberOfComponents = 1;
223 int Id = -1;
225
226private:
227 vtkCellAttribute(const vtkCellAttribute&) = delete;
228 void operator=(const vtkCellAttribute&) = delete;
229};
230
231VTK_ABI_NAMESPACE_END
232#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 DeepCopy(vtkCellAttribute *other, const std::map< vtkAbstractArray *, vtkAbstractArray * > &arrayRewrites={})
virtual CellTypeInfo GetCellTypeInfo(vtkStringToken cellType) const
Return the arrays required to evaluate this attribute on cells of the given type.
virtual int GetNumberOfComponents() const
Return the number of components this function provides at each point in space.
virtual bool Initialize(vtkStringToken name, vtkStringToken space, int numberOfComponents)
Initialize an attribute.
vtkStringToken Space
~vtkCellAttribute() override=default
vtkCellAttribute()=default
vtkStringToken Name
static vtkCellAttribute * New()
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 bool SetCellTypeInfo(vtkStringToken cellType, const CellTypeInfo &cellTypeInfo)
Set the arrays required to evaluate this attribute on cells of the given type.
static std::string EncodeSpace(const std::string &base, unsigned int, int halfspace=0)
Return a space string given a description of it via base, exp, and halfspace.
virtual vtkStringToken GetName() const
Return the (user-presentable) name of this attribute.
bool SetColormap(vtkScalarsToColors *colormap)
vtkScalarsToColors * GetColormap() const
Return a default colormap associated with the attribute.
vtkSmartPointer< vtkScalarsToColors > Colormap
vtkAbstractArray * GetArrayForCellTypeAndRole(vtkStringToken cellType, vtkStringToken arrayRole) const
Return an array for the given cell type and role.
std::unordered_map< vtkStringToken, vtkSmartPointer< vtkAbstractArray > > ArraysForCellType
A dictionary of arrays indexed by their roles in interpolation.
static bool DecodeSpace(const std::string &space, std::string &base, double &exp, int &halfspace, bool quiet=false)
Given a space string (e.g., ℝ³⁻ or ℚ¹), decode the base (e.g., ℝ resp.
virtual void ShallowCopy(vtkCellAttribute *other, bool copyArrays=true)
Copy data from an other attribute instance into this instance.
std::unordered_map< vtkStringToken, CellTypeInfo > Arrays
Visualization data composed of cells of arbitrary type.
Definition vtkCellGrid.h:46
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
Superclass for mapping scalar values to colors.
Hold a reference to a vtkObjectBase instance.
Represent a string by its integer hash.
std::uint32_t Hash
ArraysForCellType ArraysByRole
A dictionary of arrays indexed by their roles in interpolation.
int Order
The interpolation order of the attribute on cells of the matching type.
vtkStringToken Basis
The interpolation scheme of the attribute on cells of the matching type.
bool operator!=(const CellTypeInfo &other) const
Comparator used to test inequality.
CellTypeInfo()=default
Explicitly include assignment and copy-construction.
vtkStringToken FunctionSpace
The function space used to interpolate values of the attribute on cells of the matching type.
CellTypeInfo(const CellTypeInfo &other)=default
CellTypeInfo & operator=(const CellTypeInfo &other)=default