Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Common/vtkDataSetAttributes.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDataSetAttributes.h,v $
00005   Language:  C++
00006 
00007 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00057 #ifndef __vtkDataSetAttributes_h
00058 #define __vtkDataSetAttributes_h
00059 
00060 #include "vtkObject.h"
00061 #include "vtkFieldData.h"
00062 
00063 class VTK_COMMON_EXPORT vtkDataSetAttributes : public vtkFieldData
00064 {
00065 public:
00067   static vtkDataSetAttributes *New();
00068   
00069   vtkTypeMacro(vtkDataSetAttributes,vtkFieldData);
00070   void PrintSelf(ostream& os, vtkIndent indent);
00071 
00073   virtual void Initialize();
00074 
00077   virtual void Update() {}
00078 
00085   virtual void PassData(vtkFieldData* fd);
00086 
00088 
00095   void CopyAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00096                     vtkIdType ext=1000);
00098 
00106   void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId);
00107 
00109 
00112   void InterpolateAllocate(vtkDataSetAttributes* pd, vtkIdType sze=0,
00113                            vtkIdType ext=1000);
00115   
00117 
00119   void InterpolatePoint(vtkDataSetAttributes *fromPd, vtkIdType toId, 
00120                         vtkIdList *ids, float *weights);
00122   
00124 
00128   void InterpolateEdge(vtkDataSetAttributes *fromPd, vtkIdType toId,
00129                        vtkIdType p1, vtkIdType p2, float t);
00131 
00133 
00140   void InterpolateTime(vtkDataSetAttributes *from1, 
00141                        vtkDataSetAttributes *from2,
00142                        vtkIdType id, float t);
00144 
00147   virtual void DeepCopy(vtkFieldData *pd);
00148 
00150   virtual void ShallowCopy(vtkFieldData *pd);
00151 
00153 
00154   int SetScalars(vtkDataArray* da);
00155   int SetActiveScalars(const char* name);
00156   vtkDataArray* GetScalars();
00158 
00160 
00161   int SetVectors(vtkDataArray* da);
00162   int SetActiveVectors(const char* name);
00163   vtkDataArray* GetVectors();
00165 
00167 
00168   int SetNormals(vtkDataArray* da);
00169   int SetActiveNormals(const char* name);
00170   vtkDataArray* GetNormals();
00172 
00174 
00175   int SetTCoords(vtkDataArray* da);
00176   int SetActiveTCoords(const char* name);
00177   vtkDataArray* GetTCoords();
00179 
00181 
00182   int SetTensors(vtkDataArray* da);
00183   int SetActiveTensors(const char* name);
00184   vtkDataArray* GetTensors();
00186 
00193   int SetActiveAttribute(const char* name, int attributeType);
00194 
00196   int SetActiveAttribute(int index, int attributeType);
00197 
00199   void SetCopyAttribute (int index, int value);
00200 
00202 
00208   void SetCopyScalars(int i);
00209   int GetCopyScalars();
00210   vtkBooleanMacro(CopyScalars, int);
00212 
00214 
00220   void SetCopyVectors(int i);
00221   int GetCopyVectors();
00222   vtkBooleanMacro(CopyVectors, int);
00224 
00226 
00232   void SetCopyNormals(int i);
00233   int GetCopyNormals();
00234   vtkBooleanMacro(CopyNormals, int);
00236 
00238 
00244   void SetCopyTCoords(int i);
00245   int GetCopyTCoords();
00246   vtkBooleanMacro(CopyTCoords, int);
00248 
00250 
00256   void SetCopyTensors(int i);
00257   int GetCopyTensors();
00258   vtkBooleanMacro(CopyTensors, int);
00260 
00267   virtual void CopyAllOn();
00268 
00275   virtual void CopyAllOff();
00276 
00278 
00282   void CopyTuple(vtkDataArray *fromData, vtkDataArray *toData, 
00283                  vtkIdType fromId, vtkIdType toId);
00285 
00288   void GetAttributeIndices(int* indexArray);
00289 
00294   int IsArrayAnAttribute(int idx);
00295 
00298   vtkDataArray* GetAttribute(int attributeType);
00299 
00301   virtual void RemoveArray(const char *name);
00302 
00303 //BTX
00304   // Always keep NUM_ATTRIBUTES as the last entry
00305   enum AttributeTypes 
00306   {
00307     SCALARS=0,
00308     VECTORS=1,
00309     NORMALS=2,
00310     TCOORDS=3,
00311     TENSORS=4,
00312     NUM_ATTRIBUTES
00313   };
00314 
00315   enum AttributeLimitTypes 
00316   {
00317     MAX, 
00318     EXACT, 
00319     NOLIMIT
00320   };
00321 
00322   // This public class is used to perform set operations, other misc. 
00323   // operations on fields. For example, vtkAppendFilter uses it to 
00324   // determine which attributes the input datasets share in common.
00325   class VTK_COMMON_EXPORT FieldList
00326   {
00327   public:
00328     FieldList(int numInputs);
00329     ~FieldList();
00330 
00331     void InitializeFieldList(vtkDataSetAttributes* dsa);
00332     void IntersectFieldList(vtkDataSetAttributes* dsa);
00333 
00334     //Determine whether data is available
00335     int IsAttributePresent(int attrType); //true/false attributes specified
00336     int IsFieldPresent(const char *name); //return idx into field arrays
00337 
00338     friend class vtkDataSetAttributes;
00339 
00340   protected:
00341     FieldList(const FieldList&) {} //prevent these methods from being used
00342     void operator=(const FieldList&) {}
00343 
00344   private:
00345     void SetField(int index, vtkDataArray *da);
00346     void RemoveField(const char *name);
00347     void ClearFields();
00348     
00349     //These keep track of what is common across datasets
00350     char** Fields; //the names of the fields (first five are named attributes)
00351     int *FieldTypes; //the types of the fields (first five are named 
00352                      //attributes)
00353     int *FieldComponents; //the number of components in each  fields 
00354                           // (first five are named attributes)
00355     int *FieldIndices; //output data array index 
00356                        // (first five are named attributes)
00357     vtkLookupTable **LUT; //luts associated with each array
00358     vtkIdType NumberOfTuples; //a running total of values
00359     int NumberOfFields; //the number of fields
00360     
00361     //For every vtkDataSetAttributes that are processed, keep track of the 
00362     //indices into various things. The indices are organized so that the
00363     //first NUM_ATTRIBUTES refer to attributes, the next refer to the 
00364     //non-attribute fields, for a total of NUM_ATTRIBUTES + NumberOfFields.
00365     //CurrentInput is the current input being processed.
00366     int **DSAIndices;
00367     int NumberOfDSAIndices;
00368     int CurrentInput;
00369   };
00370 
00372 
00374   void CopyAllocate(vtkDataSetAttributes::FieldList& list, vtkIdType sze=0, 
00375                     vtkIdType ext=1000);
00377 
00379 
00383   void CopyData(vtkDataSetAttributes::FieldList& list, 
00384                 vtkDataSetAttributes* dsa, int idx, vtkIdType fromId,
00385                 vtkIdType toId);
00387 
00388   friend class vtkDataSetAttributes::FieldList;
00389 //ETX
00390 
00391 protected:
00392   vtkDataSetAttributes();
00393   ~vtkDataSetAttributes();
00394 
00395   // special methods to support managing data
00396   void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData,
00397                         vtkIdType toId, vtkIdList *ptIds, float *weights);
00398   void InterpolateTuple(vtkDataArray *fromData, vtkDataArray *toData,
00399                         vtkIdType toId, vtkIdType id1, vtkIdType id2, float t);
00400   void InterpolateTuple(vtkDataArray *fromData1, vtkDataArray *fromData2, 
00401                         vtkDataArray *toData, vtkIdType id, float t);
00402 
00403   int AttributeIndices[NUM_ATTRIBUTES]; //index to attribute array in field data
00404   int CopyAttributeFlags[NUM_ATTRIBUTES]; //copy flag for attribute data
00405 
00406 //BTX
00407   vtkFieldData::BasicIterator RequiredArrays;
00408 //ETX
00409 
00410   int* TargetIndices;
00411 
00412   virtual void RemoveArray(int index);
00413 
00414   static int NumberOfAttributeComponents[NUM_ATTRIBUTES];
00415   static int AttributeLimits[NUM_ATTRIBUTES];
00416   static char AttributeNames[NUM_ATTRIBUTES][10];
00417 
00418 private:
00419   int SetAttribute(vtkDataArray* da, int attributeType);
00420   static int CheckNumberOfComponents(vtkDataArray* da, int attributeType);
00421 
00422 //BTX
00423   vtkFieldData::BasicIterator  ComputeRequiredArrays(vtkDataSetAttributes* pd);
00424 //ETX
00425 
00426 private:
00427   vtkDataSetAttributes(const vtkDataSetAttributes&);  // Not implemented.
00428   void operator=(const vtkDataSetAttributes&);  // Not implemented.
00429 };
00430 
00431 #endif
00432 
00433 

Generated on Thu Mar 28 14:19:15 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001