VTK
dox/Widgets/vtkBoundedPlanePointPlacer.h
Go to the documentation of this file.
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 "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   vtkTypeMacro(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 
00070 
00072   void SetObliquePlane(vtkPlane *);
00073   vtkGetObjectMacro( ObliquePlane, vtkPlane );
00075 
00077 
00081   void SetProjectionPosition(double position);
00082   vtkGetMacro(ProjectionPosition, double);
00084 
00086 
00092   void AddBoundingPlane(vtkPlane *plane);
00093   void RemoveBoundingPlane(vtkPlane *plane);
00094   void RemoveAllBoundingPlanes();
00095   virtual void SetBoundingPlanes(vtkPlaneCollection*);
00096   vtkGetObjectMacro(BoundingPlanes,vtkPlaneCollection);
00097   void SetBoundingPlanes(vtkPlanes *planes);
00099   
00100 //BTX
00101   enum
00102   {
00103     XAxis=0,
00104     YAxis,
00105     ZAxis,
00106     Oblique
00107   };
00108 //ETX
00109   
00111 
00120   int ComputeWorldPosition( vtkRenderer *ren,
00121                             double displayPos[2], 
00122                             double worldPos[3],
00123                             double worldOrient[9] );
00125   
00127 
00130   virtual int ComputeWorldPosition( vtkRenderer *ren,
00131                                     double displayPos[2], 
00132                                     double refWorldPos[3],
00133                                     double worldPos[3],
00134                                     double worldOrient[9] );
00136   
00139   int ValidateWorldPosition( double worldPos[3] );
00140   
00141   // Descrption:
00142   // Orientationation is ignored, and the above method
00143   // is called instead.
00144   int ValidateWorldPosition( double worldPos[3],
00145                              double worldOrient[9]);
00146   
00148 
00152   virtual int UpdateWorldPosition( vtkRenderer *ren,
00153                                    double worldPos[3],
00154                                    double worldOrient[9] );
00156   
00157 
00158 protected:
00159   vtkBoundedPlanePointPlacer();
00160   ~vtkBoundedPlanePointPlacer();
00161 
00162   // Indicates the projection normal as lying along the
00163   // XAxis, YAxis, ZAxis, or Oblique. For X, Y, and Z axes,
00164   // the projection normal is assumed to be anchored at
00165   // (0,0,0)
00166   int             ProjectionNormal;
00167 
00168   // Indicates a distance from the origin of the projection
00169   // normal where the project plane will be placed
00170   double          ProjectionPosition;
00171   
00172   // If the ProjectionNormal is oblique, this is the oblique
00173   // plane
00174   vtkPlane        *ObliquePlane;
00175 
00176   // A collection of planes used to bound the projection
00177   // plane
00178   vtkPlaneCollection *BoundingPlanes;
00179 
00180   // Internal method for getting the project normal as a vector
00181   void GetProjectionNormal( double normal[3] );
00182   
00183   // Internal method for getting the origin of the 
00184   // constraining plane as a 3-tuple
00185   void GetProjectionOrigin( double origin[3] );
00186 
00187   // Internal method for getting the orientation of
00188   // the projection plane
00189   void GetCurrentOrientation( double worldOrient[9] );
00190   
00191   // Calculate the distance of a point from the Object. Negative 
00192   // values imply that the point is outside. Positive values imply that it is
00193   // inside. The closest point to the object is returned in closestPt. 
00194   static double GetDistanceFromObject( double               pos[3],
00195                                        vtkPlaneCollection * pc,
00196                                        double               closestPt[3]);
00197   
00198 private:
00199   vtkBoundedPlanePointPlacer(const vtkBoundedPlanePointPlacer&);  //Not implemented
00200   void operator=(const vtkBoundedPlanePointPlacer&);  //Not implemented
00201 };
00202 
00203 #endif