Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

mitkPlane.h

00001 /*=========================================================================
00002 
00003   Program:   3DMed
00004   Date:      $Date: 2014-02-25 18:30:00 +0800 $
00005   Version:   $Version: 4.6.0 $
00006   Copyright: MIPG, Institute of Automation, Chinese Academy of Sciences
00007 
00008 =========================================================================*/
00009 
00010 
00011 #ifndef __mitkPlane_h
00012 #define __mitkPlane_h
00013 
00014 #include "mitkObject.h"
00015 #include "mitkMatrix.h"
00016 
00020 class MITK_COMMON_API mitkPlane : public mitkObject
00021 {
00022 public:
00023     MITK_TYPE(mitkPlane,mitkObject)
00024 
00025     virtual void PrintSelf(ostream& os);
00026 
00027     mitkPlane();    
00028 
00032     float Evaluate(float x[3]);
00033     float Evaluate(float x, float y, float z);  
00034 
00038     void SetNormal(float nx, float ny, float nz) {m_Normal->ele[0] = nx; m_Normal->ele[1] = ny; m_Normal->ele[2] = nz; m_Normal->Normalize();}
00039     void SetNormal(float normal[3]) {m_Normal->ele[0] = normal[0]; m_Normal->ele[1] = normal[1]; m_Normal->ele[2] = normal[2]; m_Normal->Normalize();}
00040     void GetNormal(float &nx, float &ny, float &nz) {nx = m_Normal->ele[0]; ny = m_Normal->ele[1]; nz = m_Normal->ele[2];}  
00041     const mitkVector* GetNormal(void)  {return m_Normal;}
00042 
00046     void SetOrigin(float x, float y, float z) {m_Origin->ele[0] = x; m_Origin->ele[1] = y; m_Origin->ele[2] = z;}
00047     void SetOrigin(float origin[3]) {m_Origin->ele[0] = origin[0]; m_Origin->ele[1] = origin[1]; m_Origin->ele[2] = origin[2];}
00048     void GetOrigin(float &x, float &y, float &z) {x = m_Origin->ele[0]; y = m_Origin->ele[1]; z = m_Origin->ele[2];}    
00049     const mitkVector* GetOrigin(void)  {return m_Origin;}
00050     
00054     void TranslateTowardNormal(float distance);
00055 
00059     void ProjectPoint(float x[3], float xproj[3]);
00060     void ProjectPoint(const mitkVector &srcPoint, mitkVector &projPoint); 
00061 
00065     float DistanceToPlane(float x[3]);
00066     float DistanceToPlane(const mitkVector &srcPoint);
00067 
00071     int IntersectWithLine(float p1[3], float p2[3], float& t, float x[3]);
00072     int IntersectWithLine(const mitkVector &point1, const mitkVector &point2, float &t, mitkVector &intersectedPoint);
00073 
00074 
00075 protected:
00076     mitkVector *m_Normal;
00077     mitkVector *m_Origin;  
00078 
00079     virtual ~mitkPlane();
00080 
00081 private:
00082     mitkPlane(const mitkPlane&);
00083     void operator=(const mitkPlane&);  
00084 };
00085 
00086 inline float mitkPlane::Evaluate(float x[3])
00087 {
00088     mitkVector point(x[0], x[1], x[2]);
00089     point -= *m_Origin;
00090     return *m_Normal * point;
00091 }
00092 
00093 inline float mitkPlane::Evaluate(float x, float y, float z)
00094 {
00095     mitkVector point(x, y, z);
00096     point -= *m_Origin;
00097     return *m_Normal * point;
00098 }
00099 
00100 inline float mitkPlane::DistanceToPlane(float x[3])
00101 {
00102     mitkVector point(x[0], x[1], x[2]);
00103     point -= *m_Origin;
00104     return fabsf(*m_Normal * point);  
00105 }
00106 
00107 inline float mitkPlane::DistanceToPlane(const mitkVector &srcPoint)
00108 {
00109     mitkVector point = srcPoint;
00110     point -= *m_Origin;
00111     return fabsf(*m_Normal * point);  
00112 }
00113 
00114 
00115 //#define DEFINED_mitkPlane
00116 
00117 
00118 
00119 #endif
00120 
00121 
00122 
00123 

Generated on Tue Feb 25 15:00:37 2014 for MITK (Medical Imaging ToolKit) by  doxygen 1.4.3