VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkBoundedPlanePointPlacer.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 =========================================================================*/ 00028 #ifndef vtkBoundedPlanePointPlacer_h 00029 #define vtkBoundedPlanePointPlacer_h 00030 00031 #include "vtkInteractionWidgetsModule.h" // For export macro 00032 #include "vtkPointPlacer.h" 00033 00034 class vtkPlane; 00035 class vtkPlaneCollection; 00036 class vtkPlanes; 00037 class vtkRenderer; 00038 00039 00040 class VTKINTERACTIONWIDGETS_EXPORT vtkBoundedPlanePointPlacer : public vtkPointPlacer 00041 { 00042 public: 00044 static vtkBoundedPlanePointPlacer *New(); 00045 00047 00048 vtkTypeMacro(vtkBoundedPlanePointPlacer,vtkPointPlacer); 00049 void PrintSelf(ostream& os, vtkIndent indent); 00051 00053 00056 vtkSetClampMacro(ProjectionNormal,int, 00057 vtkBoundedPlanePointPlacer::XAxis, 00058 vtkBoundedPlanePointPlacer::Oblique); 00059 vtkGetMacro(ProjectionNormal,int); 00060 void SetProjectionNormalToXAxis() 00061 { this->SetProjectionNormal(vtkBoundedPlanePointPlacer::XAxis); } 00062 void SetProjectionNormalToYAxis() 00063 { this->SetProjectionNormal(vtkBoundedPlanePointPlacer::YAxis); } 00064 void SetProjectionNormalToZAxis() 00065 { this->SetProjectionNormal(vtkBoundedPlanePointPlacer::ZAxis); } 00066 void SetProjectionNormalToOblique() 00067 { this->SetProjectionNormal(vtkBoundedPlanePointPlacer::Oblique); } 00069 00071 00073 void SetObliquePlane(vtkPlane *); 00074 vtkGetObjectMacro( ObliquePlane, vtkPlane ); 00076 00078 00082 void SetProjectionPosition(double position); 00083 vtkGetMacro(ProjectionPosition, double); 00085 00087 00093 void AddBoundingPlane(vtkPlane *plane); 00094 void RemoveBoundingPlane(vtkPlane *plane); 00095 void RemoveAllBoundingPlanes(); 00096 virtual void SetBoundingPlanes(vtkPlaneCollection*); 00097 vtkGetObjectMacro(BoundingPlanes,vtkPlaneCollection); 00098 void SetBoundingPlanes(vtkPlanes *planes); 00100 00101 //BTX 00102 enum 00103 { 00104 XAxis=0, 00105 YAxis, 00106 ZAxis, 00107 Oblique 00108 }; 00109 //ETX 00110 00112 00121 int ComputeWorldPosition( vtkRenderer *ren, 00122 double displayPos[2], 00123 double worldPos[3], 00124 double worldOrient[9] ); 00126 00128 00131 virtual int ComputeWorldPosition( vtkRenderer *ren, 00132 double displayPos[2], 00133 double refWorldPos[3], 00134 double worldPos[3], 00135 double worldOrient[9] ); 00137 00140 int ValidateWorldPosition( double worldPos[3] ); 00141 00142 // Descrption: 00143 // Orientationation is ignored, and the above method 00144 // is called instead. 00145 int ValidateWorldPosition( double worldPos[3], 00146 double worldOrient[9]); 00147 00149 00153 virtual int UpdateWorldPosition( vtkRenderer *ren, 00154 double worldPos[3], 00155 double worldOrient[9] ); 00157 00158 00159 protected: 00160 vtkBoundedPlanePointPlacer(); 00161 ~vtkBoundedPlanePointPlacer(); 00162 00163 // Indicates the projection normal as laying along the 00164 // XAxis, YAxis, ZAxis, or Oblique. For X, Y, and Z axes, 00165 // the projection normal is assumed to be anchored at 00166 // (0,0,0) 00167 int ProjectionNormal; 00168 00169 // Indicates a distance from the origin of the projection 00170 // normal where the project plane will be placed 00171 double ProjectionPosition; 00172 00173 // If the ProjectionNormal is oblique, this is the oblique 00174 // plane 00175 vtkPlane *ObliquePlane; 00176 00177 // A collection of planes used to bound the projection 00178 // plane 00179 vtkPlaneCollection *BoundingPlanes; 00180 00181 // Internal method for getting the project normal as a vector 00182 void GetProjectionNormal( double normal[3] ); 00183 00184 // Internal method for getting the origin of the 00185 // constraining plane as a 3-tuple 00186 void GetProjectionOrigin( double origin[3] ); 00187 00188 // Internal method for getting the orientation of 00189 // the projection plane 00190 void GetCurrentOrientation( double worldOrient[9] ); 00191 00192 // Calculate the distance of a point from the Object. Negative 00193 // values imply that the point is outside. Positive values imply that it is 00194 // inside. The closest point to the object is returned in closestPt. 00195 static double GetDistanceFromObject( double pos[3], 00196 vtkPlaneCollection * pc, 00197 double closestPt[3]); 00198 00199 private: 00200 vtkBoundedPlanePointPlacer(const vtkBoundedPlanePointPlacer&); //Not implemented 00201 void operator=(const vtkBoundedPlanePointPlacer&); //Not implemented 00202 }; 00203 00204 #endif