VTK  9.0.2
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:
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 
151  int SetActiveScalars(const char* name);
154 
156 
160  int SetActiveVectors(const char* name);
163 
165 
169  int SetActiveNormals(const char* name);
172 
174 
178  int SetActiveTangents(const char* name);
181 
183 
187  int SetActiveTCoords(const char* name);
190 
192 
196  int SetActiveTensors(const char* name);
199 
201 
205  int SetActiveGlobalIds(const char* name);
208 
210 
214  int SetActivePedigreeIds(const char* name);
217 
219 
223  int SetActiveRationalWeights(const char* name);
226 
228 
235 
237 
242  vtkDataArray* GetScalars(const char* name);
243  vtkDataArray* GetVectors(const char* name);
244  vtkDataArray* GetNormals(const char* name);
246  vtkDataArray* GetTCoords(const char* name);
247  vtkDataArray* GetTensors(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 
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);
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 
485 
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);
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  }
550  vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
552 
561  vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdList* ids, double* weights);
562 
573  vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdType p1, vtkIdType p2, double t);
574 
588  vtkDataSetAttributes* from1, vtkDataSetAttributes* from2, vtkIdType id, double t);
589 
591 
592  // field list copy operations ------------------------------------------
593 
599 
607  vtkIdType fromId, vtkIdType toId);
609  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
610 
618  vtkDataSetAttributes::FieldList& list, vtkIdType sze = 0, vtkIdType ext = 1000);
619 
627  int idx, vtkIdType toId, vtkIdList* ids, double* weights);
628 
629 protected:
632 
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
Abstract superclass for all arrays.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
helps manage arrays from multiple vtkDataSetAttributes.
represent and manipulate attribute data in a dataset
vtkDataArray * GetScalars(const char *name)
This will first look for an array with the correct name.
vtkTypeBool GetCopyPedigreeIds(int ctype=ALLCOPY)
static const char * GhostArrayName()
void PassData(vtkFieldData *fd) override
Pass entire arrays of input data through to output.
virtual void Update()
Attributes have a chance to bring themselves up to date; right now this is ignored.
vtkDataArray * GetTensors()
int SetActiveTangents(const char *name)
int SetGlobalIds(vtkDataArray *da)
Set/Get the global id data.
void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId, vtkIdType p1, vtkIdType p2, double t)
Interpolate data from the two points p1,p2 (forming an edge) and an interpolation factor,...
void CopyAllocate(vtkDataSetAttributes *pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays)
vtkDataArray * GetNormals(const char *name)
void Initialize() override
Initialize all of the object's data to nullptr Also, clear the copy flags.
int GetCopyAttribute(int index, int ctype)
Get the attribute copy flag for copy operation <ctype> of attribute <index>.
vtkDataArray * GetVectors(const char *name)
vtkFieldData::BasicIterator RequiredArrays
vtkDataArray * GetRationalWeights()
vtkTypeBool GetCopyScalars(int ctype=ALLCOPY)
int SetActiveAttribute(int index, int attributeType)
Make the array with the given index the active attribute.
void SetCopyAttribute(int index, int value, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
~vtkDataSetAttributes() override
int SetHigherOrderDegrees(vtkDataArray *da)
Set/Get the rational degrees data.
int SetActiveNormals(const char *name)
void SetCopyNormals(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
void InterpolateAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
Initialize point interpolation method.
int SetActiveHigherOrderDegrees(const char *name)
int SetScalars(vtkDataArray *da)
Set/Get the scalar data.
vtkAbstractArray * GetAbstractAttribute(int attributeType)
Return an attribute given the attribute type (see vtkDataSetAttributes::AttributeTypes).
vtkDataArray * GetTangents(const char *name)
void SetCopyTCoords(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
void InterpolatePoint(vtkDataSetAttributes::FieldList &list, vtkDataSetAttributes *fromPd, int idx, vtkIdType toId, vtkIdList *ids, double *weights)
Interpolate data set attributes from other data set attributes given cell or point ids and associated...
vtkAbstractArray * GetPedigreeIds(const char *name)
int SetActiveTCoords(const char *name)
vtkDataArray * GetTensors(const char *name)
void SetCopyTangents(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
vtkTypeBool GetCopyVectors(int ctype=ALLCOPY)
vtkTypeBool GetCopyNormals(int ctype=ALLCOPY)
void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData, vtkIdList *fromIds, vtkIdList *toIds)
void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId, vtkIdList *ids, double *weights)
Interpolate data set attributes from other data set attributes given cell or point ids and associated...
void InterpolateAllocate(vtkDataSetAttributes::FieldList &list, vtkIdType sze=0, vtkIdType ext=1000)
A special form of InterpolateAllocate() to be used with FieldLists.
void SetCopyPedigreeIds(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
void InitializeFields() override
Initialize all of the object's data to nullptr.
int SetActiveGlobalIds(const char *name)
void SetupForCopy(vtkDataSetAttributes *pd)
Create a mapping between the input attributes and this object so that methods like CopyData() and Cop...
int SetActiveScalars(const char *name)
void CopyData(vtkDataSetAttributes *fromPd, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart)
Copy n consecutive attributes starting at srcStart from fromPd to this container, starting at the dst...
vtkDataArray * GetNormals()
vtkDataArray * GetHigherOrderDegrees(const char *name)
int SetNormals(vtkDataArray *da)
Set/get the normal data.
void InterpolateTime(vtkDataSetAttributes *from1, vtkDataSetAttributes *from2, vtkIdType id, double t)
Interpolate data from the same id (point or cell) at different points in time (parameter t).
void CopyData(vtkDataSetAttributes::FieldList &list, vtkDataSetAttributes *dsa, int idx, vtkIdType fromId, vtkIdType toId)
Special forms of CopyData() to be used with FieldLists.
void CopyAllOn(int ctype=ALLCOPY) override
Turn on/off the copying of attribute data.
void SetCopyScalars(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData, vtkIdType fromId, vtkIdType toId)
Copy a tuple (or set of tuples) of data from one data array to another.
vtkDataArray * GetGlobalIds(const char *name)
void InternalCopyAllocate(vtkDataSetAttributes *pd, int ctype, vtkIdType sze=0, vtkIdType ext=1000, int shallowCopyArrays=0, bool createNewArrays=true)
int IsArrayAnAttribute(int idx)
Determine whether a data array of index idx is considered a data set attribute (i....
vtkTypeBool GetCopyTangents(int ctype=ALLCOPY)
void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId)
Copy the attribute data from one id to another.
int SetActivePedigreeIds(const char *name)
int SetActiveRationalWeights(const char *name)
vtkDataArray * GetGlobalIds()
void RemoveArray(int index) override
vtkTypeBool GetCopyRationalWeights(int ctype=ALLCOPY)
vtkTypeBool GetCopyHigherOrderDegrees(int ctype=ALLCOPY)
void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart)
void CopyData(vtkDataSetAttributes::FieldList &list, vtkDataSetAttributes *dsa, int idx, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart)
vtkTypeBool GetCopyGlobalIds(int ctype=ALLCOPY)
vtkTypeBool GetCopyTCoords(int ctype=ALLCOPY)
void CopyStructuredData(vtkDataSetAttributes *inDsa, const int *inExt, const int *outExt, bool setSize=true)
This method is used to copy data arrays in images.
static vtkDataSetAttributes * New()
Construct object with copying turned on for all data.
static const char * GetAttributeTypeAsString(int attributeType)
Given an integer attribute type, this static method returns a string type for the attribute (i....
vtkDataArray * GetVectors()
void CopyAllocate(vtkDataSetAttributes::FieldList &list, vtkIdType sze=0, vtkIdType ext=1000)
A special form of CopyAllocate() to be used with FieldLists.
void CopyAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
Allocates point data for point-by-point (or cell-by-cell) copy operation.
static const char * GetLongAttributeTypeAsString(int attributeType)
vtkDataArray * GetRationalWeights(const char *name)
void DeepCopy(vtkFieldData *pd) override
Deep copy of data (i.e., create new data arrays and copy from input data).
int SetRationalWeights(vtkDataArray *da)
Set/Get the rational weights data.
void ShallowCopy(vtkFieldData *pd) override
Shallow copy of data (i.e., use reference counting).
void GetAttributeIndices(int *indexArray)
Get the field data array indices corresponding to scalars, vectors, tensors, etc.
vtkDataArray * GetTCoords(const char *name)
void SetCopyRationalWeights(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
vtkDataArray * GetTangents()
void SetCopyTensors(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
vtkAbstractArray * GetPedigreeIds()
int SetActiveAttribute(const char *name, int attributeType)
Make the array with the given name the active attribute.
vtkDataArray * GetTCoords()
int SetTCoords(vtkDataArray *da)
Set/Get the texture coordinate data.
vtkDataArray * GetHigherOrderDegrees()
void SetCopyHigherOrderDegrees(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
vtkDataArray * GetScalars()
void InterpolateAllocate(vtkDataSetAttributes *pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays)
int SetPedigreeIds(vtkAbstractArray *da)
Set/Get the pedigree id data.
vtkTypeBool GetCopyTensors(int ctype=ALLCOPY)
void CopyData(vtkDataSetAttributes *fromPd, vtkIdList *fromIds, vtkIdList *toIds)
int SetActiveVectors(const char *name)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetCopyGlobalIds(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
void CopyAllOff(int ctype=ALLCOPY) override
Turn on/off the copying of attribute data.
int SetTangents(vtkDataArray *da)
Set/get the tangent data.
int SetActiveTensors(const char *name)
void SetCopyVectors(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
int SetVectors(vtkDataArray *da)
Set/Get the vector data.
int SetTensors(vtkDataArray *da)
Set/Get the tensor data.
vtkDataArray * GetAttribute(int attributeType)
Return an attribute given the attribute type (see vtkDataSetAttributes::AttributeTypes).
int SetAttribute(vtkAbstractArray *aa, int attributeType)
Set an array to use as the given attribute type (i.e., vtkDataSetAttributes::SCALAR,...
represent and manipulate fields of data
Definition: vtkFieldData.h:54
virtual void RemoveArray(const char *name)
Remove an array (with the given name or index) from the list of arrays.
list of point or cell ids
Definition: vtkIdList.h:31
a simple class to control print indentation
Definition: vtkIndent.h:34
map scalar values into colors via a lookup table
@ value
Definition: vtkX3D.h:226
@ name
Definition: vtkX3D.h:225
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:338