clipping.h
Go to the documentation of this file.
00001 
00063 #ifndef COB_3D_CLIPPING_H
00064 #define COB_3D_CLIPPING_H
00065 
00069 namespace cob_3d_mapping
00070 {
00071   class CohenSutherlandClipping
00072   {
00073   public:
00074     CohenSutherlandClipping()
00075       : xmin(-1.0f)
00076       , xmax( 1.0f)
00077       , ymin(-1.0f)
00078       , ymax( 1.0f)
00079       , zmin(-1.0f)
00080       , zmax( 1.0f)
00081     { }
00082 
00083     void setBorders(float x_min, float x_max,
00084                     float y_min, float y_max,
00085                     float z_min, float z_max)
00086     {
00087       xmin = x_min; xmax = x_max;
00088       ymin = y_min; ymax = y_max;
00089       zmin = z_min; zmax = z_max;
00090     }
00091 
00092     int computeCode(float x, float y, float z=0.0f)
00093     {
00094       int code = 0;
00095       if( x < xmin )     code |= LEFT;
00096       else if( x > xmax) code |= RIGHT;
00097       if( y < ymin )     code |= TOP;
00098       else if( y > ymax) code |= BOTTOM;
00099       if( z < zmin )     code |= NEAR;
00100       else if( z > zmax) code |= FAR;
00101 
00102       return code;
00103     }
00104 
00105     bool clip(const Eigen::Vector3f& p0,
00106               const Eigen::Vector3f& p1,
00107               Eigen::Vector3f& q0,
00108               Eigen::Vector3f& q1);
00109 
00110 
00111   private:
00112     float xmin;
00113     float xmax;
00114     float ymin;
00115     float ymax;
00116     float zmin;
00117     float zmax;
00118 
00119     static const int FAR;    // 10 00 00
00120     static const int NEAR;   // 01 00 00
00121     static const int TOP;    // 00 10 00
00122     static const int BOTTOM; // 00 01 00
00123     static const int RIGHT;  // 00 00 10
00124     static const int LEFT;   // 00 00 01
00125   };
00126 
00127   const int CohenSutherlandClipping::FAR    = 32;
00128   const int CohenSutherlandClipping::NEAR   = 16;
00129   const int CohenSutherlandClipping::TOP    =  8;
00130   const int CohenSutherlandClipping::BOTTOM =  4;
00131   const int CohenSutherlandClipping::RIGHT  =  2;
00132   const int CohenSutherlandClipping::LEFT   =  1;
00133 }
00134 
00135 #include "cob_3d_fov_segmentation/impl/clipping.hpp"
00136 
00137 #endif


cob_3d_fov_segmentation
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:04:19