00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
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 
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 
00098   enum
00099   {
00100     XAxis=0,
00101     YAxis,
00102     ZAxis,
00103     Oblique
00104   };
00105 
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   
00139   
00140   
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   
00160   
00161   
00162   
00163   int             ProjectionNormal;
00164 
00165   
00166   
00167   double          ProjectionPosition;
00168   
00169   
00170   
00171   vtkPlane        *ObliquePlane;
00172 
00173   
00174   
00175   vtkPlaneCollection *BoundingPlanes;
00176 
00177   
00178   void GetProjectionNormal( double normal[3] );
00179   
00180   
00181   
00182   void GetProjectionOrigin( double origin[3] );
00183 
00184   
00185   
00186   void GetCurrentOrientation( double worldOrient[9] );
00187   
00188   
00189   
00190   
00191   static double GetDistanceFromObject( double               pos[3],
00192                                        vtkPlaneCollection * pc,
00193                                        double               closestPt[3]);
00194   
00195 private:
00196   vtkBoundedPlanePointPlacer(const vtkBoundedPlanePointPlacer&);  
00197   void operator=(const vtkBoundedPlanePointPlacer&);  
00198 };
00199 
00200 #endif