VTK  9.7.1
vtkDataSetAttributes.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
49 #ifndef vtkDataSetAttributes_h
50 #define vtkDataSetAttributes_h
51 
52 #include "vtkCommonDataModelModule.h" // For export macro
53 #include "vtkDataSetAttributesFieldList.h" // for vtkDataSetAttributesFieldList
54 #include "vtkFieldData.h"
55 #include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
56 
57 VTK_ABI_NAMESPACE_BEGIN
58 class vtkLookupTable;
59 
60 class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALMANUAL vtkDataSetAttributes : public vtkFieldData
61 {
62 public:
66  static vtkDataSetAttributes* New();
68 
70  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
76  void Initialize() override;
77 
82  virtual void Update() {}
83 
84  // -- shallow and deep copy -----------------------------------------------
85 
91  void DeepCopy(vtkFieldData* pd) override;
92 
97  void ShallowCopy(vtkFieldData* pd) override;
98 
99  // -- attribute types -----------------------------------------------------
100 
101  // Always keep NUM_ATTRIBUTES as the last entry
103  {
104  SCALARS = 0,
105  VECTORS = 1,
106  NORMALS = 2,
107  TCOORDS = 3,
108  TENSORS = 4,
109  GLOBALIDS = 5,
110  PEDIGREEIDS = 6,
111  EDGEFLAG = 7,
112  TANGENTS = 8,
113  RATIONALWEIGHTS = 9,
114  HIGHERORDERDEGREES = 10,
115  PROCESSIDS = 11,
116  NUM_ATTRIBUTES = 12
117  };
118 
120  {
123  NOLIMIT
124  };
125 
126  // ----------- ghost points and ghost cells -------------------------------------------
127  // The following bit fields are consistent with VisIt ghost zones specification
128  // For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
129 
131  {
132  DUPLICATECELL = 1, // The cell is present on multiple partitions/ranks.
133  HIGHCONNECTIVITYCELL = 2, // The cell has more neighbors than in a regular mesh.
134  LOWCONNECTIVITYCELL = 4, // The cell has less neighbors than in a regular mesh.
135  REFINEDCELL = 8, // Other cells are present that refines it.
136  EXTERIORCELL = 16, // The cell is on the exterior of the data set.
137  HIDDENCELL = 32 // The cell is only present for connectivity; ignore data values.
138  };
139 
141  {
142  DUPLICATEPOINT = 1, // The point is present in multiple partitions/ranks.
143  HIDDENPOINT = 2 // The point is only present for connectivity; ignore data values.
144  };
145 
146  //-----------------------------------------------------------------------------------
147 
149 
152  int SetScalars(vtkDataArray* da);
153  int SetActiveScalars(const char* name);
154  vtkDataArray* GetScalars();
156 
158 
161  int SetVectors(vtkDataArray* da);
162  int SetActiveVectors(const char* name);
163  vtkDataArray* GetVectors();
165 
167 
170  int SetNormals(vtkDataArray* da);
171  int SetActiveNormals(const char* name);
172  vtkDataArray* GetNormals();
174 
176 
179  int SetTangents(vtkDataArray* da);
180  int SetActiveTangents(const char* name);
181  vtkDataArray* GetTangents();
183 
185 
188  int SetTCoords(vtkDataArray* da);
189  int SetActiveTCoords(const char* name);
190  vtkDataArray* GetTCoords();
192 
194 
197  int SetTensors(vtkDataArray* da);
198  int SetActiveTensors(const char* name);
199  vtkDataArray* GetTensors();
201 
203 
206  int SetGlobalIds(vtkDataArray* da);
207  int SetActiveGlobalIds(const char* name);
208  vtkDataArray* GetGlobalIds();
210 
212 
215  int SetPedigreeIds(vtkAbstractArray* da);
216  int SetActivePedigreeIds(const char* name);
217  vtkAbstractArray* GetPedigreeIds();
219 
221 
224  int SetRationalWeights(vtkDataArray* da);
225  int SetActiveRationalWeights(const char* name);
226  vtkDataArray* GetRationalWeights();
228 
230 
233  int SetHigherOrderDegrees(vtkDataArray* da);
234  int SetActiveHigherOrderDegrees(const char* name);
235  vtkDataArray* GetHigherOrderDegrees();
237 
239 
242  int SetProcessIds(vtkDataArray* da);
243  int SetActiveProcessIds(const char* name);
244  vtkDataArray* GetProcessIds();
246 
248 
254  vtkDataArray* GetScalars(const char* name);
255  vtkDataArray* GetVectors(const char* name);
256  vtkDataArray* GetNormals(const char* name);
257  vtkDataArray* GetTangents(const char* name);
258  vtkDataArray* GetTCoords(const char* name);
259  vtkDataArray* GetTensors(const char* name);
260  vtkDataArray* GetGlobalIds(const char* name);
261  vtkAbstractArray* GetPedigreeIds(const char* name);
262  vtkDataArray* GetRationalWeights(const char* name);
263  vtkDataArray* GetHigherOrderDegrees(const char* name);
264  vtkDataArray* GetProcessIds(const char* name);
266 
285  int SetActiveAttribute(const char* name, int attributeType);
286 
292  int SetActiveAttribute(int index, int attributeType);
293 
299  void GetAttributeIndices(int* indexArray);
300 
307  int IsArrayAnAttribute(int idx);
308 
331  int SetAttribute(vtkAbstractArray* aa, int attributeType);
332 
339  vtkDataArray* GetAttribute(int attributeType);
340 
348  vtkAbstractArray* GetAbstractAttribute(int attributeType);
349 
351 
356  void RemoveArray(int index) override;
358 
360 
364  static const char* GetAttributeTypeAsString(int attributeType);
365  static const char* GetLongAttributeTypeAsString(int attributeType);
367 
368  // -- attribute copy properties ------------------------------------------
369 
370  // NOLINTNEXTLINE(readability-enum-initial-value)
372  {
373  COPYTUPLE = 0,
374  INTERPOLATE = 1,
375  PASSDATA = 2,
376  ALLCOPY // all of the above
377  };
378 
400  void SetCopyAttribute(int index, int value, int ctype = ALLCOPY);
401 
406  int GetCopyAttribute(int index, int ctype);
407 
409  void SetCopyScalars(vtkTypeBool i, int ctype = ALLCOPY);
410  vtkTypeBool GetCopyScalars(int ctype = ALLCOPY);
411  vtkBooleanMacro(CopyScalars, vtkTypeBool);
412 
414  void SetCopyVectors(vtkTypeBool i, int ctype = ALLCOPY);
415  vtkTypeBool GetCopyVectors(int ctype = ALLCOPY);
416  vtkBooleanMacro(CopyVectors, vtkTypeBool);
417 
419  void SetCopyNormals(vtkTypeBool i, int ctype = ALLCOPY);
420  vtkTypeBool GetCopyNormals(int ctype = ALLCOPY);
421  vtkBooleanMacro(CopyNormals, vtkTypeBool);
422 
424  void SetCopyTangents(vtkTypeBool i, int ctype = ALLCOPY);
425  vtkTypeBool GetCopyTangents(int ctype = ALLCOPY);
426  vtkBooleanMacro(CopyTangents, vtkTypeBool);
427 
429  void SetCopyTCoords(vtkTypeBool i, int ctype = ALLCOPY);
430  vtkTypeBool GetCopyTCoords(int ctype = ALLCOPY);
431  vtkBooleanMacro(CopyTCoords, vtkTypeBool);
432 
434  void SetCopyTensors(vtkTypeBool i, int ctype = ALLCOPY);
435  vtkTypeBool GetCopyTensors(int ctype = ALLCOPY);
436  vtkBooleanMacro(CopyTensors, vtkTypeBool);
437 
439  void SetCopyGlobalIds(vtkTypeBool i, int ctype = ALLCOPY);
440  vtkTypeBool GetCopyGlobalIds(int ctype = ALLCOPY);
441  vtkBooleanMacro(CopyGlobalIds, vtkTypeBool);
442 
444  void SetCopyPedigreeIds(vtkTypeBool i, int ctype = ALLCOPY);
445  vtkTypeBool GetCopyPedigreeIds(int ctype = ALLCOPY);
446  vtkBooleanMacro(CopyPedigreeIds, vtkTypeBool);
447 
449  void SetCopyRationalWeights(vtkTypeBool i, int ctype = ALLCOPY);
450  vtkTypeBool GetCopyRationalWeights(int ctype = ALLCOPY);
451  vtkBooleanMacro(CopyRationalWeights, vtkTypeBool);
452 
454  void SetCopyHigherOrderDegrees(vtkTypeBool i, int ctype = ALLCOPY);
455  vtkTypeBool GetCopyHigherOrderDegrees(int ctype = ALLCOPY);
456  vtkBooleanMacro(CopyHigherOrderDegrees, vtkTypeBool);
457 
459  void SetCopyProcessIds(vtkTypeBool i, int ctype = ALLCOPY);
460  vtkTypeBool GetCopyProcessIds(int ctype = ALLCOPY);
461  vtkBooleanMacro(CopyProcessIds, vtkTypeBool);
462 
464  void CopyAllOn(int ctype = ALLCOPY) override;
465 
467  void CopyAllOff(int ctype = ALLCOPY) override;
468 
469  // -- passthrough operations ----------------------------------------------
470 
480  void PassData(vtkFieldData* fd) override;
481 
482  // -- copytuple operations ------------------------------------------------
483 
485 
496  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze = 0, vtkIdType ext = 1000)
497  {
498  this->CopyAllocate(pd, sze, ext, 0);
499  }
500  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
502 
510  void SetupForCopy(vtkDataSetAttributes* pd);
511 
520  void CopyStructuredData(
521  vtkDataSetAttributes* inDsa, const int* inExt, const int* outExt, bool setSize = true);
522 
524 
537  void CopyData(vtkDataSetAttributes* fromPd, vtkIdType fromId, vtkIdType toId);
538  void CopyData(vtkDataSetAttributes* fromPd, vtkIdList* fromIds, vtkIdList* toIds);
539  void CopyData(vtkDataSetAttributes* fromPd, vtkIdList* fromIds, vtkIdType destStartId = 0);
541 
547  void CopyData(vtkDataSetAttributes* fromPd, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
548 
550 
556  void CopyTuple(
557  vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdType fromId, vtkIdType toId);
558  void CopyTuples(
559  vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdList* fromIds, vtkIdList* toIds);
560  void CopyTuples(vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdType dstStart,
561  vtkIdType n, vtkIdType srcStart);
563 
564  // -- interpolate operations ----------------------------------------------
565 
567 
576  {
577  this->InterpolateAllocate(pd, sze, ext, 0);
578  }
579  void InterpolateAllocate(
580  vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
582 
590  void InterpolatePoint(
591  vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdList* ids, double* weights);
592 
602  void InterpolateEdge(
603  vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdType p1, vtkIdType p2, double t);
604 
617  void InterpolateTime(
618  vtkDataSetAttributes* from1, vtkDataSetAttributes* from2, vtkIdType id, double t);
619 
621 
622  // field list copy operations ------------------------------------------
623 
628  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze = 0, vtkIdType ext = 1000);
629 
636  void CopyData(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* dsa, int idx,
637  vtkIdType fromId, vtkIdType toId);
638  void CopyData(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* dsa, int idx,
639  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
640 
647  void InterpolateAllocate(
648  vtkDataSetAttributes::FieldList& list, vtkIdType sze = 0, vtkIdType ext = 1000);
649 
656  void InterpolatePoint(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* fromPd,
657  int idx, vtkIdType toId, vtkIdList* ids, double* weights);
658 
659 protected:
661  ~vtkDataSetAttributes() override;
662 
663  void InternalCopyAllocate(vtkDataSetAttributes* pd, int ctype, vtkIdType sze = 0,
664  vtkIdType ext = 1000, int shallowCopyArrays = 0, bool createNewArrays = true);
665 
669  void InitializeFields() override;
670 
671  int AttributeIndices[NUM_ATTRIBUTES]; // index to attribute array in field data
672  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; // copy flag for attribute data
673 
674  friend struct ArrayList; // Friend to base class in vtkArrayListTemplate
677 
678  static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
679  static const int AttributeLimits[NUM_ATTRIBUTES];
680  static const char AttributeNames[NUM_ATTRIBUTES][19];
681  static const char LongAttributeNames[NUM_ATTRIBUTES][42];
682 
683 private:
684  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
685 
686  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
687 
689  void operator=(const vtkDataSetAttributes&) = delete;
690 
692 };
693 
694 VTK_ABI_NAMESPACE_END
695 #endif
Abstract superclass for all arrays.
helps manage arrays from multiple vtkDataSetAttributes.
void InterpolateAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
Initialize point interpolation method.
map scalar values into colors via a lookup table
virtual void PassData(vtkFieldData *fd)
Pass entire arrays of input data through to output.
static vtkFieldData * ExtendedNew()
virtual void CopyAllOn(int unused=0)
Turn on copying of all data.
int vtkIdType
Definition: vtkType.h:363
virtual void Update()
Attributes have a chance to bring themselves up to date; right now this is ignored.
virtual void CopyAllOff(int unused=0)
Turn off copying of all data.
int vtkTypeBool
Definition: vtkABI.h:64
VTKIOHDF_EXPORT bool GetAttribute(hid_t group, const char *attributeName, size_t numberOfElements, T *value)
Reads an attribute from the group passed to it.
static vtkFieldData * New()
#define VTK_MARSHALMANUAL
virtual void InitializeFields()
Release all data but do not delete object.
a simple class to control print indentation
Definition: vtkIndent.h:28
list of point or cell ids
Definition: vtkIdList.h:25
void CopyAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
Allocates point data for point-by-point (or cell-by-cell) copy operation.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
represent and manipulate attribute data in a dataset
virtual void DeepCopy(vtkFieldData *da)
Copy a field by creating new data arrays (i.e., duplicate storage).
virtual void Initialize()
Release all data but do not delete object.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void ShallowCopy(vtkFieldData *da)
Copy a field by reference counting the data arrays.
virtual void RemoveArray(const char *name)
Remove an array (with the given name) from the list of arrays.
vtkFieldData::BasicIterator RequiredArrays
Represents and manipulates a collection of data arrays.
Definition: vtkFieldData.h:51