VTK  9.3.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
45 #ifndef vtkDataSetAttributes_h
46 #define vtkDataSetAttributes_h
47 
48 #include "vtkCommonDataModelModule.h" // For export macro
49 #include "vtkDataSetAttributesFieldList.h" // for vtkDataSetAttributesFieldList
50 #include "vtkFieldData.h"
51 
52 VTK_ABI_NAMESPACE_BEGIN
53 class vtkLookupTable;
54 
55 class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributes : public vtkFieldData
56 {
57 public:
61  static vtkDataSetAttributes* New();
63 
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
71  void Initialize() override;
72 
77  virtual void Update() {}
78 
79  // -- shallow and deep copy -----------------------------------------------
80 
86  void DeepCopy(vtkFieldData* pd) override;
87 
92  void ShallowCopy(vtkFieldData* pd) override;
93 
94  // -- attribute types -----------------------------------------------------
95 
96  // Always keep NUM_ATTRIBUTES as the last entry
98  {
99  SCALARS = 0,
100  VECTORS = 1,
101  NORMALS = 2,
102  TCOORDS = 3,
103  TENSORS = 4,
104  GLOBALIDS = 5,
105  PEDIGREEIDS = 6,
106  EDGEFLAG = 7,
107  TANGENTS = 8,
108  RATIONALWEIGHTS = 9,
109  HIGHERORDERDEGREES = 10,
110  PROCESSIDS = 11,
111  NUM_ATTRIBUTES
112  };
113 
115  {
118  NOLIMIT
119  };
120 
121  // ----------- ghost points and ghost cells -------------------------------------------
122  // The following bit fields are consistent with VisIt ghost zones specification
123  // For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
124 
126  {
127  DUPLICATECELL = 1, // the cell is present on multiple processors
128  HIGHCONNECTIVITYCELL = 2, // the cell has more neighbors than in a regular mesh
129  LOWCONNECTIVITYCELL = 4, // the cell has less neighbors than in a regular mesh
130  REFINEDCELL = 8, // other cells are present that refines it.
131  EXTERIORCELL = 16, // the cell is on the exterior of the data set
132  HIDDENCELL =
133  32 // the cell is needed to maintain connectivity, but the data values should be ignored.
134  };
135 
137  {
138  DUPLICATEPOINT = 1, // the cell is present on multiple processors
139  HIDDENPOINT =
140  2 // the point is needed to maintain connectivity, but the data values should be ignored.
141  };
142 
143  // A vtkDataArray with this name must be of type vtkUnsignedCharArray.
144  // Each value must be assigned according to the bit fields described in
145  // PointGhostTypes or CellGhostType
146  static const char* GhostArrayName() { return "vtkGhostType"; }
147 
148  //-----------------------------------------------------------------------------------
149 
151 
154  int SetScalars(vtkDataArray* da);
155  int SetActiveScalars(const char* name);
156  vtkDataArray* GetScalars();
158 
160 
163  int SetVectors(vtkDataArray* da);
164  int SetActiveVectors(const char* name);
165  vtkDataArray* GetVectors();
167 
169 
172  int SetNormals(vtkDataArray* da);
173  int SetActiveNormals(const char* name);
174  vtkDataArray* GetNormals();
176 
178 
181  int SetTangents(vtkDataArray* da);
182  int SetActiveTangents(const char* name);
183  vtkDataArray* GetTangents();
185 
187 
190  int SetTCoords(vtkDataArray* da);
191  int SetActiveTCoords(const char* name);
192  vtkDataArray* GetTCoords();
194 
196 
199  int SetTensors(vtkDataArray* da);
200  int SetActiveTensors(const char* name);
201  vtkDataArray* GetTensors();
203 
205 
208  int SetGlobalIds(vtkDataArray* da);
209  int SetActiveGlobalIds(const char* name);
210  vtkDataArray* GetGlobalIds();
212 
214 
217  int SetPedigreeIds(vtkAbstractArray* da);
218  int SetActivePedigreeIds(const char* name);
219  vtkAbstractArray* GetPedigreeIds();
221 
223 
226  int SetRationalWeights(vtkDataArray* da);
227  int SetActiveRationalWeights(const char* name);
228  vtkDataArray* GetRationalWeights();
230 
232 
235  int SetHigherOrderDegrees(vtkDataArray* da);
236  int SetActiveHigherOrderDegrees(const char* name);
237  vtkDataArray* GetHigherOrderDegrees();
239 
241 
244  int SetProcessIds(vtkDataArray* da);
245  int SetActiveProcessIds(const char* name);
246  vtkDataArray* GetProcessIds();
248 
250 
256  vtkDataArray* GetScalars(const char* name);
257  vtkDataArray* GetVectors(const char* name);
258  vtkDataArray* GetNormals(const char* name);
259  vtkDataArray* GetTangents(const char* name);
260  vtkDataArray* GetTCoords(const char* name);
261  vtkDataArray* GetTensors(const char* name);
262  vtkDataArray* GetGlobalIds(const char* name);
263  vtkAbstractArray* GetPedigreeIds(const char* name);
264  vtkDataArray* GetRationalWeights(const char* name);
265  vtkDataArray* GetHigherOrderDegrees(const char* name);
266  vtkDataArray* GetProcessIds(const char* name);
268 
287  int SetActiveAttribute(const char* name, int attributeType);
288 
294  int SetActiveAttribute(int index, int attributeType);
295 
301  void GetAttributeIndices(int* indexArray);
302 
309  int IsArrayAnAttribute(int idx);
310 
333  int SetAttribute(vtkAbstractArray* aa, int attributeType);
334 
341  vtkDataArray* GetAttribute(int attributeType);
342 
350  vtkAbstractArray* GetAbstractAttribute(int attributeType);
351 
353 
358  void RemoveArray(int index) override;
360 
362 
366  static const char* GetAttributeTypeAsString(int attributeType);
367  static const char* GetLongAttributeTypeAsString(int attributeType);
369 
370  // -- attribute copy properties ------------------------------------------
371 
373  {
374  COPYTUPLE = 0,
375  INTERPOLATE = 1,
376  PASSDATA = 2,
377  ALLCOPY // all of the above
378  };
379 
401  void SetCopyAttribute(int index, int value, int ctype = ALLCOPY);
402 
407  int GetCopyAttribute(int index, int ctype);
408 
410  void SetCopyScalars(vtkTypeBool i, int ctype = ALLCOPY);
411  vtkTypeBool GetCopyScalars(int ctype = ALLCOPY);
412  vtkBooleanMacro(CopyScalars, vtkTypeBool);
413 
415  void SetCopyVectors(vtkTypeBool i, int ctype = ALLCOPY);
416  vtkTypeBool GetCopyVectors(int ctype = ALLCOPY);
417  vtkBooleanMacro(CopyVectors, vtkTypeBool);
418 
420  void SetCopyNormals(vtkTypeBool i, int ctype = ALLCOPY);
421  vtkTypeBool GetCopyNormals(int ctype = ALLCOPY);
422  vtkBooleanMacro(CopyNormals, vtkTypeBool);
423 
425  void SetCopyTangents(vtkTypeBool i, int ctype = ALLCOPY);
426  vtkTypeBool GetCopyTangents(int ctype = ALLCOPY);
427  vtkBooleanMacro(CopyTangents, vtkTypeBool);
428 
430  void SetCopyTCoords(vtkTypeBool i, int ctype = ALLCOPY);
431  vtkTypeBool GetCopyTCoords(int ctype = ALLCOPY);
432  vtkBooleanMacro(CopyTCoords, vtkTypeBool);
433 
435  void SetCopyTensors(vtkTypeBool i, int ctype = ALLCOPY);
436  vtkTypeBool GetCopyTensors(int ctype = ALLCOPY);
437  vtkBooleanMacro(CopyTensors, vtkTypeBool);
438 
440  void SetCopyGlobalIds(vtkTypeBool i, int ctype = ALLCOPY);
441  vtkTypeBool GetCopyGlobalIds(int ctype = ALLCOPY);
442  vtkBooleanMacro(CopyGlobalIds, vtkTypeBool);
443 
445  void SetCopyPedigreeIds(vtkTypeBool i, int ctype = ALLCOPY);
446  vtkTypeBool GetCopyPedigreeIds(int ctype = ALLCOPY);
447  vtkBooleanMacro(CopyPedigreeIds, vtkTypeBool);
448 
450  void SetCopyRationalWeights(vtkTypeBool i, int ctype = ALLCOPY);
451  vtkTypeBool GetCopyRationalWeights(int ctype = ALLCOPY);
452  vtkBooleanMacro(CopyRationalWeights, vtkTypeBool);
453 
455  void SetCopyHigherOrderDegrees(vtkTypeBool i, int ctype = ALLCOPY);
456  vtkTypeBool GetCopyHigherOrderDegrees(int ctype = ALLCOPY);
457  vtkBooleanMacro(CopyHigherOrderDegrees, vtkTypeBool);
458 
460  void SetCopyProcessIds(vtkTypeBool i, int ctype = ALLCOPY);
461  vtkTypeBool GetCopyProcessIds(int ctype = ALLCOPY);
462  vtkBooleanMacro(CopyProcessIds, vtkTypeBool);
463 
465  void CopyAllOn(int ctype = ALLCOPY) override;
466 
468  void CopyAllOff(int ctype = ALLCOPY) override;
469 
470  // -- passthrough operations ----------------------------------------------
471 
481  void PassData(vtkFieldData* fd) override;
482 
483  // -- copytuple operations ------------------------------------------------
484 
486 
497  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze = 0, vtkIdType ext = 1000)
498  {
499  this->CopyAllocate(pd, sze, ext, 0);
500  }
501  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
503 
511  void SetupForCopy(vtkDataSetAttributes* pd);
512 
521  void CopyStructuredData(
522  vtkDataSetAttributes* inDsa, const int* inExt, const int* outExt, bool setSize = true);
523 
525 
538  void CopyData(vtkDataSetAttributes* fromPd, vtkIdType fromId, vtkIdType toId);
539  void CopyData(vtkDataSetAttributes* fromPd, vtkIdList* fromIds, vtkIdList* toIds);
540  void CopyData(vtkDataSetAttributes* fromPd, vtkIdList* fromIds, vtkIdType destStartId = 0);
542 
548  void CopyData(vtkDataSetAttributes* fromPd, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
549 
551 
557  void CopyTuple(
558  vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdType fromId, vtkIdType toId);
559  void CopyTuples(
560  vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdList* fromIds, vtkIdList* toIds);
561  void CopyTuples(vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdType dstStart,
562  vtkIdType n, vtkIdType srcStart);
564 
565  // -- interpolate operations ----------------------------------------------
566 
568 
577  {
578  this->InterpolateAllocate(pd, sze, ext, 0);
579  }
580  void InterpolateAllocate(
581  vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
583 
591  void InterpolatePoint(
592  vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdList* ids, double* weights);
593 
603  void InterpolateEdge(
604  vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdType p1, vtkIdType p2, double t);
605 
618  void InterpolateTime(
619  vtkDataSetAttributes* from1, vtkDataSetAttributes* from2, vtkIdType id, double t);
620 
622 
623  // field list copy operations ------------------------------------------
624 
629  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze = 0, vtkIdType ext = 1000);
630 
637  void CopyData(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* dsa, int idx,
638  vtkIdType fromId, vtkIdType toId);
639  void CopyData(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* dsa, int idx,
640  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
641 
648  void InterpolateAllocate(
649  vtkDataSetAttributes::FieldList& list, vtkIdType sze = 0, vtkIdType ext = 1000);
650 
657  void InterpolatePoint(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* fromPd,
658  int idx, vtkIdType toId, vtkIdList* ids, double* weights);
659 
660 protected:
662  ~vtkDataSetAttributes() override;
663 
664  void InternalCopyAllocate(vtkDataSetAttributes* pd, int ctype, vtkIdType sze = 0,
665  vtkIdType ext = 1000, int shallowCopyArrays = 0, bool createNewArrays = true);
666 
670  void InitializeFields() override;
671 
672  int AttributeIndices[NUM_ATTRIBUTES]; // index to attribute array in field data
673  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; // copy flag for attribute data
674 
675  friend struct ArrayList; // Friend to base class in vtkArrayListTemplate
678 
679  static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
680  static const int AttributeLimits[NUM_ATTRIBUTES];
681  static const char AttributeNames[NUM_ATTRIBUTES][19];
682  static const char LongAttributeNames[NUM_ATTRIBUTES][42];
683 
684 private:
685  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
686 
687  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
688 
690  void operator=(const vtkDataSetAttributes&) = delete;
691 
693 };
694 
695 VTK_ABI_NAMESPACE_END
696 #endif
static const char * GhostArrayName()
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:315
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
static vtkFieldData * New()
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:22
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
represent and manipulate fields of data
Definition: vtkFieldData.h:51