VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkBoundedPlanePointPlacer.h,v $ 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 =========================================================================*/ 00028 #ifndef __vtkBoundedPlanePointPlacer_h 00029 #define __vtkBoundedPlanePointPlacer_h 00030 00031 #include "vtkPointPlacer.h" 00032 00033 class vtkPlane; 00034 class vtkPlaneCollection; 00035 class vtkPlanes; 00036 class vtkRenderer; 00037 00038 00039 class VTK_WIDGETS_EXPORT vtkBoundedPlanePointPlacer : public vtkPointPlacer 00040 { 00041 public: 00043 static vtkBoundedPlanePointPlacer *New(); 00044 00046 00047 vtkTypeRevisionMacro(vtkBoundedPlanePointPlacer,vtkPointPlacer); 00048 void PrintSelf(ostream& os, vtkIndent indent); 00050 00052 00055 vtkSetClampMacro(ProjectionNormal,int, 00056 vtkBoundedPlanePointPlacer::XAxis, 00057 vtkBoundedPlanePointPlacer::Oblique); 00058 vtkGetMacro(ProjectionNormal,int); 00059 void SetProjectionNormalToXAxis() 00060 { this->SetProjectionNormal(vtkBoundedPlanePointPlacer::XAxis); } 00061 void SetProjectionNormalToYAxis() 00062 { this->SetProjectionNormal(vtkBoundedPlanePointPlacer::YAxis); } 00063 void SetProjectionNormalToZAxis() 00064 { this->SetProjectionNormal(vtkBoundedPlanePointPlacer::ZAxis); } 00065 void SetProjectionNormalToOblique() 00066 { this->SetProjectionNormal(vtkBoundedPlanePointPlacer::Oblique); } 00068 00071 void SetObliquePlane(vtkPlane *); 00072 00074 00078 void SetProjectionPosition(double position); 00079 vtkGetMacro(ProjectionPosition, double); 00081 00083 00089 void AddBoundingPlane(vtkPlane *plane); 00090 void RemoveBoundingPlane(vtkPlane *plane); 00091 void RemoveAllBoundingPlanes(); 00092 virtual void SetBoundingPlanes(vtkPlaneCollection*); 00093 vtkGetObjectMacro(BoundingPlanes,vtkPlaneCollection); 00094 void SetBoundingPlanes(vtkPlanes *planes); 00096 00097 //BTX 00098 enum 00099 { 00100 XAxis=0, 00101 YAxis, 00102 ZAxis, 00103 Oblique 00104 }; 00105 //ETX 00106 00108 00117 int ComputeWorldPosition( vtkRenderer *ren, 00118 double displayPos[2], 00119 double worldPos[3], 00120 double worldOrient[9] ); 00122 00124 00127 virtual int ComputeWorldPosition( vtkRenderer *ren, 00128 double displayPos[2], 00129 double refWorldPos[3], 00130 double worldPos[3], 00131 double worldOrient[9] ); 00133 00136 int ValidateWorldPosition( double worldPos[3] ); 00137 00138 // Descrption: 00139 // Orientationation is ignored, and the above method 00140 // is called instead. 00141 int ValidateWorldPosition( double worldPos[3], 00142 double worldOrient[9]); 00143 00145 00149 virtual int UpdateWorldPosition( vtkRenderer *ren, 00150 double worldPos[3], 00151 double worldOrient[9] ); 00153 00154 00155 protected: 00156 vtkBoundedPlanePointPlacer(); 00157 ~vtkBoundedPlanePointPlacer(); 00158 00159 // Indicates the projection normal as lying along the 00160 // XAxis, YAxis, ZAxis, or Oblique. For X, Y, and Z axes, 00161 // the projection normal is assumed to be anchored at 00162 // (0,0,0) 00163 int ProjectionNormal; 00164 00165 // Indicates a distance from the origin of the projection 00166 // normal where the project plane will be placed 00167 double ProjectionPosition; 00168 00169 // If the ProjectionNormal is oblique, this is the oblique 00170 // plane 00171 vtkPlane *ObliquePlane; 00172 00173 // A collection of planes used to bound the projection 00174 // plane 00175 vtkPlaneCollection *BoundingPlanes; 00176 00177 // Internal method for getting the project normal as a vector 00178 void GetProjectionNormal( double normal[3] ); 00179 00180 // Internal method for getting the origin of the 00181 // constraining plane as a 3-tuple 00182 void GetProjectionOrigin( double origin[3] ); 00183 00184 // Internal method for getting the orientation of 00185 // the projection plane 00186 void GetCurrentOrientation( double worldOrient[9] ); 00187 00188 // Calculate the distance of a point from the Object. Negative 00189 // values imply that the point is outside. Positive values imply that it is 00190 // inside. The closest point to the object is returned in closestPt. 00191 static double GetDistanceFromObject( double pos[3], 00192 vtkPlaneCollection * pc, 00193 double closestPt[3]); 00194 00195 private: 00196 vtkBoundedPlanePointPlacer(const vtkBoundedPlanePointPlacer&); //Not implemented 00197 void operator=(const vtkBoundedPlanePointPlacer&); //Not implemented 00198 }; 00199 00200 #endif