VTK  9.1.0
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=========================================================================*/
60#ifndef vtkDataSetAttributes_h
61#define vtkDataSetAttributes_h
62
63#include "vtkCommonDataModelModule.h" // For export macro
64#include "vtkDataSetAttributesFieldList.h" // for vtkDataSetAttributesFieldList
65#include "vtkFieldData.h"
66
67class vtkLookupTable;
68
69class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributes : public vtkFieldData
70{
71public:
77
79 void PrintSelf(ostream& os, vtkIndent indent) override;
80
85 void Initialize() override;
86
91 virtual void Update() {}
92
93 // -- shallow and deep copy -----------------------------------------------
94
100 void DeepCopy(vtkFieldData* pd) override;
101
106 void ShallowCopy(vtkFieldData* pd) override;
107
108 // -- attribute types -----------------------------------------------------
109
110 // Always keep NUM_ATTRIBUTES as the last entry
112 {
113 SCALARS = 0,
114 VECTORS = 1,
115 NORMALS = 2,
116 TCOORDS = 3,
117 TENSORS = 4,
118 GLOBALIDS = 5,
119 PEDIGREEIDS = 6,
120 EDGEFLAG = 7,
121 TANGENTS = 8,
122 RATIONALWEIGHTS = 9,
123 HIGHERORDERDEGREES = 10,
124 NUM_ATTRIBUTES
125 };
126
128 {
131 NOLIMIT
132 };
133
134 // ----------- ghost points and ghost cells -------------------------------------------
135 // The following bit fields are consistent with VisIt ghost zones specification
136 // For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
137
139 {
140 DUPLICATECELL = 1, // the cell is present on multiple processors
141 HIGHCONNECTIVITYCELL = 2, // the cell has more neighbors than in a regular mesh
142 LOWCONNECTIVITYCELL = 4, // the cell has less neighbors than in a regular mesh
143 REFINEDCELL = 8, // other cells are present that refines it.
144 EXTERIORCELL = 16, // the cell is on the exterior of the data set
145 HIDDENCELL =
146 32 // the cell is needed to maintain connectivity, but the data values should be ignored.
147 };
148
150 {
151 DUPLICATEPOINT = 1, // the cell is present on multiple processors
152 HIDDENPOINT =
153 2 // the point is needed to maintain connectivity, but the data values should be ignored.
154 };
155
156 // A vtkDataArray with this name must be of type vtkUnsignedCharArray.
157 // Each value must be assigned according to the bit fields described in
158 // PointGhostTypes or CellGhostType
159 static const char* GhostArrayName() { return "vtkGhostType"; }
160
161 //-----------------------------------------------------------------------------------
162
164
168 int SetActiveScalars(const char* name);
171
173
177 int SetActiveVectors(const char* name);
180
182
186 int SetActiveNormals(const char* name);
189
191
195 int SetActiveTangents(const char* name);
198
200
204 int SetActiveTCoords(const char* name);
207
209
213 int SetActiveTensors(const char* name);
216
218
222 int SetActiveGlobalIds(const char* name);
225
227
231 int SetActivePedigreeIds(const char* name);
234
236
243
245
252
254
270
286 int SetActiveAttribute(const char* name, int attributeType);
287
291 int SetActiveAttribute(int index, int attributeType);
292
297 void GetAttributeIndices(int* indexArray);
298
305 int IsArrayAnAttribute(int idx);
306
329 int SetAttribute(vtkAbstractArray* aa, int attributeType);
330
337 vtkDataArray* GetAttribute(int attributeType);
338
347
349
353 void RemoveArray(int index) override;
355
357
361 static const char* GetAttributeTypeAsString(int attributeType);
362 static const char* GetLongAttributeTypeAsString(int attributeType);
364
365 // -- attribute copy properties ------------------------------------------
366
368 {
369 COPYTUPLE = 0,
370 INTERPOLATE = 1,
371 PASSDATA = 2,
372 ALLCOPY // all of the above
373 };
374
396 void SetCopyAttribute(int index, int value, int ctype = ALLCOPY);
397
402 int GetCopyAttribute(int index, int ctype);
403
405 void SetCopyScalars(vtkTypeBool i, int ctype = ALLCOPY);
406 vtkTypeBool GetCopyScalars(int ctype = ALLCOPY);
407 vtkBooleanMacro(CopyScalars, vtkTypeBool);
408
410 void SetCopyVectors(vtkTypeBool i, int ctype = ALLCOPY);
411 vtkTypeBool GetCopyVectors(int ctype = ALLCOPY);
412 vtkBooleanMacro(CopyVectors, vtkTypeBool);
413
415 void SetCopyNormals(vtkTypeBool i, int ctype = ALLCOPY);
416 vtkTypeBool GetCopyNormals(int ctype = ALLCOPY);
417 vtkBooleanMacro(CopyNormals, vtkTypeBool);
418
420 void SetCopyTangents(vtkTypeBool i, int ctype = ALLCOPY);
421 vtkTypeBool GetCopyTangents(int ctype = ALLCOPY);
422 vtkBooleanMacro(CopyTangents, vtkTypeBool);
423
425 void SetCopyTCoords(vtkTypeBool i, int ctype = ALLCOPY);
426 vtkTypeBool GetCopyTCoords(int ctype = ALLCOPY);
427 vtkBooleanMacro(CopyTCoords, vtkTypeBool);
428
430 void SetCopyTensors(vtkTypeBool i, int ctype = ALLCOPY);
431 vtkTypeBool GetCopyTensors(int ctype = ALLCOPY);
432 vtkBooleanMacro(CopyTensors, vtkTypeBool);
433
435 void SetCopyGlobalIds(vtkTypeBool i, int ctype = ALLCOPY);
436 vtkTypeBool GetCopyGlobalIds(int ctype = ALLCOPY);
437 vtkBooleanMacro(CopyGlobalIds, vtkTypeBool);
438
440 void SetCopyPedigreeIds(vtkTypeBool i, int ctype = ALLCOPY);
441 vtkTypeBool GetCopyPedigreeIds(int ctype = ALLCOPY);
442 vtkBooleanMacro(CopyPedigreeIds, vtkTypeBool);
443
445 void SetCopyRationalWeights(vtkTypeBool i, int ctype = ALLCOPY);
447 vtkBooleanMacro(CopyRationalWeights, vtkTypeBool);
448
450 void SetCopyHigherOrderDegrees(vtkTypeBool i, int ctype = ALLCOPY);
452 vtkBooleanMacro(CopyHigherOrderDegrees, vtkTypeBool);
453
455 void CopyAllOn(int ctype = ALLCOPY) override;
456
458 void CopyAllOff(int ctype = ALLCOPY) override;
459
460 // -- passthrough operations ----------------------------------------------
461
471 void PassData(vtkFieldData* fd) override;
472
473 // -- copytuple operations ------------------------------------------------
474
476
488 {
489 this->CopyAllocate(pd, sze, ext, 0);
490 }
491 void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
493
502
512 vtkDataSetAttributes* inDsa, const int* inExt, const int* outExt, bool setSize = true);
513
515
526 void CopyData(vtkDataSetAttributes* fromPd, vtkIdList* fromIds, vtkIdList* toIds);
528
534 void CopyData(vtkDataSetAttributes* fromPd, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
535
537
544 vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdType fromId, vtkIdType toId);
546 vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdList* fromIds, vtkIdList* toIds);
547 void CopyTuples(vtkAbstractArray* fromData, vtkAbstractArray* toData, vtkIdType dstStart,
548 vtkIdType n, vtkIdType srcStart);
550
551 // -- interpolate operations ----------------------------------------------
552
554
563 {
564 this->InterpolateAllocate(pd, sze, ext, 0);
565 }
567 vtkDataSetAttributes* pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays);
569
578 vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdList* ids, double* weights);
579
590 vtkDataSetAttributes* fromPd, vtkIdType toId, vtkIdType p1, vtkIdType p2, double t);
591
605 vtkDataSetAttributes* from1, vtkDataSetAttributes* from2, vtkIdType id, double t);
606
608
609 // field list copy operations ------------------------------------------
610
616
624 vtkIdType fromId, vtkIdType toId);
626 vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
627
635 vtkDataSetAttributes::FieldList& list, vtkIdType sze = 0, vtkIdType ext = 1000);
636
644 int idx, vtkIdType toId, vtkIdList* ids, double* weights);
645
646protected:
649
651 vtkIdType ext = 1000, int shallowCopyArrays = 0, bool createNewArrays = true);
652
656 void InitializeFields() override;
657
658 int AttributeIndices[NUM_ATTRIBUTES]; // index to attribute array in field data
659 int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; // copy flag for attribute data
660
661 friend struct ArrayList; // Friend to base class in vtkArrayListTemplate
664
665 static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
666 static const int AttributeLimits[NUM_ATTRIBUTES];
667 static const char AttributeNames[NUM_ATTRIBUTES][19];
668 static const char LongAttributeNames[NUM_ATTRIBUTES][42];
669
670private:
671 static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
672
673 vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
674
675private:
677 void operator=(const vtkDataSetAttributes&) = delete;
678
680};
681
682#endif
Abstract superclass for all arrays.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:59
helps manage arrays from multiple vtkDataSetAttributes.
represent and manipulate attribute data in a dataset
static const char * GetLongAttributeTypeAsString(int attributeType)
Given an integer attribute type, this static method returns a string type for the attribute (i....
vtkTypeBool GetCopyPedigreeIds(int ctype=ALLCOPY)
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 * GetTangents(const char *name)
This will first look for an array with the correct name.
int SetActiveTangents(const char *name)
Set/get the tangent data.
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)
Allocates point data for point-by-point (or cell-by-cell) copy operation.
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.
vtkFieldData::BasicIterator RequiredArrays
vtkDataArray * GetHigherOrderDegrees(const char *name)
This will first look for an array with the correct name.
vtkDataArray * GetScalars(const char *name)
This will first look for an array with the correct name.
vtkTypeBool GetCopyScalars(int ctype=ALLCOPY)
vtkDataArray * GetTCoords()
Set/Get the texture coordinate data.
static vtkDataSetAttributes * ExtendedNew()
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)
Set/get the normal data.
vtkDataArray * GetTangents()
Set/get the tangent data.
vtkAbstractArray * GetPedigreeIds(const char *name)
This will first look for an array with the correct name.
vtkDataArray * GetRationalWeights()
Set/Get the rational weights data.
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)
Set/Get the rational degrees data.
vtkDataArray * GetNormals()
Set/get the normal data.
int SetScalars(vtkDataArray *da)
Set/Get the scalar data.
vtkDataArray * GetNormals(const char *name)
This will first look for an array with the correct 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...
vtkDataArray * GetRationalWeights(const char *name)
This will first look for an array with the correct name.
int SetActiveTCoords(const char *name)
Set/Get the texture coordinate data.
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)
Copy a tuple (or set of tuples) of data from one data array to another.
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.
vtkDataArray * GetTensors()
Set/Get the tensor data.
int SetActiveGlobalIds(const char *name)
Set/Get the global id data.
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)
Set/Get the scalar data.
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...
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.
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)
vtkDataArray * GetTCoords(const char *name)
This will first look for an array with the correct name.
void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId)
Copy the attribute data from one id to another.
int SetActivePedigreeIds(const char *name)
Set/Get the pedigree id data.
vtkAbstractArray * GetPedigreeIds()
Set/Get the pedigree id data.
vtkDataArray * GetVectors()
Set/Get the vector data.
int SetActiveRationalWeights(const char *name)
Set/Get the rational weights data.
vtkAbstractArray * GetAbstractAttribute(int attributeType)
Return an attribute given the attribute type (see vtkDataSetAttributes::AttributeTypes).
void RemoveArray(int index) override
Remove an array (with the given name) from the list of arrays.
static const char * GhostArrayName()
vtkTypeBool GetCopyRationalWeights(int ctype=ALLCOPY)
vtkTypeBool GetCopyHigherOrderDegrees(int ctype=ALLCOPY)
vtkDataArray * GetAttribute(int attributeType)
Return an attribute given the attribute type (see vtkDataSetAttributes::AttributeTypes).
void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData, vtkIdType dstStart, vtkIdType n, vtkIdType srcStart)
Copy a tuple (or set of tuples) of data from one data array to another.
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)
static vtkDataSetAttributes * New()
Construct object with copying turned on for all data.
void CopyStructuredData(vtkDataSetAttributes *inDsa, const int *inExt, const int *outExt, bool setSize=true)
This method is used to copy data arrays in images.
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.
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).
static const char * GetAttributeTypeAsString(int attributeType)
Given an integer attribute type, this static method returns a string type for the attribute (i....
void GetAttributeIndices(int *indexArray)
Get the field data array indices corresponding to scalars, vectors, tensors, etc.
void SetCopyRationalWeights(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
void SetCopyTensors(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
int SetActiveAttribute(const char *name, int attributeType)
Make the array with the given name the active attribute.
int SetTCoords(vtkDataArray *da)
Set/Get the texture coordinate data.
void SetCopyHigherOrderDegrees(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
void InterpolateAllocate(vtkDataSetAttributes *pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays)
Initialize point interpolation method.
int SetPedigreeIds(vtkAbstractArray *da)
Set/Get the pedigree id data.
vtkTypeBool GetCopyTensors(int ctype=ALLCOPY)
void CopyData(vtkDataSetAttributes *fromPd, vtkIdList *fromIds, vtkIdList *toIds)
Copy the attribute data from one id to another.
int SetActiveVectors(const char *name)
Set/Get the vector data.
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.
vtkDataArray * GetGlobalIds(const char *name)
This will first look for an array with the correct name.
vtkDataArray * GetScalars()
Set/Get the scalar data.
vtkDataArray * GetHigherOrderDegrees()
Set/Get the rational degrees data.
int SetTangents(vtkDataArray *da)
Set/get the tangent data.
int SetActiveTensors(const char *name)
Set/Get the tensor data.
void SetCopyVectors(vtkTypeBool i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
vtkDataArray * GetVectors(const char *name)
This will first look for an array with the correct name.
int SetVectors(vtkDataArray *da)
Set/Get the vector data.
vtkDataArray * GetTensors(const char *name)
This will first look for an array with the correct name.
vtkDataArray * GetGlobalIds()
Set/Get the global id data.
int SetTensors(vtkDataArray *da)
Set/Get the tensor data.
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:64
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:40
a simple class to control print indentation
Definition: vtkIndent.h:43
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:332