VTK  9.0.1
vtkDataSetAttributes.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDataSetAttributes.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
44 #ifndef vtkDataSetAttributes_h
45 #define vtkDataSetAttributes_h
46 
47 #include "vtkCommonDataModelModule.h" // For export macro
48 #include "vtkDataSetAttributesFieldList.h" // for vtkDataSetAttributesFieldList
49 #include "vtkFieldData.h"
50 
51 class vtkLookupTable;
52 
53 class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributes : public vtkFieldData
54 {
55 public:
59  static vtkDataSetAttributes* New();
60 
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
68  void Initialize() override;
69 
74  virtual void Update() {}
75 
76  // -- shallow and deep copy -----------------------------------------------
77 
83  void DeepCopy(vtkFieldData* pd) override;
84 
89  void ShallowCopy(vtkFieldData* pd) override;
90 
91  // -- attribute types -----------------------------------------------------
92 
93  // Always keep NUM_ATTRIBUTES as the last entry
95  {
96  SCALARS = 0,
97  VECTORS = 1,
98  NORMALS = 2,
99  TCOORDS = 3,
100  TENSORS = 4,
101  GLOBALIDS = 5,
102  PEDIGREEIDS = 6,
103  EDGEFLAG = 7,
104  TANGENTS = 8,
105  RATIONALWEIGHTS = 9,
106  HIGHERORDERDEGREES = 10,
107  NUM_ATTRIBUTES
108  };
109 
111  {
114  NOLIMIT
115  };
116 
117  // ----------- ghost points and ghost cells -------------------------------------------
118  // The following bit fields are consistent with VisIt ghost zones specification
119  // For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
120 
122  {
123  DUPLICATECELL = 1, // the cell is present on multiple processors
124  HIGHCONNECTIVITYCELL = 2, // the cell has more neighbors than in a regular mesh
125  LOWCONNECTIVITYCELL = 4, // the cell has less neighbors than in a regular mesh
126  REFINEDCELL = 8, // other cells are present that refines it.
127  EXTERIORCELL = 16, // the cell is on the exterior of the data set
128  HIDDENCELL =
129  32 // the cell is needed to maintain connectivity, but the data values should be ignored.
130  };
131 
133  {
134  DUPLICATEPOINT = 1, // the cell is present on multiple processors
135  HIDDENPOINT =
136  2 // the point is needed to maintain connectivity, but the data values should be ignored.
137  };
138 
139  // A vtkDataArray with this name must be of type vtkUnsignedCharArray.
140  // Each value must be assigned according to the bit fields described in
141  // PointGhostTypes or CellGhostType
142  static const char* GhostArrayName() { return "vtkGhostType"; }
143 
144  //-----------------------------------------------------------------------------------
145 
147 
150  int SetScalars(vtkDataArray* da);
151  int SetActiveScalars(const char* name);
152  vtkDataArray* GetScalars();
154 
156 
159  int SetVectors(vtkDataArray* da);
160  int SetActiveVectors(const char* name);
161  vtkDataArray* GetVectors();
163 
165 
168  int SetNormals(vtkDataArray* da);
169  int SetActiveNormals(const char* name);
170  vtkDataArray* GetNormals();
172 
174 
177  int SetTangents(vtkDataArray* da);
178  int SetActiveTangents(const char* name);
179  vtkDataArray* GetTangents();
181 
183 
186  int SetTCoords(vtkDataArray* da);
187  int SetActiveTCoords(const char* name);
188  vtkDataArray* GetTCoords();
190 
192 
195  int SetTensors(vtkDataArray* da);
196  int SetActiveTensors(const char* name);
197  vtkDataArray* GetTensors();
199 
201 
204  int SetGlobalIds(vtkDataArray* da);
205  int SetActiveGlobalIds(const char* name);
206  vtkDataArray* GetGlobalIds();
208 
210 
213  int SetPedigreeIds(vtkAbstractArray* da);
214  int SetActivePedigreeIds(const char* name);
215  vtkAbstractArray* GetPedigreeIds();
217 
219 
222  int SetRationalWeights(vtkDataArray* da);
223  int SetActiveRationalWeights(const char* name);
224  vtkDataArray* GetRationalWeights();
226 
228 
231  int SetHigherOrderDegrees(vtkDataArray* da);
232  int SetActiveHigherOrderDegrees(const char* name);
233  vtkDataArray* GetHigherOrderDegrees();
235 
237 
242  vtkDataArray* GetScalars(const char* name);
243  vtkDataArray* GetVectors(const char* name);
244  vtkDataArray* GetNormals(const char* name);
245  vtkDataArray* GetTangents(const char* name);
246  vtkDataArray* GetTCoords(const char* name);
247  vtkDataArray* GetTensors(const char* name);
248  vtkDataArray* GetGlobalIds(const char* name);
249  vtkAbstractArray* GetPedigreeIds(const char* name);
250  vtkDataArray* GetRationalWeights(const char* name);
251  vtkDataArray* GetHigherOrderDegrees(const char* name);
253 
269  int SetActiveAttribute(const char* name, int attributeType);
270 
274  int SetActiveAttribute(int index, int attributeType);
275 
280  void GetAttributeIndices(int* indexArray);
281 
288  int IsArrayAnAttribute(int idx);
289 
312  int SetAttribute(vtkAbstractArray* aa, int attributeType);
313 
320  vtkDataArray* GetAttribute(int attributeType);
321 
329  vtkAbstractArray* GetAbstractAttribute(int attributeType);
330 
332 
336  void RemoveArray(int index) override;
338 
340 
344  static const char* GetAttributeTypeAsString(int attributeType);
345  static const char* GetLongAttributeTypeAsString(int attributeType);
347 
348  // -- attribute copy properties ------------------------------------------
349 
351  {
352  COPYTUPLE = 0,
353  INTERPOLATE = 1,
354  PASSDATA = 2,
355  ALLCOPY // all of the above
356  };
357 
379  void SetCopyAttribute(int index, int value, int ctype = ALLCOPY);
380 
385  int GetCopyAttribute(int index, int ctype);
386 
388  void SetCopyScalars(vtkTypeBool i, int ctype = ALLCOPY);
389  vtkTypeBool GetCopyScalars(int ctype = ALLCOPY);
390  vtkBooleanMacro(CopyScalars, vtkTypeBool);
391 
393  void SetCopyVectors(vtkTypeBool i, int ctype = ALLCOPY);
394  vtkTypeBool GetCopyVectors(int ctype = ALLCOPY);
395  vtkBooleanMacro(CopyVectors, vtkTypeBool);
396 
398  void SetCopyNormals(vtkTypeBool i, int ctype = ALLCOPY);
399  vtkTypeBool GetCopyNormals(int ctype = ALLCOPY);
400  vtkBooleanMacro(CopyNormals, vtkTypeBool);
401 
403  void SetCopyTangents(vtkTypeBool i, int ctype = ALLCOPY);
404  vtkTypeBool GetCopyTangents(int ctype = ALLCOPY);
405  vtkBooleanMacro(CopyTangents, vtkTypeBool);
406 
408  void SetCopyTCoords(vtkTypeBool i, int ctype = ALLCOPY);
409  vtkTypeBool GetCopyTCoords(int ctype = ALLCOPY);
410  vtkBooleanMacro(CopyTCoords, vtkTypeBool);
411 
413  void SetCopyTensors(vtkTypeBool i, int ctype = ALLCOPY);
414  vtkTypeBool GetCopyTensors(int ctype = ALLCOPY);
415  vtkBooleanMacro(CopyTensors, vtkTypeBool);
416 
418  void SetCopyGlobalIds(vtkTypeBool i, int ctype = ALLCOPY);
419  vtkTypeBool GetCopyGlobalIds(int ctype = ALLCOPY);
420  vtkBooleanMacro(CopyGlobalIds, vtkTypeBool);
421 
423  void SetCopyPedigreeIds(vtkTypeBool i, int ctype = ALLCOPY);
424  vtkTypeBool GetCopyPedigreeIds(int ctype = ALLCOPY);
425  vtkBooleanMacro(CopyPedigreeIds, vtkTypeBool);
426 
428  void SetCopyRationalWeights(vtkTypeBool i, int ctype = ALLCOPY);
429  vtkTypeBool GetCopyRationalWeights(int ctype = ALLCOPY);
430  vtkBooleanMacro(CopyRationalWeights, vtkTypeBool);
431 
433  void SetCopyHigherOrderDegrees(vtkTypeBool i, int ctype = ALLCOPY);
434  vtkTypeBool GetCopyHigherOrderDegrees(int ctype = ALLCOPY);
435  vtkBooleanMacro(CopyHigherOrderDegrees, vtkTypeBool);
436 
438  void CopyAllOn(int ctype = ALLCOPY) override;
439 
441  void CopyAllOff(int ctype = ALLCOPY) override;
442 
443  // -- passthrough operations ----------------------------------------------
444 
454  void PassData(vtkFieldData* fd) override;
455 
456  // -- copytuple operations ------------------------------------------------
457 
459 
470  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze = 0, vtkIdType ext = 1000)
471  {
472  this->CopyAllocate(pd, sze, ext, 0);
473  }
474  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
476 
484  void SetupForCopy(vtkDataSetAttributes* pd);
485 
494  void CopyStructuredData(
495  vtkDataSetAttributes* inDsa, const int* inExt, const int* outExt, bool setSize = true);
496 
498 
508  void CopyData(vtkDataSetAttributes* fromPd, vtkIdType fromId, vtkIdType toId);
509  void CopyData(vtkDataSetAttributes* fromPd, vtkIdList* fromIds, vtkIdList* toIds);
511 
517  void CopyData(vtkDataSetAttributes* fromPd, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
518 
520 
526  void CopyTuple(
527  vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdType fromId, vtkIdType toId);
528  void CopyTuples(
529  vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdList* fromIds, vtkIdList* toIds);
530  void CopyTuples(vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdType dstStart,
531  vtkIdType n, vtkIdType srcStart);
533 
534  // -- interpolate operations ----------------------------------------------
535 
537 
546  {
547  this->InterpolateAllocate(pd, sze, ext, 0);
548  }
549  void InterpolateAllocate(
550  vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
552 
560  void InterpolatePoint(
561  vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdList* ids, double* weights);
562 
572  void InterpolateEdge(
573  vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdType p1, vtkIdType p2, double t);
574 
587  void InterpolateTime(
588  vtkDataSetAttributes* from1, vtkDataSetAttributes* from2, vtkIdType id, double t);
589 
591 
592  // field list copy operations ------------------------------------------
593 
598  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze = 0, vtkIdType ext = 1000);
599 
606  void CopyData(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* dsa, int idx,
607  vtkIdType fromId, vtkIdType toId);
608  void CopyData(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* dsa, int idx,
609  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
610 
617  void InterpolateAllocate(
618  vtkDataSetAttributes::FieldList& list, vtkIdType sze = 0, vtkIdType ext = 1000);
619 
626  void InterpolatePoint(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* fromPd,
627  int idx, vtkIdType toId, vtkIdList* ids, double* weights);
628 
629 protected:
631  ~vtkDataSetAttributes() override;
632 
633  void InternalCopyAllocate(vtkDataSetAttributes* pd, int ctype, vtkIdType sze = 0,
634  vtkIdType ext = 1000, int shallowCopyArrays = 0, bool createNewArrays = true);
635 
639  void InitializeFields() override;
640 
641  int AttributeIndices[NUM_ATTRIBUTES]; // index to attribute array in field data
642  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; // copy flag for attribute data
643 
645 
647 
648  static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
649  static const int AttributeLimits[NUM_ATTRIBUTES];
650  static const char AttributeNames[NUM_ATTRIBUTES][19];
651  static const char LongAttributeNames[NUM_ATTRIBUTES][42];
652 
653 private:
654  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
655 
656  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
657 
658 private:
660  void operator=(const vtkDataSetAttributes&) = delete;
661 
663 };
664 
665 #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.
virtual void CopyAllOn(int unused=0)
Turn on copying of all data.
int vtkIdType
Definition: vtkType.h:338
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:69
static vtkFieldData * New()
virtual void InitializeFields()
Release all data but do not delete object.
a simple class to control print indentation
Definition: vtkIndent.h:33
list of point or cell ids
Definition: vtkIdList.h:30
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:49
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 or index) from the list of arrays.
vtkFieldData::BasicIterator RequiredArrays
represent and manipulate fields of data
Definition: vtkFieldData.h:53