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 =========================================================================*/
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  NUM_ATTRIBUTES
105  };
106 
108  {
111  NOLIMIT
112  };
113 
114  // ----------- ghost points and ghost cells -------------------------------------------
115  //The following bit fields are consistent with VisIt ghost zones specification
116  //For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
117 
119  {
120  DUPLICATECELL = 1, //the cell is present on multiple processors
121  HIGHCONNECTIVITYCELL = 2, //the cell has more neighbors than in a regular mesh
122  LOWCONNECTIVITYCELL = 4, //the cell has less neighbors than in a regular mesh
123  REFINEDCELL = 8, //other cells are present that refines it.
124  EXTERIORCELL = 16, //the cell is on the exterior of the data set
125  HIDDENCELL = 32 //the cell is needed to maintain connectivity, but the data values should be ignored.
126  };
127 
129  {
130  DUPLICATEPOINT =1, //the cell is present on multiple processors
131  HIDDENPOINT =2 //the point is needed to maintain connectivity, but the data values should be ignored.
132  };
133 
134  //A vtkDataArray with this name must be of type vtkUnsignedCharArray.
135  //Each value must be assigned according to the bit fields described in
136  //PointGhostTypes or CellGhostType
137  static const char* GhostArrayName() { return "vtkGhostType";}
138 
139  //-----------------------------------------------------------------------------------
140 
142 
145  int SetScalars(vtkDataArray* da);
146  int SetActiveScalars(const char* name);
147  vtkDataArray* GetScalars();
149 
151 
154  int SetVectors(vtkDataArray* da);
155  int SetActiveVectors(const char* name);
156  vtkDataArray* GetVectors();
158 
160 
163  int SetNormals(vtkDataArray* da);
164  int SetActiveNormals(const char* name);
165  vtkDataArray* GetNormals();
167 
169 
172  int SetTCoords(vtkDataArray* da);
173  int SetActiveTCoords(const char* name);
174  vtkDataArray* GetTCoords();
176 
178 
181  int SetTensors(vtkDataArray* da);
182  int SetActiveTensors(const char* name);
183  vtkDataArray* GetTensors();
185 
187 
190  int SetGlobalIds(vtkDataArray* da);
191  int SetActiveGlobalIds(const char* name);
192  vtkDataArray* GetGlobalIds();
194 
196 
199  int SetPedigreeIds(vtkAbstractArray* da);
200  int SetActivePedigreeIds(const char* name);
201  vtkAbstractArray* GetPedigreeIds();
203 
205 
210  vtkDataArray* GetScalars(const char* name);
211  vtkDataArray* GetVectors(const char* name);
212  vtkDataArray* GetNormals(const char* name);
213  vtkDataArray* GetTCoords(const char* name);
214  vtkDataArray* GetTensors(const char* name);
215  vtkDataArray* GetGlobalIds(const char* name);
216  vtkAbstractArray* GetPedigreeIds(const char* name);
218 
233  int SetActiveAttribute(const char* name, int attributeType);
234 
238  int SetActiveAttribute(int index, int attributeType);
239 
244  void GetAttributeIndices(int* indexArray);
245 
252  int IsArrayAnAttribute(int idx);
253 
276  int SetAttribute(vtkAbstractArray* aa, int attributeType);
277 
284  vtkDataArray* GetAttribute(int attributeType);
285 
293  vtkAbstractArray* GetAbstractAttribute(int attributeType);
294 
296 
300  void RemoveArray(int index) override;
302 
303 
305 
309  static const char* GetAttributeTypeAsString(int attributeType);
310  static const char* GetLongAttributeTypeAsString(int attributeType);
312 
313  // -- attribute copy properties ------------------------------------------
314 
316  {
317  COPYTUPLE=0,
318  INTERPOLATE=1,
319  PASSDATA=2,
320  ALLCOPY //all of the above
321  };
322 
344  void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
345 
350  int GetCopyAttribute (int index, int ctype);
351 
353  void SetCopyScalars(vtkTypeBool i, int ctype=ALLCOPY);
354  vtkTypeBool GetCopyScalars(int ctype=ALLCOPY);
355  vtkBooleanMacro(CopyScalars, vtkTypeBool);
356 
358  void SetCopyVectors(vtkTypeBool i, int ctype=ALLCOPY);
359  vtkTypeBool GetCopyVectors(int ctype=ALLCOPY);
360  vtkBooleanMacro(CopyVectors, vtkTypeBool);
361 
363  void SetCopyNormals(vtkTypeBool i, int ctype=ALLCOPY);
364  vtkTypeBool GetCopyNormals(int ctype=ALLCOPY);
365  vtkBooleanMacro(CopyNormals, vtkTypeBool);
366 
368  void SetCopyTCoords(vtkTypeBool i, int ctype=ALLCOPY);
369  vtkTypeBool GetCopyTCoords(int ctype=ALLCOPY);
370  vtkBooleanMacro(CopyTCoords, vtkTypeBool);
371 
373  void SetCopyTensors(vtkTypeBool i, int ctype=ALLCOPY);
374  vtkTypeBool GetCopyTensors(int ctype=ALLCOPY);
375  vtkBooleanMacro(CopyTensors, vtkTypeBool);
376 
378  void SetCopyGlobalIds(vtkTypeBool i, int ctype=ALLCOPY);
379  vtkTypeBool GetCopyGlobalIds(int ctype=ALLCOPY);
380  vtkBooleanMacro(CopyGlobalIds, vtkTypeBool);
381 
383  void SetCopyPedigreeIds(vtkTypeBool i, int ctype=ALLCOPY);
384  vtkTypeBool GetCopyPedigreeIds(int ctype=ALLCOPY);
385  vtkBooleanMacro(CopyPedigreeIds, vtkTypeBool);
386 
388  void CopyAllOn(int ctype=ALLCOPY) override;
389 
391  void CopyAllOff(int ctype=ALLCOPY) override;
392 
393  // -- passthrough operations ----------------------------------------------
394 
404  void PassData(vtkFieldData* fd) override;
405 
406  // -- copytuple operations ------------------------------------------------
407 
409 
421  vtkIdType ext=1000)
422  {
423  this->CopyAllocate(pd, sze, ext, 0);
424  }
425  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
426  vtkIdType ext, int shallowCopyArrays);
428 
436  void SetupForCopy(vtkDataSetAttributes* pd);
437 
438 
447  void CopyStructuredData(vtkDataSetAttributes *inDsa,
448  const int *inExt,
449  const int *outExt,
450  bool setSize = true);
451 
453 
463  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
464  void CopyData(vtkDataSetAttributes *fromPd,
465  vtkIdList *fromIds, vtkIdList *toIds);
467 
473  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType dstStart, vtkIdType n,
474  vtkIdType srcStart);
475 
477 
483  void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
484  vtkIdType fromId, vtkIdType toId);
485  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
486  vtkIdList *fromIds, vtkIdList *toIds);
487  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
488  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
490 
491 
492  // -- interpolate operations ----------------------------------------------
493 
495 
504  vtkIdType ext=1000)
505  {
506  this->InterpolateAllocate(pd, sze, ext, 0);
507  }
508  void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
509  vtkIdType ext, int shallowCopyArrays);
511 
519  void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
520  vtkIdList *ids, double *weights);
521 
531  void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
532  vtkIdType p1, vtkIdType p2, double t);
533 
546  void InterpolateTime(vtkDataSetAttributes *from1,
547  vtkDataSetAttributes *from2,
548  vtkIdType id, double t);
549 
551 
552  // field list copy operations ------------------------------------------
553 
558  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
559  vtkIdType ext=1000);
560 
567  void CopyData(vtkDataSetAttributes::FieldList& list,
568  vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
569  vtkIdType toId);
570  void CopyData(vtkDataSetAttributes::FieldList& list,
571  vtkDataSetAttributes* dsa, int idx, vtkIdType dstStart,
572  vtkIdType n, vtkIdType srcStart);
573 
580  void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
581  vtkIdType ext=1000);
582 
589  void InterpolatePoint(
591  vtkDataSetAttributes *fromPd,
592  int idx, vtkIdType toId,
593  vtkIdList *ids, double *weights);
594 
595 protected:
597  ~vtkDataSetAttributes() override;
598 
599  void InternalCopyAllocate(vtkDataSetAttributes* pd,
600  int ctype,
601  vtkIdType sze=0,
602  vtkIdType ext=1000,
603  int shallowCopyArrays=0,
604  bool createNewArrays=true);
605 
609  void InitializeFields() override;
610 
611  int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
612  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
613 
615 
617 
618  static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
619  static const int AttributeLimits[NUM_ATTRIBUTES];
620  static const char AttributeNames[NUM_ATTRIBUTES][12];
621  static const char LongAttributeNames[NUM_ATTRIBUTES][35];
622 
623 private:
624  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
625 
626  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
627 
628 private:
630  void operator=(const vtkDataSetAttributes&) = delete;
631 
633 };
634 
635 #endif
vtkDataSetAttributes::AttributeLimitTypes
AttributeLimitTypes
Definition: vtkDataSetAttributes.h:107
vtkDataSetAttributes::MAX
Definition: vtkDataSetAttributes.h:109
vtkX3D::value
Definition: vtkX3D.h:220
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkDataSetAttributes::GhostArrayName
static const char * GhostArrayName()
Definition: vtkDataSetAttributes.h:137
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:53
vtkFieldData::CopyAllOn
virtual void CopyAllOn(int unused=0)
Turn on copying of all data.
vtkFieldData::BasicIterator
Definition: vtkFieldData.h:399
vtkFieldData::DeepCopy
virtual void DeepCopy(vtkFieldData *da)
Copy a field by creating new data arrays (i.e., duplicate storage).
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkFieldData::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkDataSetAttributes::PointGhostTypes
PointGhostTypes
Definition: vtkDataSetAttributes.h:128
vtkDataSetAttributes::AttributeTypes
AttributeTypes
Definition: vtkDataSetAttributes.h:94
vtkDataSetAttributes::CellGhostTypes
CellGhostTypes
Definition: vtkDataSetAttributes.h:118
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:53
vtkFieldData.h
vtkDataSetAttributes::TargetIndices
int * TargetIndices
Definition: vtkDataSetAttributes.h:616
vtkDataSetAttributes::Update
virtual void Update()
Attributes have a chance to bring themselves up to date; right now this is ignored.
Definition: vtkDataSetAttributes.h:74
vtkDataSetAttributes::RequiredArrays
vtkFieldData::BasicIterator RequiredArrays
Definition: vtkDataSetAttributes.h:614
vtkFieldData::CopyAllOff
virtual void CopyAllOff(int unused=0)
Turn off copying of all data.
vtkDataSetAttributesFieldList
helps manage arrays from multiple vtkDataSetAttributes.
Definition: vtkDataSetAttributesFieldList.h:70
vtkFieldData::RemoveArray
virtual void RemoveArray(const char *name)
Remove an array (with the given name or index) from the list of arrays.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
vtkFieldData::InitializeFields
virtual void InitializeFields()
Release all data but do not delete object.
vtkX3D::name
Definition: vtkX3D.h:219
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:75
vtkLookupTable
map scalar values into colors via a lookup table
Definition: vtkLookupTable.h:68
vtkDataSetAttributesFieldList.h
vtkFieldData::PassData
virtual void PassData(vtkFieldData *fd)
Pass entire arrays of input data through to output.
vtkDataSetAttributes::InterpolateAllocate
void InterpolateAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
Initialize point interpolation method.
Definition: vtkDataSetAttributes.h:503
vtkFieldData::ShallowCopy
virtual void ShallowCopy(vtkFieldData *da)
Copy a field by reference counting the data arrays.
vtkDataSetAttributes::CopyAllocate
void CopyAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
Allocates point data for point-by-point (or cell-by-cell) copy operation.
Definition: vtkDataSetAttributes.h:420
vtkDataSetAttributes::AttributeCopyOperations
AttributeCopyOperations
Definition: vtkDataSetAttributes.h:315
vtkFieldData::Initialize
virtual void Initialize()
Release all data but do not delete object.
vtkX3D::index
Definition: vtkX3D.h:246
vtkDataSetAttributes::EXACT
Definition: vtkDataSetAttributes.h:110
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkFieldData::New
static vtkFieldData * New()