00001 #ifndef HDWFMISC_H 00002 #define HDWFMISC_H 00003 00004 #include "HW2DReaderCommon.h" 00005 00006 struct Point; 00007 00008 static inline void WT2HT(const WT_Integer32 in_x, const WT_Integer32 in_y, 00009 float & out_x, float & out_y, float & out_z, 00010 const HW2DReaderCommon * pW2DReaderCommon); 00011 00012 static inline void WT2HT(const WT_Logical_Point & in, Point & out, const HW2DReaderCommon * pW2DReaderCommon); 00013 00014 static inline void WT2HT (const float in_x, const float in_y, 00015 float & out_x, float & out_y, float & out_z, 00016 const HW2DReaderCommon * pW2DReaderCommon); 00017 00018 static inline void WT2HT(const WT_Point_Set & in, Point * out, HW2DReaderCommon * pW2DReaderCommon); 00019 00020 static inline void WT2HT(const WT_Logical_Point * points, int count, Point * out, HW2DReaderCommon * pW2DReaderCommon); 00021 00022 struct Point 00023 { 00024 Point () 00025 { 00026 x = 0; 00027 y = 0; 00028 z = 0; 00029 } 00030 00031 Point(const WT_Integer32 xx, const WT_Integer32 yy, const HW2DReaderCommon * pHW2DReaderCommon) 00032 { WT2HT(xx, yy, x, y, z, pHW2DReaderCommon); } 00033 00034 Point(const WT_Logical_Point p, const HW2DReaderCommon * pHW2DReaderCommon) 00035 { WT2HT(p.m_x, p.m_y, x, y, z, pHW2DReaderCommon); } 00036 00037 Point (const float xx, const float yy, const HW2DReaderCommon * pHW2DReaderCommon) 00038 { WT2HT (xx, yy, x, y, z, pHW2DReaderCommon); } 00039 00040 float x, y, z; 00041 }; 00042 00043 class PointSet 00044 { 00045 public: 00046 PointSet(const WT_Logical_Point * points, WT_Integer32 count, HW2DReaderCommon * pW2DReaderCommon); 00047 PointSet(const WT_Point_Set & ps, HW2DReaderCommon * pW2DReaderCommon); 00048 ~PointSet(); 00049 00050 Point * points() const { return m_pts; } 00051 int count() const { return m_count; } 00052 Point * GetPoint(int idx) { return &m_pts[idx]; } 00053 00054 private: 00055 void set(const WT_Logical_Point * points); 00056 void set(const WT_Point_Set & in); 00057 00058 Point m_pts_static[32]; 00059 Point * m_pts; 00060 int m_count; 00061 bool m_isDynamic; 00062 00063 HW2DReaderCommon * m_pW2DReaderCommon; 00064 }; 00065 00066 //update bounds functions 00067 static inline void update_bounds(WT_Logical_Box & lhlb, const WT_Logical_Box & rhlb) 00068 { 00069 if( rhlb.m_min.m_x < lhlb.m_min.m_x ) 00070 lhlb.m_min.m_x = rhlb.m_min.m_x; 00071 00072 if( rhlb.m_min.m_y < lhlb.m_min.m_y ) 00073 lhlb.m_min.m_y = rhlb.m_min.m_y; 00074 00075 if( rhlb.m_max.m_x > lhlb.m_max.m_x ) 00076 lhlb.m_max.m_x = rhlb.m_max.m_x; 00077 00078 if( rhlb.m_max.m_y > lhlb.m_max.m_y ) 00079 lhlb.m_max.m_y = rhlb.m_max.m_y; 00080 } 00081 00082 static inline void update_bounds(WT_Logical_Box & lhlb, const WT_Logical_Point & wt_point) 00083 { 00084 if( wt_point.m_x < lhlb.m_min.m_x ) 00085 lhlb.m_min.m_x = wt_point.m_x; 00086 else if( wt_point.m_x > lhlb.m_max.m_x ) 00087 lhlb.m_max.m_x = wt_point.m_x; 00088 00089 if( wt_point.m_y < lhlb.m_min.m_y ) 00090 lhlb.m_min.m_y = wt_point.m_y; 00091 else if( wt_point.m_y > lhlb.m_max.m_y ) 00092 lhlb.m_max.m_y = wt_point.m_y; 00093 } 00094 00095 static inline void update_bounds(WT_Logical_Box & lhlb, const int nPoints, const WT_Logical_Point * pPoints) 00096 { 00097 for( int i = 0; i < nPoints; i++ ) 00098 update_bounds(lhlb, pPoints[i]); 00099 } 00100 00101 static void WT2HT(const WT_Integer32 in_x, const WT_Integer32 in_y, 00102 float & out_x, float & out_y, float & out_z, 00103 const HW2DReaderCommon * pW2DReaderCommon) 00104 { 00105 if(pW2DReaderCommon->m_CoordMode == HW2DReaderCommon::recentered_coords) 00106 { 00107 out_x = in_x - pW2DReaderCommon->m_x_extents; 00108 out_y = in_y - pW2DReaderCommon->m_y_extents; 00109 out_z = pW2DReaderCommon->m_z_plane; 00110 } 00111 else if(pW2DReaderCommon->m_CoordMode == HW2DReaderCommon::application_coords) 00112 { 00113 WT_Point3D pt_in((double)in_x, (double)in_y); 00114 WT_Point3D pt_out = pW2DReaderCommon->m_pWhipUnits->transform_from_DWF_to_application(pt_in); 00115 out_x = pt_out.m_x; 00116 out_y = pt_out.m_y; 00117 out_z = pW2DReaderCommon->m_z_plane; 00118 } 00119 else 00120 { 00121 out_x = in_x; 00122 out_y = in_y; 00123 out_z = pW2DReaderCommon->m_z_plane; 00124 } 00125 } 00126 00127 static void WT2HT(const WT_Logical_Point & in, Point & out, const HW2DReaderCommon * pW2DReaderCommon) 00128 { WT2HT(in.m_x, in.m_y, out.x, out.y, out.z, pW2DReaderCommon); } 00129 00130 static void WT2HT (const float in_x, const float in_y, 00131 float & out_x, float & out_y, float & out_z, 00132 const HW2DReaderCommon * pW2DReaderCommon) 00133 { 00134 if (pW2DReaderCommon->m_CoordMode == HW2DReaderCommon::recentered_coords) 00135 { 00136 out_x = in_x - pW2DReaderCommon->m_x_extents; 00137 out_y = in_y - pW2DReaderCommon->m_y_extents; 00138 out_z = pW2DReaderCommon->m_z_plane; 00139 } 00140 else if(pW2DReaderCommon->m_CoordMode == HW2DReaderCommon::application_coords) 00141 { 00142 WT_Point3D pt_in((double)in_x, (double)in_y); 00143 WT_Point3D pt_out = pW2DReaderCommon->m_pWhipUnits->transform_from_DWF_to_application(pt_in); 00144 out_x = pt_out.m_x; 00145 out_y = pt_out.m_y; 00146 out_z = pW2DReaderCommon->m_z_plane; 00147 } 00148 else 00149 { 00150 out_x = in_x; 00151 out_y = in_y; 00152 out_z = pW2DReaderCommon->m_z_plane; 00153 } 00154 } 00155 00156 static void WT2HT(const WT_Point_Set & in, Point * out, HW2DReaderCommon * pW2DReaderCommon) 00157 { 00158 WT_Logical_Point * wlp = in.points(); 00159 00160 for (int i = 0; i < in.count(); i++) 00161 WT2HT(wlp[i], out[i], pW2DReaderCommon); 00162 } 00163 00164 static void WT2HT(const WT_Logical_Point * points, int count, Point * out, HW2DReaderCommon * pW2DReaderCommon) 00165 { 00166 for (int i = 0; i < count; i++) 00167 WT2HT(points[i], out[i], pW2DReaderCommon); 00168 } 00169 00170 void eliminate_special_chars(char * zString); 00171 void set_2d_view_mode(HBaseView * hbv); 00172 void set_3d_view_mode(HBaseView * hbv); 00173 00174 #endif //HDWFMISC_H