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

Common/vtkTransform.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkTransform.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 =========================================================================*/
00040 
00079 #ifndef __vtkTransform_h
00080 #define __vtkTransform_h
00081 
00082 #include "vtkLinearTransform.h"
00083 #include "vtkMatrix4x4.h"
00084 
00085 class VTK_COMMON_EXPORT vtkTransform : public vtkLinearTransform
00086 {
00087  public:
00088   static vtkTransform *New();
00089   vtkTypeMacro(vtkTransform,vtkLinearTransform);
00090   void PrintSelf(ostream& os, vtkIndent indent);
00091 
00095   void Identity();
00096 
00100   void Inverse();
00101 
00103 
00105   void Translate(double x, double y, double z) {
00106     this->Concatenation->Translate(x,y,z); };
00107   void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00108   void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00110 
00112 
00116   void RotateWXYZ(double angle, double x, double y, double z) {
00117     this->Concatenation->Rotate(angle,x,y,z); };
00118   void RotateWXYZ(double angle, const double axis[3]) {
00119     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00120   void RotateWXYZ(double angle, const float axis[3]) {
00121     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00123 
00125 
00128   void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00129   void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00130   void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00132 
00134 
00137   void Scale(double x, double y, double z) {
00138     this->Concatenation->Scale(x,y,z); };
00139   void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00140   void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00142 
00144 
00146   void SetMatrix(vtkMatrix4x4 *matrix) { 
00147     this->SetMatrix(*matrix->Element); };
00148   void SetMatrix(const double elements[16]) { 
00149     this->Identity(); this->Concatenate(elements); };
00151 
00153 
00155   void Concatenate(vtkMatrix4x4 *matrix) { 
00156     this->Concatenate(*matrix->Element); };
00157   void Concatenate(const double elements[16]) {
00158     this->Concatenation->Concatenate(elements); };
00160 
00166   void Concatenate(vtkLinearTransform *transform);
00167 
00169 
00174   void PreMultiply() { 
00175     if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00176     this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00178 
00180 
00185   void PostMultiply()  { 
00186     if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00187     this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00189 
00191 
00193   int GetNumberOfConcatenatedTransforms() {
00194     return this->Concatenation->GetNumberOfTransforms() + 
00195       (this->Input == NULL ? 0 : 1); };
00197 
00199 
00204   vtkLinearTransform *GetConcatenatedTransform(int i) {
00205     if (this->Input == NULL) {
00206       return (vtkLinearTransform *)this->Concatenation->GetTransform(i); }
00207     else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
00208       return (vtkLinearTransform *)this->Concatenation->GetTransform(i); }
00209     else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
00210       return (vtkLinearTransform *)this->Concatenation->GetTransform(i-1); } 
00211     else if (this->GetInverseFlag()) {
00212       return (vtkLinearTransform *)this->Input->GetInverse(); }
00213     else {
00214       return (vtkLinearTransform *)this->Input; } };
00216 
00218 
00220   void GetOrientation(double orient[3]);
00221   void GetOrientation(float orient[3]) {
00222     double temp[3]; this->GetOrientation(temp); 
00223     orient[0] = temp[0]; orient[1] = temp[1]; orient[2] = temp[2]; };
00224   float *GetOrientation() { 
00225     this->GetOrientation(this->ReturnValue); return this->ReturnValue; };
00227 
00229 
00230   void GetOrientationWXYZ(double wxyz[4]);
00231   void GetOrientationWXYZ(float wxyz[3]) {
00232     double temp[4]; this->GetOrientationWXYZ(temp); 
00233     wxyz[0]=temp[0]; wxyz[1]=temp[1]; wxyz[2]=temp[2]; wxyz[3]=temp[3];};
00234   float *GetOrientationWXYZ() { 
00235     this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
00237 
00239 
00242   void GetPosition(double pos[3]);
00243   void GetPosition(float pos[3]) {
00244     double temp[3]; this->GetPosition(temp); 
00245     pos[0] = temp[0]; pos[1] = temp[1]; pos[2] = temp[2]; };
00246   float *GetPosition() { 
00247     this->GetPosition(this->ReturnValue); return this->ReturnValue; };
00249 
00251 
00255   void GetScale(double scale[3]);
00256   void GetScale(float scale[3]) {
00257     double temp[3]; this->GetScale(temp); 
00258     scale[0] = temp[0]; scale[1] = temp[1]; scale[2] = temp[2]; };
00259   float *GetScale() { 
00260     this->GetScale(this->ReturnValue); return this->ReturnValue; };
00262 
00265   void GetInverse(vtkMatrix4x4 *inverse);
00266 
00270   void GetTranspose(vtkMatrix4x4 *transpose);
00271 
00273 
00279   void SetInput(vtkLinearTransform *input);
00280   vtkLinearTransform *GetInput() { return this->Input; };
00282 
00284 
00288   int GetInverseFlag() {
00289     return this->Concatenation->GetInverseFlag(); };
00291 
00293 
00294   void Push() { if (this->Stack == NULL) { 
00295                     this->Stack = vtkTransformConcatenationStack::New(); }
00296                 this->Stack->Push(&this->Concatenation); 
00297                 this->Modified(); };
00299 
00301 
00303   void Pop() { if (this->Stack == NULL) { return; }
00304                this->Stack->Pop(&this->Concatenation);
00305                this->Modified(); };
00307 
00314   int CircuitCheck(vtkAbstractTransform *transform);
00315 
00316   // Return an inverse transform which will always update itself
00317   // to match this transform.
00318   vtkAbstractTransform *GetInverse() { 
00319     return vtkLinearTransform::GetInverse(); }
00320 
00322   vtkAbstractTransform *MakeTransform();
00323 
00325   unsigned long GetMTime();
00326 
00328 
00331   void MultiplyPoint(const float in[4], float out[4]) {
00332     this->GetMatrix()->MultiplyPoint(in,out);};
00333   void MultiplyPoint(const double in[4], double out[4]) {      
00334     this->GetMatrix()->MultiplyPoint(in,out);};
00336 
00337 protected:
00338   vtkTransform ();
00339   ~vtkTransform ();
00340 
00341   void InternalDeepCopy(vtkAbstractTransform *t);
00342 
00343   void InternalUpdate();
00344 
00345   vtkLinearTransform *Input;
00346   vtkTransformConcatenation *Concatenation;
00347   vtkTransformConcatenationStack *Stack;
00348 
00349   // this allows us to check whether people have been fooling
00350   // around with our matrix
00351   unsigned long MatrixUpdateMTime;
00352 
00353   float Point[4];
00354   double DoublePoint[4];
00355   float ReturnValue[4];
00356 private:
00357   vtkTransform (const vtkTransform& t);  // Not implemented.
00358   void operator=(const vtkTransform&);  // Not implemented.
00359 };
00360 
00361 #endif

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