VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkDataSetAttributes.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00049 #ifndef __vtkDataSetAttributes_h 00050 #define __vtkDataSetAttributes_h 00051 00052 #include "vtkCommonDataModelModule.h" // For export macro 00053 #include "vtkFieldData.h" 00054 00055 class vtkLookupTable; 00056 00057 class VTKCOMMONDATAMODEL_EXPORT vtkDataSetAttributes : public vtkFieldData 00058 { 00059 public: 00061 static vtkDataSetAttributes *New(); 00062 00063 vtkTypeMacro(vtkDataSetAttributes,vtkFieldData); 00064 void PrintSelf(ostream& os, vtkIndent indent); 00065 00068 virtual void Initialize(); 00069 00072 virtual void Update() {} 00073 00074 // -- shallow and deep copy ----------------------------------------------- 00075 00078 virtual void DeepCopy(vtkFieldData *pd); 00079 00082 virtual void ShallowCopy(vtkFieldData *pd); 00083 00084 // -- attribute types ----------------------------------------------------- 00085 //BTX 00086 // Always keep NUM_ATTRIBUTES as the last entry 00087 enum AttributeTypes 00088 { 00089 SCALARS=0, 00090 VECTORS=1, 00091 NORMALS=2, 00092 TCOORDS=3, 00093 TENSORS=4, 00094 GLOBALIDS=5, 00095 PEDIGREEIDS=6, 00096 EDGEFLAG=7, 00097 NUM_ATTRIBUTES 00098 }; 00099 00100 enum AttributeLimitTypes 00101 { 00102 MAX, 00103 EXACT, 00104 NOLIMIT 00105 }; 00106 //ETX 00107 00109 00110 int SetScalars(vtkDataArray* da); 00111 int SetActiveScalars(const char* name); 00112 vtkDataArray* GetScalars(); 00114 00116 00117 int SetVectors(vtkDataArray* da); 00118 int SetActiveVectors(const char* name); 00119 vtkDataArray* GetVectors(); 00121 00123 00124 int SetNormals(vtkDataArray* da); 00125 int SetActiveNormals(const char* name); 00126 vtkDataArray* GetNormals(); 00128 00130 00131 int SetTCoords(vtkDataArray* da); 00132 int SetActiveTCoords(const char* name); 00133 vtkDataArray* GetTCoords(); 00135 00137 00138 int SetTensors(vtkDataArray* da); 00139 int SetActiveTensors(const char* name); 00140 vtkDataArray* GetTensors(); 00142 00144 00145 int SetGlobalIds(vtkDataArray* da); 00146 int SetActiveGlobalIds(const char* name); 00147 vtkDataArray* GetGlobalIds(); 00149 00151 00152 int SetPedigreeIds(vtkAbstractArray* da); 00153 int SetActivePedigreeIds(const char* name); 00154 vtkAbstractArray* GetPedigreeIds(); 00156 00158 00161 vtkDataArray* GetScalars(const char* name); 00162 vtkDataArray* GetVectors(const char* name); 00163 vtkDataArray* GetNormals(const char* name); 00164 vtkDataArray* GetTCoords(const char* name); 00165 vtkDataArray* GetTensors(const char* name); 00166 vtkDataArray* GetGlobalIds(const char* name); 00167 vtkAbstractArray* GetPedigreeIds(const char* name); 00169 00177 int SetActiveAttribute(const char* name, int attributeType); 00178 00180 int SetActiveAttribute(int index, int attributeType); 00181 00184 void GetAttributeIndices(int* indexArray); 00185 00190 int IsArrayAnAttribute(int idx); 00191 00196 vtkDataArray* GetAttribute(int attributeType); 00197 00203 vtkAbstractArray* GetAbstractAttribute(int attributeType); 00204 00206 00207 virtual void RemoveArray(const char *name); 00208 virtual void RemoveArray(int index); 00210 00211 00213 00215 static const char* GetAttributeTypeAsString(int attributeType); 00216 static const char* GetLongAttributeTypeAsString(int attributeType); 00218 00219 // -- attribute copy properties ------------------------------------------ 00220 00221 //BTX 00222 enum AttributeCopyOperations 00223 { 00224 COPYTUPLE=0, 00225 INTERPOLATE=1, 00226 PASSDATA=2, 00227 ALLCOPY //all of the above 00228 }; 00229 //ETX 00230 00235 void SetCopyAttribute (int index, int value, int ctype=ALLCOPY); 00236 00238 00249 void SetCopyScalars(int i, int ctype=ALLCOPY); 00250 int GetCopyScalars(int ctype=ALLCOPY); 00251 vtkBooleanMacro(CopyScalars, int); 00253 00255 00266 void SetCopyVectors(int i, int ctype=ALLCOPY); 00267 int GetCopyVectors(int ctype=ALLCOPY); 00268 vtkBooleanMacro(CopyVectors, int); 00270 00272 00283 void SetCopyNormals(int i, int ctype=ALLCOPY); 00284 int GetCopyNormals(int ctype=ALLCOPY); 00285 vtkBooleanMacro(CopyNormals, int); 00287 00289 00300 void SetCopyTCoords(int i, int ctype=ALLCOPY); 00301 int GetCopyTCoords(int ctype=ALLCOPY); 00302 vtkBooleanMacro(CopyTCoords, int); 00304 00306 00317 void SetCopyTensors(int i, int ctype=ALLCOPY); 00318 int GetCopyTensors(int ctype=ALLCOPY); 00319 vtkBooleanMacro(CopyTensors, int); 00321 00323 00334 void SetCopyGlobalIds(int i, int ctype=ALLCOPY); 00335 int GetCopyGlobalIds(int ctype=ALLCOPY); 00336 vtkBooleanMacro(CopyGlobalIds, int); 00338 00340 00351 void SetCopyPedigreeIds(int i, int ctype=ALLCOPY); 00352 int GetCopyPedigreeIds(int ctype=ALLCOPY); 00353 vtkBooleanMacro(CopyPedigreeIds, int); 00355 00367 virtual void CopyAllOn(int ctype=ALLCOPY); 00368 00380 virtual void CopyAllOff(int ctype=ALLCOPY); 00381 00382 // -- passthrough operations ---------------------------------------------- 00383 00391 virtual void PassData(vtkFieldData* fd); 00392 00393 // -- copytuple operations ------------------------------------------------ 00394 00396 00404 void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0, 00405 vtkIdType ext=1000) 00406 { 00407 this->CopyAllocate(pd, sze, ext, 0); 00408 } 00409 void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze, 00410 vtkIdType ext, int shallowCopyArrays); 00412 00414 00416 void CopyStructuredData(vtkDataSetAttributes *inDsa, 00417 const int *inExt, const int *outExt); 00419 00421 00428 void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId); 00429 void CopyData(vtkDataSetAttributes *fromPd, 00430 vtkIdList *fromIds, vtkIdList *toIds); 00432 00434 00438 void CopyTuple(vtkAbstractArray *fromData, vtkAbstractArray *toData, 00439 vtkIdType fromId, vtkIdType toId); 00440 void CopyTuples(vtkAbstractArray *fromData, vtkAbstractArray *toData, 00441 vtkIdList *fromIds, vtkIdList *toIds); 00443 00444 00445 // -- interpolate operations ---------------------------------------------- 00446 00448 00453 void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0, 00454 vtkIdType ext=1000) 00455 { 00456 this->InterpolateAllocate(pd, sze, ext, 0); 00457 } 00458 void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze, 00459 vtkIdType ext, int shallowCopyArrays); 00461 00463 00468 void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId, 00469 vtkIdList *ids, double *weights); 00471 00473 00480 void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId, 00481 vtkIdType p1, vtkIdType p2, double t); 00483 00485 00495 void InterpolateTime(vtkDataSetAttributes *from1, 00496 vtkDataSetAttributes *from2, 00497 vtkIdType id, double t); 00499 00500 //BTX 00501 class FieldList; 00502 00503 // field list copy operations ------------------------------------------ 00504 00506 00508 void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 00509 vtkIdType ext=1000); 00511 00513 00517 void CopyData(vtkDataSetAttributes::FieldList& list, 00518 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId, 00519 vtkIdType toId); 00521 00523 00528 void InterpolateAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 00529 vtkIdType ext=1000); 00531 00533 00537 void InterpolatePoint( 00538 vtkDataSetAttributes::FieldList& list, 00539 vtkDataSetAttributes *fromPd, 00540 int idx, vtkIdType toId, 00541 vtkIdList *ids, double *weights); 00543 00544 friend class vtkDataSetAttributes::FieldList; 00545 //ETX 00546 00547 //BTX 00548 protected: 00549 vtkDataSetAttributes(); 00550 ~vtkDataSetAttributes(); 00551 00552 void InternalCopyAllocate(vtkDataSetAttributes* pd, 00553 int ctype, 00554 vtkIdType sze=0, 00555 vtkIdType ext=1000, 00556 int shallowCopyArrays=0); 00557 00558 void InternalCopyAllocate( 00559 vtkDataSetAttributes::FieldList& list, 00560 int ctype, 00561 vtkIdType sze, vtkIdType ext); 00562 00564 virtual void InitializeFields(); 00565 00566 int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data 00567 int CopyAttributeFlags[ALLCOPY][NUM_ATTRIBUTES]; //copy flag for attribute data 00568 00569 vtkFieldData::BasicIterator RequiredArrays; 00570 00571 int* TargetIndices; 00572 00573 static const int NumberOfAttributeComponents[NUM_ATTRIBUTES]; 00574 static const int AttributeLimits[NUM_ATTRIBUTES]; 00575 static const char AttributeNames[NUM_ATTRIBUTES][12]; 00576 static const char LongAttributeNames[NUM_ATTRIBUTES][35]; 00577 00578 private: 00579 int SetAttribute(vtkAbstractArray* da, int attributeType); 00580 static int CheckNumberOfComponents(vtkAbstractArray* da, int attributeType); 00581 00582 vtkFieldData::BasicIterator ComputeRequiredArrays(vtkDataSetAttributes* pd, int ctype); 00583 00584 private: 00585 vtkDataSetAttributes(const vtkDataSetAttributes&); // Not implemented. 00586 void operator=(const vtkDataSetAttributes&); // Not implemented. 00587 00588 public: 00589 // This public class is used to perform set operations, other misc. 00590 // operations on fields. For example, vtkAppendFilter uses it to 00591 // determine which attributes the input datasets share in common. 00592 class vtkInternalComponentNames; 00593 class VTKCOMMONDATAMODEL_EXPORT FieldList 00594 { 00595 public: 00596 FieldList(int numInputs); 00597 ~FieldList(); 00598 void PrintSelf(ostream &os, vtkIndent indent); 00599 00600 void InitializeFieldList(vtkDataSetAttributes* dsa); 00601 void IntersectFieldList(vtkDataSetAttributes* dsa); 00602 00607 void UnionFieldList(vtkDataSetAttributes* dsa); 00608 00609 //Determine whether data is available 00610 int IsAttributePresent(int attrType); //true/false attributes specified 00611 00612 // Accessor methods. 00613 int GetNumberOfFields() { return this->NumberOfFields; } 00614 int GetFieldIndex(int i) { return this->FieldIndices[i]; } 00615 const char* GetFieldName(int i) { return this->Fields[i]; } 00616 int GetFieldComponents(int i) { return this->FieldComponents[i]; } 00617 int GetDSAIndex(int index, int i) { return this->DSAIndices[index][i]; } 00618 00619 friend class vtkDataSetAttributes; 00620 00621 protected: 00622 FieldList(const FieldList&) {} //prevent these methods from being used 00623 void operator=(const FieldList&) {} 00624 00625 void SetFieldIndex(int i, int index) 00626 { this->FieldIndices[i] = index; } 00627 private: 00628 void SetField(int index, vtkAbstractArray *da); 00629 void RemoveField(const char *name); 00630 void ClearFields(); 00631 void GrowBy(unsigned int delta); 00632 00633 int NumberOfFields; //the number of fields (including five named attributes) 00634 // These keep track of what is common across datasets. The first 00635 // six items are always named attributes. 00636 char** Fields; // the names of the fields 00637 int *FieldTypes; // the types of the fields 00638 int *FieldComponents; // the number of components in field 00639 int *FieldIndices; // output data array index 00640 vtkLookupTable **LUT; // luts associated with each array 00641 vtkInformation **FieldInformation; // Information map associated with each array 00642 00643 vtkInternalComponentNames **FieldComponentsNames; // the name for each component in the field 00644 00645 vtkIdType NumberOfTuples; // a running total of values 00646 00647 //For every vtkDataSetAttributes that are processed, keep track of the 00648 //indices into various things. The indices are organized so that the 00649 //first NUM_ATTRIBUTES refer to attributes, the next refer to the 00650 //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields. 00651 //CurrentInput is the current input being processed. 00652 int **DSAIndices; 00653 int NumberOfDSAIndices; 00654 int CurrentInput; 00655 00656 }; 00657 //ETX 00658 }; 00659 00660 #endif 00661 00662