gre/3dclip.h

Go to the documentation of this file.
00001 /**
00002  * \file 3dclip.h <gre/3dclip.h>
00003  * \brief Clipping against unit cube [-1.0, 1.0] in homogenius coordinates
00004  *
00005  * \if NODOC
00006  * $Id: 3dclip.h_v 1.5 2003/09/15 13:48:59 fileserver!dwilliss Exp $
00007  *
00008  * $Log: 3dclip.h_v $
00009  * Revision 1.5  2003/09/15 13:48:59  fileserver!dwilliss
00010  * Doxygen
00011  *
00012  * Revision 1.4  2003/08/14 19:51:26  vdronov
00013  * added docs
00014  *
00015  * Revision 1.3  2003/07/30 13:31:19  mju
00016  * Add inclusion guards and ignore private section.
00017  *
00018  * Revision 1.2  2003/03/12 22:42:06  vdronov
00019  * added ClipPoint
00020  *
00021  * Revision 1.1  2003/03/10 15:05:04  vdronov
00022  * Initial revision
00023  * \endif
00024 **/
00025 
00026 #ifndef  INC_GRE_3DCLIP_H
00027 #define  INC_GRE_3DCLIP_H
00028 
00029 #ifndef  INC_MI32_POINT_H
00030    #include <mi32/point.h>
00031 #endif
00032 
00033 #ifndef  INC_MI32_DOUBLEAR_H
00034    #include <mi32/doublear.h>
00035 #endif
00036 
00037 namespace GRE {
00038 
00039 //! CLIPPING3D class.
00040 //!
00041 //!   This class is designed to provide static clipping methods against unit cube {-1.0, 1.0] 
00042 //! for each coordinate in homogenius coordinates.
00043 class CLIPPING3D {
00044    public:
00045 
00046       enum PLANE {
00047          PLANE_X_P_W = 0,
00048          PLANE_X_M_W = 1,
00049          PLANE_Y_P_W = 2,
00050          PLANE_Y_M_W = 3,
00051          PLANE_Z_P_W = 4,
00052          PLANE_Z_M_W = 5,
00053          PLANE_Count = 6
00054          };
00055 
00056       //! Clip point
00057       //!
00058       //! @return true if point inside unit cube
00059       static bool ClipPoint   (
00060          DPOINT3DH& point
00061          );
00062 
00063       //! Clip segment with endpoints point1 and point2. If segment intersects unit cube than
00064       //! point1 and point2 contains endpoints of intersection in return.
00065       //!
00066       //! @return true if segment intersects unit cube 
00067       static bool ClipSegment (
00068          DPOINT3DH& point1,
00069          DPOINT3DH& point2
00070          );
00071 
00072       //! Clip plane polygon input. If polygon intersects unit cube than
00073       //! output contains polygon of intersection in return.
00074 
00075       //!
00076       //! @return true if polygon intersects unit cube 
00077       static bool ClipPolygon (
00078          const DOUBLE_ARRAY<DPOINT3DH>& input,
00079          DOUBLE_ARRAY<DPOINT3DH>& output
00080          );
00081 
00082    private:
00083       #ifndef GENERATING_DOXYGEN_OUTPUT
00084 
00085       static bool Check (
00086          const double w1,
00087          const double w2,
00088          double& tmin,
00089          double& tmax
00090          );
00091 
00092       static bool ClipToPlane (
00093          const PLANE plane,
00094          const DOUBLE_ARRAY<DPOINT3DH>& input,
00095          DOUBLE_ARRAY<DPOINT3DH>& output
00096          );
00097 
00098       static bool CheckAbove (
00099          const double value
00100          ) { return (value > 0.0); }
00101 
00102       static bool AbovePlane  (
00103          const PLANE plane,
00104          const DPOINT3DH& point
00105          );
00106 
00107       //! Assuming an intersection point exists always (for efficency)
00108       static DPOINT3DH IntersectPlane  (
00109          const PLANE plane,
00110          const DPOINT3DH& point1,
00111          const DPOINT3DH& point2
00112          );
00113 
00114       static bool Intersect (
00115          const double w1,
00116          const double w2,
00117          double& t
00118          );
00119 
00120       #endif //!< GENERATING_DOXYGEN_OUTPUT
00121    };
00122 
00123 };    //! End of namespace
00124 
00125 #endif
00126 

Generated on Thu Apr 26 04:44:37 2007 for TNTsdk by  doxygen 1.5.2