VTK
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=========================================================================*/
50#ifndef vtkDataSetAttributes_h
51#define vtkDataSetAttributes_h
52
53#include "vtkCommonDataModelModule.h" // For export macro
54#include "vtkFieldData.h"
55
56class vtkLookupTable;
57
58class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributes : public vtkFieldData
59{
60public:
65
67 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
68
73 void Initialize() VTK_OVERRIDE;
74
79 virtual void Update() {}
80
81 // -- shallow and deep copy -----------------------------------------------
82
88 void DeepCopy(vtkFieldData *pd) VTK_OVERRIDE;
89
94 void ShallowCopy(vtkFieldData *pd) VTK_OVERRIDE;
95
96 // -- attribute types -----------------------------------------------------
97
98 // Always keep NUM_ATTRIBUTES as the last entry
100 {
101 SCALARS=0,
102 VECTORS=1,
103 NORMALS=2,
104 TCOORDS=3,
105 TENSORS=4,
106 GLOBALIDS=5,
107 PEDIGREEIDS=6,
108 EDGEFLAG=7,
109 NUM_ATTRIBUTES
110 };
111
113 {
116 NOLIMIT
117 };
118
119 // ----------- ghost points and ghost cells -------------------------------------------
120 //The following bit fields are consistent with VisIt ghost zones specification
121 //For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
122
124 {
125 DUPLICATECELL = 1, //the cell is present on multiple processors
126 HIGHCONNECTIVITYCELL = 2, //the cell has more neighbors than in a regular mesh
127 LOWCONNECTIVITYCELL = 4, //the cell has less neighbors than in a regular mesh
128 REFINEDCELL = 8, //other cells are present that refines it.
129 EXTERIORCELL = 16, //the cell is on the exterior of the data set
130 HIDDENCELL = 32 //the cell is needed to maintain connectivity, but the data values should be ignored.
131 };
132
134 {
135 DUPLICATEPOINT =1, //the cell is present on multiple processors
136 HIDDENPOINT =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 SetActiveTCoords(const char* name);
181
183
187 int SetActiveTensors(const char* name);
190
192
196 int SetActiveGlobalIds(const char* name);
199
201
205 int SetActivePedigreeIds(const char* name);
208
210
223
238 int SetActiveAttribute(const char* name, int attributeType);
239
243 int SetActiveAttribute(int index, int attributeType);
244
249 void GetAttributeIndices(int* indexArray);
250
257 int IsArrayAnAttribute(int idx);
258
281 int SetAttribute(vtkAbstractArray* aa, int attributeType);
282
289 vtkDataArray* GetAttribute(int attributeType);
290
299
301
305 void RemoveArray(int index) VTK_OVERRIDE;
307
308
310
314 static const char* GetAttributeTypeAsString(int attributeType);
315 static const char* GetLongAttributeTypeAsString(int attributeType);
317
318 // -- attribute copy properties ------------------------------------------
319
321 {
322 COPYTUPLE=0,
323 INTERPOLATE=1,
324 PASSDATA=2,
325 ALLCOPY //all of the above
326 };
327
349 void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
350
355 int GetCopyAttribute (int index, int ctype);
356
358 void SetCopyScalars(int i, int ctype=ALLCOPY);
359 int GetCopyScalars(int ctype=ALLCOPY);
360 vtkBooleanMacro(CopyScalars, int);
361
363 void SetCopyVectors(int i, int ctype=ALLCOPY);
364 int GetCopyVectors(int ctype=ALLCOPY);
365 vtkBooleanMacro(CopyVectors, int);
366
368 void SetCopyNormals(int i, int ctype=ALLCOPY);
369 int GetCopyNormals(int ctype=ALLCOPY);
370 vtkBooleanMacro(CopyNormals, int);
371
373 void SetCopyTCoords(int i, int ctype=ALLCOPY);
374 int GetCopyTCoords(int ctype=ALLCOPY);
375 vtkBooleanMacro(CopyTCoords, int);
376
378 void SetCopyTensors(int i, int ctype=ALLCOPY);
379 int GetCopyTensors(int ctype=ALLCOPY);
380 vtkBooleanMacro(CopyTensors, int);
381
383 void SetCopyGlobalIds(int i, int ctype=ALLCOPY);
384 int GetCopyGlobalIds(int ctype=ALLCOPY);
385 vtkBooleanMacro(CopyGlobalIds, int);
386
388 void SetCopyPedigreeIds(int i, int ctype=ALLCOPY);
389 int GetCopyPedigreeIds(int ctype=ALLCOPY);
390 vtkBooleanMacro(CopyPedigreeIds, int);
391
393 void CopyAllOn(int ctype=ALLCOPY) VTK_OVERRIDE;
394
396 void CopyAllOff(int ctype=ALLCOPY) VTK_OVERRIDE;
397
398 // -- passthrough operations ----------------------------------------------
399
409 void PassData(vtkFieldData* fd) VTK_OVERRIDE;
410
411 // -- copytuple operations ------------------------------------------------
412
414
426 vtkIdType ext=1000)
427 {
428 this->CopyAllocate(pd, sze, ext, 0);
429 }
431 vtkIdType ext, int shallowCopyArrays);
433
439 const int *inExt, const int *outExt);
440
442
454 vtkIdList *fromIds, vtkIdList *toIds);
456
463 vtkIdType srcStart);
464
466
473 vtkIdType fromId, vtkIdType toId);
475 vtkIdList *fromIds, vtkIdList *toIds);
477 vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
479
480
481 // -- interpolate operations ----------------------------------------------
482
484
493 vtkIdType ext=1000)
494 {
495 this->InterpolateAllocate(pd, sze, ext, 0);
496 }
498 vtkIdType ext, int shallowCopyArrays);
500
509 vtkIdList *ids, double *weights);
510
521 vtkIdType p1, vtkIdType p2, double t);
522
537 vtkIdType id, double t);
538
539 class FieldList;
540
541 // field list copy operations ------------------------------------------
542
548 vtkIdType ext=1000);
549
557 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
558 vtkIdType toId);
559
567 vtkIdType ext=1000);
568
577 vtkDataSetAttributes *fromPd,
578 int idx, vtkIdType toId,
579 vtkIdList *ids, double *weights);
580
582
583protected:
585 ~vtkDataSetAttributes() VTK_OVERRIDE;
586
588 int ctype,
589 vtkIdType sze=0,
590 vtkIdType ext=1000,
591 int shallowCopyArrays=0);
592
595 int ctype,
596 vtkIdType sze, vtkIdType ext);
597
601 void InitializeFields() VTK_OVERRIDE;
602
603 int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
604 int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
605
607
609
612 static const char AttributeNames[NUM_ATTRIBUTES][12];
613 static const char LongAttributeNames[NUM_ATTRIBUTES][35];
614
615private:
616 static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
617
618 vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
619
620private:
621 vtkDataSetAttributes(const vtkDataSetAttributes&) VTK_DELETE_FUNCTION;
622 void operator=(const vtkDataSetAttributes&) VTK_DELETE_FUNCTION;
623
624public:
625 // This public class is used to perform set operations, other misc.
626 // operations on fields. For example, vtkAppendFilter uses it to
627 // determine which attributes the input datasets share in common.
628 class vtkInternalComponentNames;
629 class VTKCOMMONDATAMODEL_EXPORT FieldList
630 {
631 public:
632 FieldList(int numInputs);
634 void PrintSelf(ostream &os, vtkIndent indent);
635
638
647
648 //Determine whether data is available
649 int IsAttributePresent(int attrType); //true/false attributes specified
650
651 // Accessor methods.
652 int GetNumberOfFields() { return this->NumberOfFields; }
653 int GetFieldIndex(int i) { return this->FieldIndices[i]; }
654 const char* GetFieldName(int i) { return this->Fields[i]; }
655 int GetFieldComponents(int i) { return this->FieldComponents[i]; }
656 int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; }
657
659
660 protected:
661 void SetFieldIndex(int i, int index)
662 { this->FieldIndices[i] = index; }
663 private:
664 FieldList(const FieldList&) VTK_DELETE_FUNCTION;
665 void operator=(const FieldList&) VTK_DELETE_FUNCTION;
666
667 void SetField(int index, vtkAbstractArray *da);
668 void RemoveField(const char *name);
669 void ClearFields();
670 void GrowBy(unsigned int delta);
671
672 int NumberOfFields; //the number of fields (including five named attributes)
673 // These keep track of what is common across datasets. The first
674 // six items are always named attributes.
675 char** Fields; // the names of the fields
676 int *FieldTypes; // the types of the fields
677 int *FieldComponents; // the number of components in field
678 int *FieldIndices; // output data array index
679 vtkLookupTable **LUT; // luts associated with each array
680 vtkInformation **FieldInformation; // Information map associated with each array
681
682 vtkInternalComponentNames **FieldComponentsNames; // the name for each component in the field
683
684 vtkIdType NumberOfTuples; // a running total of values
685
686 //For every vtkDataSetAttributes that are processed, keep track of the
687 //indices into various things. The indices are organized so that the
688 //first NUM_ATTRIBUTES refer to attributes, the next refer to the
689 //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
690 //CurrentInput is the current input being processed.
691 int **DSAIndices;
692 int NumberOfDSAIndices;
693 int CurrentInput;
694
695 };
696
697};
698
699#endif
Abstract superclass for all arrays.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
void IntersectFieldList(vtkDataSetAttributes *dsa)
void SetFieldIndex(int i, int index)
void InitializeFieldList(vtkDataSetAttributes *dsa)
void PrintSelf(ostream &os, vtkIndent indent)
void UnionFieldList(vtkDataSetAttributes *dsa)
Similar to IntersectFieldList() except that it builds a union of the array list.
int IsAttributePresent(int attrType)
represent and manipulate attribute data in a dataset
static const char * GetLongAttributeTypeAsString(int attributeType)
int AttributeIndices[NUM_ATTRIBUTES]
void PassData(vtkFieldData *fd) override
Pass entire arrays of input data through to output.
void SetCopyNormals(int i, int ctype=ALLCOPY)
Turn on/off the copying of attribute 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)
void Initialize() override
Initialize all of the object's data to NULL 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 * GetScalars(const char *name)
This will first look for an array with the correct name.
vtkDataArray * GetTCoords()
void SetCopyScalars(int i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
int GetCopyPedigreeIds(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
void SetCopyTensors(int i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
int SetActiveNormals(const char *name)
static const int NumberOfAttributeComponents[NUM_ATTRIBUTES]
vtkAbstractArray * GetPedigreeIds(const char *name)
void InternalCopyAllocate(vtkDataSetAttributes *pd, int ctype, vtkIdType sze=0, vtkIdType ext=1000, int shallowCopyArrays=0)
void InterpolateAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
Initialize point interpolation method.
vtkDataArray * GetNormals()
int SetScalars(vtkDataArray *da)
Set/Get the scalar data.
vtkDataArray * GetNormals(const char *name)
static const char LongAttributeNames[NUM_ATTRIBUTES][35]
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...
int SetActiveTCoords(const char *name)
void SetCopyGlobalIds(int i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
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 InitializeFields() override
Initialize all of the object's data to NULL.
int GetCopyScalars(int ctype=ALLCOPY)
vtkDataArray * GetTensors()
void SetCopyTCoords(int i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
int SetActiveGlobalIds(const char *name)
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...
void SetCopyPedigreeIds(int i, int ctype=ALLCOPY)
Turn on/off the copying of attribute data.
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)
A special form of CopyData() to be used with FieldLists.
void CopyAllOn(int ctype=ALLCOPY) override
Turn on/off the copying of attribute data.
int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]
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.
int GetCopyTCoords(int ctype=ALLCOPY)
int IsArrayAnAttribute(int idx)
Determine whether a data array of index idx is considered a data set attribute (i....
void CopyStructuredData(vtkDataSetAttributes *inDsa, const int *inExt, const int *outExt)
This method is used to copy data arrays in images.
vtkDataArray * GetTCoords(const char *name)
void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId)
Copy the attribute data from one id to another.
int SetActivePedigreeIds(const char *name)
vtkAbstractArray * GetPedigreeIds()
vtkDataArray * GetVectors()
static const char AttributeNames[NUM_ATTRIBUTES][12]
vtkAbstractArray * GetAbstractAttribute(int attributeType)
Return an attribute given the attribute type (see vtkDataSetAttributes::AttributeTypes).
void RemoveArray(int index) override
static const char * GhostArrayName()
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)
static vtkDataSetAttributes * New()
Construct object with copying turned on for all data.
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).
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.
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.
int GetCopyVectors(int ctype=ALLCOPY)
int GetCopyTensors(int ctype=ALLCOPY)
void InterpolateAllocate(vtkDataSetAttributes *pd, vtkIdType sze, vtkIdType ext, int shallowCopyArrays)
int SetPedigreeIds(vtkAbstractArray *da)
Set/Get the pedigree id data.
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 CopyAllOff(int ctype=ALLCOPY) override
Turn on/off the copying of attribute data.
vtkDataArray * GetGlobalIds(const char *name)
vtkDataArray * GetScalars()
int GetCopyNormals(int ctype=ALLCOPY)
int SetActiveTensors(const char *name)
static const int AttributeLimits[NUM_ATTRIBUTES]
vtkDataArray * GetVectors(const char *name)
int SetVectors(vtkDataArray *da)
Set/Get the vector data.
vtkDataArray * GetTensors(const char *name)
vtkDataArray * GetGlobalIds()
int GetCopyGlobalIds(int ctype=ALLCOPY)
int SetTensors(vtkDataArray *da)
Set/Get the tensor data.
void SetCopyVectors(int i, int ctype=ALLCOPY)
Turn on/off the copying of attribute 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:57
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:37
a simple class to control print indentation
Definition: vtkIndent.h:40
Store vtkAlgorithm input/output information.
map scalar values into colors via a lookup table
@ value
Definition: vtkX3D.h:220
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
virtual void Update()
Updates the extensions string.
int vtkIdType
Definition: vtkType.h:287