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

common/vtkVectors.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkVectors.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 =========================================================================*/
00053 #ifndef __vtkVectors_h
00054 #define __vtkVectors_h
00055 
00056 #include "vtkAttributeData.h"
00057 
00058 class vtkIdList;
00059 class vtkVectors;
00060 
00061 class VTK_EXPORT vtkVectors : public vtkAttributeData
00062 {
00063 public:
00064   static vtkVectors *New(int dataType);
00065   static vtkVectors *New();
00066 
00067   vtkTypeMacro(vtkVectors,vtkAttributeData);
00068   void PrintSelf(ostream& os, vtkIndent indent);
00069   
00071   vtkAttributeData *MakeObject()
00072     {return vtkVectors::New(this->GetDataType());};
00073 
00075   int GetNumberOfVectors() {return this->Data->GetNumberOfTuples();};
00076 
00078   float *GetVector(int id) { return this->Data->GetTuple(id);};
00079 
00082   void GetVector(int id, float v[3]) { this->Data->GetTuple(id,v);};
00083   void GetVector(int id, double v[3]) { this->Data->GetTuple(id,v);};
00084 
00088   void SetVector(int id, const float v[3]) {this->Data->SetTuple(id,v);};
00089   void SetVector(int id, const double v[3]) {this->Data->SetTuple(id,v);};
00090   void SetVector(int id, double vx, double vy, double vz);
00091 
00094   void InsertVector(int id, const float v[3])
00095     {this->Data->InsertTuple(id,v);};
00096   void InsertVector(int id, const double v[3]) 
00097     {this->Data->InsertTuple(id,v);};
00098   void InsertVector(int id, double vx, double vy, double vz);
00099 
00101   int InsertNextVector(const float v[3]) 
00102     {return this->Data->InsertNextTuple(v);};
00103   int InsertNextVector(const double v[3]) 
00104     {return this->Data->InsertNextTuple(v);};
00105   int InsertNextVector(double vx, double vy, double vz);
00106 
00110   void SetNumberOfVectors(int number);
00111 
00113   void ComputeMaxNorm();
00114 
00116   double GetMaxNorm();
00117 
00119   void GetVectors(vtkIdList *ptId, vtkVectors *fv);
00120 
00121 #ifndef VTK_REMOVE_LEGACY_CODE
00122 
00123   void GetVectors(vtkIdList& ptId, vtkVectors& fv)
00124     {VTK_LEGACY_METHOD(GetVectors,"3.2"); this->GetVectors(&ptId, &fv);}
00125 #endif
00126   
00127 
00128 protected:
00129   vtkVectors();
00130   ~vtkVectors() {};
00131   vtkVectors(const vtkVectors&) {};
00132   void operator=(const vtkVectors&) {};
00133 
00134   double MaxNorm;
00135   vtkTimeStamp ComputeTime; // Time at which MaxNorm computed
00136 
00137 };
00138 
00139 
00140 inline void vtkVectors::SetNumberOfVectors(int number)
00141 {
00142   this->Data->SetNumberOfComponents(3);
00143   this->Data->SetNumberOfTuples(number);
00144 }
00145 
00146 inline void vtkVectors::SetVector(int id, double vx, double vy, double vz)
00147 {
00148   double v[3];
00149   v[0] = vx;
00150   v[1] = vy;
00151   v[2] = vz;
00152   this->Data->SetTuple(id,v);
00153 }
00154 
00155 inline void vtkVectors::InsertVector(int id, double vx, double vy, double vz)
00156 {
00157   double v[3];
00158 
00159   v[0] = vx;
00160   v[1] = vy;
00161   v[2] = vz;
00162   this->Data->InsertTuple(id,v);
00163 }
00164 
00165 inline int vtkVectors::InsertNextVector(double vx, double vy, double vz)
00166 {
00167   double v[3];
00168 
00169   v[0] = vx;
00170   v[1] = vy;
00171   v[2] = vz;
00172   return this->Data->InsertNextTuple(v);
00173 }
00174 
00175 
00176 // These include files are placed here so that if Vectors.h is included 
00177 // all other classes necessary for compilation are also included. 
00178 #include "vtkIdList.h"
00179 
00180 #endif
00181 

Generated on Wed Nov 21 12:26:54 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001