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 "vtkDataSetAttributesFieldList.h" // for vtkDataSetAttributesFieldList
55 #include "vtkFieldData.h"
56 
57 class vtkLookupTable;
58 
59 class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributes : public vtkFieldData
60 {
61 public:
65  static vtkDataSetAttributes *New();
66 
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
74  void Initialize() override;
75 
80  virtual void Update() {}
81 
82  // -- shallow and deep copy -----------------------------------------------
83 
89  void DeepCopy(vtkFieldData *pd) override;
90 
95  void ShallowCopy(vtkFieldData *pd) override;
96 
97  // -- attribute types -----------------------------------------------------
98 
99  // Always keep NUM_ATTRIBUTES as the last entry
101  {
102  SCALARS=0,
103  VECTORS=1,
104  NORMALS=2,
105  TCOORDS=3,
106  TENSORS=4,
107  GLOBALIDS=5,
108  PEDIGREEIDS=6,
109  EDGEFLAG=7,
110  NUM_ATTRIBUTES
111  };
112 
114  {
117  NOLIMIT
118  };
119 
120  // ----------- ghost points and ghost cells -------------------------------------------
121  //The following bit fields are consistent with VisIt ghost zones specification
122  //For details, see http://www.visitusers.org/index.php?title=Representing_ghost_data
123 
125  {
126  DUPLICATECELL = 1, //the cell is present on multiple processors
127  HIGHCONNECTIVITYCELL = 2, //the cell has more neighbors than in a regular mesh
128  LOWCONNECTIVITYCELL = 4, //the cell has less neighbors than in a regular mesh
129  REFINEDCELL = 8, //other cells are present that refines it.
130  EXTERIORCELL = 16, //the cell is on the exterior of the data set
131  HIDDENCELL = 32 //the cell is needed to maintain connectivity, but the data values should be ignored.
132  };
133 
135  {
136  DUPLICATEPOINT =1, //the cell is present on multiple processors
137  HIDDENPOINT =2 //the point is needed to maintain connectivity, but the data values should be ignored.
138  };
139 
140  //A vtkDataArray with this name must be of type vtkUnsignedCharArray.
141  //Each value must be assigned according to the bit fields described in
142  //PointGhostTypes or CellGhostType
143  static const char* GhostArrayName() { return "vtkGhostType";}
144 
145  //-----------------------------------------------------------------------------------
146 
148 
151  int SetScalars(vtkDataArray* da);
152  int SetActiveScalars(const char* name);
153  vtkDataArray* GetScalars();
155 
157 
160  int SetVectors(vtkDataArray* da);
161  int SetActiveVectors(const char* name);
162  vtkDataArray* GetVectors();
164 
166 
169  int SetNormals(vtkDataArray* da);
170  int SetActiveNormals(const char* name);
171  vtkDataArray* GetNormals();
173 
175 
178  int SetTCoords(vtkDataArray* da);
179  int SetActiveTCoords(const char* name);
180  vtkDataArray* GetTCoords();
182 
184 
187  int SetTensors(vtkDataArray* da);
188  int SetActiveTensors(const char* name);
189  vtkDataArray* GetTensors();
191 
193 
196  int SetGlobalIds(vtkDataArray* da);
197  int SetActiveGlobalIds(const char* name);
198  vtkDataArray* GetGlobalIds();
200 
202 
205  int SetPedigreeIds(vtkAbstractArray* da);
206  int SetActivePedigreeIds(const char* name);
207  vtkAbstractArray* GetPedigreeIds();
209 
211 
216  vtkDataArray* GetScalars(const char* name);
217  vtkDataArray* GetVectors(const char* name);
218  vtkDataArray* GetNormals(const char* name);
219  vtkDataArray* GetTCoords(const char* name);
220  vtkDataArray* GetTensors(const char* name);
221  vtkDataArray* GetGlobalIds(const char* name);
222  vtkAbstractArray* GetPedigreeIds(const char* name);
224 
239  int SetActiveAttribute(const char* name, int attributeType);
240 
244  int SetActiveAttribute(int index, int attributeType);
245 
250  void GetAttributeIndices(int* indexArray);
251 
258  int IsArrayAnAttribute(int idx);
259 
282  int SetAttribute(vtkAbstractArray* aa, int attributeType);
283 
290  vtkDataArray* GetAttribute(int attributeType);
291 
299  vtkAbstractArray* GetAbstractAttribute(int attributeType);
300 
302 
306  void RemoveArray(int index) override;
308 
309 
311 
315  static const char* GetAttributeTypeAsString(int attributeType);
316  static const char* GetLongAttributeTypeAsString(int attributeType);
318 
319  // -- attribute copy properties ------------------------------------------
320 
322  {
323  COPYTUPLE=0,
324  INTERPOLATE=1,
325  PASSDATA=2,
326  ALLCOPY //all of the above
327  };
328 
350  void SetCopyAttribute (int index, int value, int ctype=ALLCOPY);
351 
356  int GetCopyAttribute (int index, int ctype);
357 
359  void SetCopyScalars(vtkTypeBool i, int ctype=ALLCOPY);
360  vtkTypeBool GetCopyScalars(int ctype=ALLCOPY);
361  vtkBooleanMacro(CopyScalars, vtkTypeBool);
362 
364  void SetCopyVectors(vtkTypeBool i, int ctype=ALLCOPY);
365  vtkTypeBool GetCopyVectors(int ctype=ALLCOPY);
366  vtkBooleanMacro(CopyVectors, vtkTypeBool);
367 
369  void SetCopyNormals(vtkTypeBool i, int ctype=ALLCOPY);
370  vtkTypeBool GetCopyNormals(int ctype=ALLCOPY);
371  vtkBooleanMacro(CopyNormals, vtkTypeBool);
372 
374  void SetCopyTCoords(vtkTypeBool i, int ctype=ALLCOPY);
375  vtkTypeBool GetCopyTCoords(int ctype=ALLCOPY);
376  vtkBooleanMacro(CopyTCoords, vtkTypeBool);
377 
379  void SetCopyTensors(vtkTypeBool i, int ctype=ALLCOPY);
380  vtkTypeBool GetCopyTensors(int ctype=ALLCOPY);
381  vtkBooleanMacro(CopyTensors, vtkTypeBool);
382 
384  void SetCopyGlobalIds(vtkTypeBool i, int ctype=ALLCOPY);
385  vtkTypeBool GetCopyGlobalIds(int ctype=ALLCOPY);
386  vtkBooleanMacro(CopyGlobalIds, vtkTypeBool);
387 
389  void SetCopyPedigreeIds(vtkTypeBool i, int ctype=ALLCOPY);
390  vtkTypeBool GetCopyPedigreeIds(int ctype=ALLCOPY);
391  vtkBooleanMacro(CopyPedigreeIds, vtkTypeBool);
392 
394  void CopyAllOn(int ctype=ALLCOPY) override;
395 
397  void CopyAllOff(int ctype=ALLCOPY) override;
398 
399  // -- passthrough operations ----------------------------------------------
400 
410  void PassData(vtkFieldData* fd) override;
411 
412  // -- copytuple operations ------------------------------------------------
413 
415 
427  vtkIdType ext=1000)
428  {
429  this->CopyAllocate(pd, sze, ext, 0);
430  }
431  void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
432  vtkIdType ext, int shallowCopyArrays);
434 
442  void SetupForCopy(vtkDataSetAttributes* pd);
443 
444 
453  void CopyStructuredData(vtkDataSetAttributes *inDsa,
454  const int *inExt,
455  const int *outExt,
456  bool setSize = true);
457 
459 
469  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
470  void CopyData(vtkDataSetAttributes *fromPd,
471  vtkIdList *fromIds, vtkIdList *toIds);
473 
479  void CopyData(vtkDataSetAttributes *fromPd, vtkIdType dstStart, vtkIdType n,
480  vtkIdType srcStart);
481 
483 
489  void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData,
490  vtkIdType fromId, vtkIdType toId);
491  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
492  vtkIdList *fromIds, vtkIdList *toIds);
493  void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData,
494  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart);
496 
497 
498  // -- interpolate operations ----------------------------------------------
499 
501 
510  vtkIdType ext=1000)
511  {
512  this->InterpolateAllocate(pd, sze, ext, 0);
513  }
514  void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze,
515  vtkIdType ext, int shallowCopyArrays);
517 
525  void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId,
526  vtkIdList *ids, double *weights);
527 
537  void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
538  vtkIdType p1, vtkIdType p2, double t);
539 
552  void InterpolateTime(vtkDataSetAttributes *from1,
553  vtkDataSetAttributes *from2,
554  vtkIdType id, double t);
555 
557 
558  // field list copy operations ------------------------------------------
559 
564  void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
565  vtkIdType ext=1000);
566 
573  void CopyData(vtkDataSetAttributes::FieldList& list,
574  vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
575  vtkIdType toId);
576  void CopyData(vtkDataSetAttributes::FieldList& list,
577  vtkDataSetAttributes* dsa, int idx, vtkIdType dstStart,
578  vtkIdType n, vtkIdType srcStart);
579 
586  void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0,
587  vtkIdType ext=1000);
588 
595  void InterpolatePoint(
597  vtkDataSetAttributes *fromPd,
598  int idx, vtkIdType toId,
599  vtkIdList *ids, double *weights);
600 
601 protected:
603  ~vtkDataSetAttributes() override;
604 
605  void InternalCopyAllocate(vtkDataSetAttributes* pd,
606  int ctype,
607  vtkIdType sze=0,
608  vtkIdType ext=1000,
609  int shallowCopyArrays=0,
610  bool createNewArrays=true);
611 
615  void InitializeFields() override;
616 
617  int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
618  int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data
619 
621 
623 
624  static const int NumberOfAttributeComponents[NUM_ATTRIBUTES];
625  static const int AttributeLimits[NUM_ATTRIBUTES];
626  static const char AttributeNames[NUM_ATTRIBUTES][12];
627  static const char LongAttributeNames[NUM_ATTRIBUTES][35];
628 
629 private:
630  static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType);
631 
632  vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype);
633 
634 private:
636  void operator=(const vtkDataSetAttributes&) = delete;
637 
639 };
640 
641 #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.
virtual void CopyAllOn(int unused=0)
Turn on copying of all data.
int vtkIdType
Definition: vtkType.h:347
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:36
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:54
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:56