VTK  9.2.6
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 =========================================================================*/
57 #ifndef vtkDataSetAttributes_h
58 #define vtkDataSetAttributes_h
59 
60 #include "vtkCommonDataModelModule.h" // For export macro
61 #include "vtkDataSetAttributesFieldList.h" // for vtkDataSetAttributesFieldList
62 #include "vtkFieldData.h"
63 
64 class vtkLookupTable;
65 
66 class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributes : public vtkFieldData
67 {
68 public:
72  static vtkDataSetAttributes* New();
74 
76  void PrintSelf(ostream& os, vtkIndent indent) override;
77 
82  void Initialize() override;
83 
88  virtual void Update() {}
89 
90  // -- shallow and deep copy -----------------------------------------------
91 
97  void DeepCopy(vtkFieldData* pd) override;
98 
103  void ShallowCopy(vtkFieldData* pd) override;
104 
105  // -- attribute types -----------------------------------------------------
106 
107  // Always keep NUM_ATTRIBUTES as the last entry
109  {
110  SCALARS = 0,
111  VECTORS = 1,
112  NORMALS = 2,
113  TCOORDS = 3,
114  TENSORS = 4,
115  GLOBALIDS = 5,
116  PEDIGREEIDS = 6,
117  EDGEFLAG = 7,
118  TANGENTS = 8,
119  RATIONALWEIGHTS = 9,
120  HIGHERORDERDEGREES = 10,
121  NUM_ATTRIBUTES
122  };
123 
125  {
128  NOLIMIT
129  };
130 
131  // ----------- ghost points and ghost cells -------------------------------------------
132  // The following bit fields are consistent with VisIt ghost zones specification
133  // For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
134 
136  {
137  DUPLICATECELL = 1, // the cell is present on multiple processors
138  HIGHCONNECTIVITYCELL = 2, // the cell has more neighbors than in a regular mesh
139  LOWCONNECTIVITYCELL = 4, // the cell has less neighbors than in a regular mesh
140  REFINEDCELL = 8, // other cells are present that refines it.
141  EXTERIORCELL = 16, // the cell is on the exterior of the data set
142  HIDDENCELL =
143  32 // the cell is needed to maintain connectivity, but the data values should be ignored.
144  };
145 
147  {
148  DUPLICATEPOINT = 1, // the cell is present on multiple processors
149  HIDDENPOINT =
150  2 // the point is needed to maintain connectivity, but the data values should be ignored.
151  };
152 
153  // A vtkDataArray with this name must be of type vtkUnsignedCharArray.
154  // Each value must be assigned according to the bit fields described in
155  // PointGhostTypes or CellGhostType
156  static const char* GhostArrayName() { return "vtkGhostType"; }
157 
158  //-----------------------------------------------------------------------------------
159 
161 
164  int SetScalars(vtkDataArray* da);
165  int SetActiveScalars(const char* name);
166  vtkDataArray* GetScalars();
168 
170 
173  int SetVectors(vtkDataArray* da);
174  int SetActiveVectors(const char* name);
175  vtkDataArray* GetVectors();
177 
179 
182  int SetNormals(vtkDataArray* da);
183  int SetActiveNormals(const char* name);
184  vtkDataArray* GetNormals();
186 
188 
191  int SetTangents(vtkDataArray* da);
192  int SetActiveTangents(const char* name);
193  vtkDataArray* GetTangents();
195 
197 
200  int SetTCoords(vtkDataArray* da);
201  int SetActiveTCoords(const char* name);
202  vtkDataArray* GetTCoords();
204 
206 
209  int SetTensors(vtkDataArray* da);
210  int SetActiveTensors(const char* name);
211  vtkDataArray* GetTensors();
213 
215 
218  int SetGlobalIds(vtkDataArray* da);
219  int SetActiveGlobalIds(const char* name);
220  vtkDataArray* GetGlobalIds();
222 
224 
227  int SetPedigreeIds(vtkAbstractArray* da);
228  int SetActivePedigreeIds(const char* name);
229  vtkAbstractArray* GetPedigreeIds();
231 
233 
236  int SetRationalWeights(vtkDataArray* da);
237  int SetActiveRationalWeights(const char* name);
238  vtkDataArray* GetRationalWeights();
240 
242 
245  int SetHigherOrderDegrees(vtkDataArray* da);
246  int SetActiveHigherOrderDegrees(const char* name);
247  vtkDataArray* GetHigherOrderDegrees();
249 
251 
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);
267 
283  int SetActiveAttribute(const char* name, int attributeType);
284 
288  int SetActiveAttribute(int index, int attributeType);
289 
294  void GetAttributeIndices(int* indexArray);
295 
302  int IsArrayAnAttribute(int idx);
303 
326  int SetAttribute(vtkAbstractArray* aa, int attributeType);
327 
334  vtkDataArray* GetAttribute(int attributeType);
335 
343  vtkAbstractArray* GetAbstractAttribute(int attributeType);
344 
346 
350  void RemoveArray(int index) override;
352 
354 
358  static const char* GetAttributeTypeAsString(int attributeType);
359  static const char* GetLongAttributeTypeAsString(int attributeType);
361 
362  // -- attribute copy properties ------------------------------------------
363 
365  {
366  COPYTUPLE = 0,
367  INTERPOLATE = 1,
368  PASSDATA = 2,
369  ALLCOPY // all of the above
370  };
371 
393  void SetCopyAttribute(int index, int value, int ctype = ALLCOPY);
394 
399  int GetCopyAttribute(int index, int ctype);
400 
402  void SetCopyScalars(vtkTypeBool i, int ctype = ALLCOPY);
403  vtkTypeBool GetCopyScalars(int ctype = ALLCOPY);
404  vtkBooleanMacro(CopyScalars, vtkTypeBool);
405 
407  void SetCopyVectors(vtkTypeBool i, int ctype = ALLCOPY);
408  vtkTypeBool GetCopyVectors(int ctype = ALLCOPY);
409  vtkBooleanMacro(CopyVectors, vtkTypeBool);
410 
412  void SetCopyNormals(vtkTypeBool i, int ctype = ALLCOPY);
413  vtkTypeBool GetCopyNormals(int ctype = ALLCOPY);
414  vtkBooleanMacro(CopyNormals, vtkTypeBool);
415 
417  void SetCopyTangents(vtkTypeBool i, int ctype = ALLCOPY);
418  vtkTypeBool GetCopyTangents(int ctype = ALLCOPY);
419  vtkBooleanMacro(CopyTangents, vtkTypeBool);
420 
422  void SetCopyTCoords(vtkTypeBool i, int ctype = ALLCOPY);
423  vtkTypeBool GetCopyTCoords(int ctype = ALLCOPY);
424  vtkBooleanMacro(CopyTCoords, vtkTypeBool);
425 
427  void SetCopyTensors(vtkTypeBool i, int ctype = ALLCOPY);
428  vtkTypeBool GetCopyTensors(int ctype = ALLCOPY);
429  vtkBooleanMacro(CopyTensors, vtkTypeBool);
430 
432  void SetCopyGlobalIds(vtkTypeBool i, int ctype = ALLCOPY);
433  vtkTypeBool GetCopyGlobalIds(int ctype = ALLCOPY);
434  vtkBooleanMacro(CopyGlobalIds, vtkTypeBool);
435 
437  void SetCopyPedigreeIds(vtkTypeBool i, int ctype = ALLCOPY);
438  vtkTypeBool GetCopyPedigreeIds(int ctype = ALLCOPY);
439  vtkBooleanMacro(CopyPedigreeIds, vtkTypeBool);
440 
442  void SetCopyRationalWeights(vtkTypeBool i, int ctype = ALLCOPY);
443  vtkTypeBool GetCopyRationalWeights(int ctype = ALLCOPY);
444  vtkBooleanMacro(CopyRationalWeights, vtkTypeBool);
445 
447  void SetCopyHigherOrderDegrees(vtkTypeBool i, int ctype = ALLCOPY);
448  vtkTypeBool GetCopyHigherOrderDegrees(int ctype = ALLCOPY);
449  vtkBooleanMacro(CopyHigherOrderDegrees, vtkTypeBool);
450 
452  void CopyAllOn(int ctype = ALLCOPY) override;
453 
455  void CopyAllOff(int ctype = ALLCOPY) override;
456 
457  // -- passthrough operations ----------------------------------------------
458 
468  void PassData(vtkFieldData* fd) override;
469 
470  // -- copytuple operations ------------------------------------------------
471 
473 
484  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze = 0, vtkIdType ext = 1000)
485  {
486  this->CopyAllocate(pd, sze, ext, 0);
487  }
488  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
490 
498  void SetupForCopy(vtkDataSetAttributes* pd);
499 
508  void CopyStructuredData(
509  vtkDataSetAttributes* inDsa, const int* inExt, const int* outExt, bool setSize = true);
510 
512 
525  void CopyData(vtkDataSetAttributes* fromPd, vtkIdType fromId, vtkIdType toId);
526  void CopyData(vtkDataSetAttributes* fromPd, vtkIdList* fromIds, vtkIdList* toIds);
527  void CopyData(vtkDataSetAttributes* fromPd, vtkIdList* fromIds, vtkIdType destStartId = 0);
529 
535  void CopyData(vtkDataSetAttributes* fromPd, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
536 
538 
544  void CopyTuple(
545  vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdType fromId, vtkIdType toId);
546  void CopyTuples(
547  vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdList* fromIds, vtkIdList* toIds);
548  void CopyTuples(vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdType dstStart,
549  vtkIdType n, vtkIdType srcStart);
551 
552  // -- interpolate operations ----------------------------------------------
553 
555 
564  {
565  this->InterpolateAllocate(pd, sze, ext, 0);
566  }
567  void InterpolateAllocate(
568  vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
570 
578  void InterpolatePoint(
579  vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdList* ids, double* weights);
580 
590  void InterpolateEdge(
591  vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdType p1, vtkIdType p2, double t);
592 
605  void InterpolateTime(
606  vtkDataSetAttributes* from1, vtkDataSetAttributes* from2, vtkIdType id, double t);
607 
609 
610  // field list copy operations ------------------------------------------
611 
616  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze = 0, vtkIdType ext = 1000);
617 
624  void CopyData(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* dsa, int idx,
625  vtkIdType fromId, vtkIdType toId);
626  void CopyData(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* dsa, int idx,
627  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
628 
635  void InterpolateAllocate(
636  vtkDataSetAttributes::FieldList& list, vtkIdType sze = 0, vtkIdType ext = 1000);
637 
644  void InterpolatePoint(vtkDataSetAttributes::FieldList& list, vtkDataSetAttributes* fromPd,
645  int idx, vtkIdType toId, vtkIdList* ids, double* weights);
646 
647 protected:
649  ~vtkDataSetAttributes() override;
650 
651  void InternalCopyAllocate(vtkDataSetAttributes* pd, int ctype, vtkIdType sze = 0,
652  vtkIdType ext = 1000, int shallowCopyArrays = 0, bool createNewArrays = true);
653 
657  void InitializeFields() override;
658 
659  int AttributeIndices[NUM_ATTRIBUTES]; // index to attribute array in field data
660  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; // copy flag for attribute data
661 
662  friend struct ArrayList; // Friend to base class in vtkArrayListTemplate
665 
666  static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
667  static const int AttributeLimits[NUM_ATTRIBUTES];
668  static const char AttributeNames[NUM_ATTRIBUTES][19];
669  static const char LongAttributeNames[NUM_ATTRIBUTES][42];
670 
671 private:
672  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
673 
674  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
675 
676 private:
678  void operator=(const vtkDataSetAttributes&) = delete;
679 
681 };
682 
683 #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:332
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:39
list of point or cell ids
Definition: vtkIdList.h:33
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:55
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:62