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

Common/vtkPlane.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkPlane.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00046 #ifndef __vtkPlane_h
00047 #define __vtkPlane_h
00048 
00049 #include "vtkImplicitFunction.h"
00050 
00051 class VTK_COMMON_EXPORT vtkPlane : public vtkImplicitFunction
00052 {
00053 public:
00055   static vtkPlane *New();
00056 
00057   vtkTypeRevisionMacro(vtkPlane,vtkImplicitFunction);
00058   void PrintSelf(ostream& os, vtkIndent indent);
00059 
00061 
00062   float EvaluateFunction(float x[3]);
00063   float EvaluateFunction(float x, float y, float z)
00064     {return this->vtkImplicitFunction::EvaluateFunction(x, y, z); } ;
00066 
00068   void EvaluateGradient(float x[3], float g[3]);
00069 
00071 
00072   vtkSetVector3Macro(Normal,float);
00073   vtkGetVectorMacro(Normal,float,3);
00075 
00077 
00079   vtkSetVector3Macro(Origin,float);
00080   vtkGetVectorMacro(Origin,float,3);
00082 
00085   void Push(float distance);
00086 
00088 
00091   static void ProjectPoint(float x[3], float origin[3], float normal[3], 
00092                            float xproj[3]);
00093   static void ProjectPoint(double x[3], double origin[3], double normal[3], 
00094                            double xproj[3]);
00096 
00098 
00101   static void GeneralizedProjectPoint(float x[3], float origin[3],
00102                                       float normal[3], float xproj[3]);
00104   
00106 
00107   static float Evaluate(float normal[3], float origin[3], float x[3]);
00108   static float Evaluate(double normal[3], double origin[3], double x[3]);
00110 
00113   static float DistanceToPlane(float x[3], float n[3], float p0[3]);
00114   
00116 
00121   static int IntersectWithLine(float p1[3], float p2[3], float n[3], 
00122                                float p0[3], float& t, float x[3]);
00124 
00125 
00126 protected:
00127   vtkPlane();
00128   ~vtkPlane() {};
00129 
00130   float Normal[3];
00131   float Origin[3];
00132 
00133 private:
00134   vtkPlane(const vtkPlane&);  // Not implemented.
00135   void operator=(const vtkPlane&);  // Not implemented.
00136 };
00137 
00138 inline float vtkPlane::Evaluate(float normal[3], float origin[3], float x[3])
00139 {
00140   return normal[0]*(x[0]-origin[0]) + normal[1]*(x[1]-origin[1]) + 
00141          normal[2]*(x[2]-origin[2]);
00142 }
00143 inline float vtkPlane::Evaluate(double normal[3], double origin[3],double x[3])
00144 {
00145   return static_cast<float> (normal[0]*(x[0]-origin[0]) + normal[1]*(x[1]-origin[1]) + 
00146          normal[2]*(x[2]-origin[2]));
00147 }
00148 
00149 inline float vtkPlane::DistanceToPlane(float x[3], float n[3], float p0[3])
00150 {
00151 #define vtkPlaneAbs(x) ((x)<0?-(x):(x))
00152   return ((float) vtkPlaneAbs(n[0]*(x[0]-p0[0]) + n[1]*(x[1]-p0[1]) + 
00153                               n[2]*(x[2]-p0[2])));
00154 }
00155 
00156 #endif
00157 
00158