Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HDWFMisc.h
1 #ifndef HDWFMISC_H
2 #define HDWFMISC_H
3 
4 #include "HW2DReaderCommon.h"
5 
6 struct Point;
7 
8 static inline void WT2HT(const WT_Integer32 in_x, const WT_Integer32 in_y,
9  float & out_x, float & out_y, float & out_z,
10  const HW2DReaderCommon * pW2DReaderCommon);
11 
12 static inline void WT2HT(const WT_Logical_Point & in, Point & out, const HW2DReaderCommon * pW2DReaderCommon);
13 
14 static inline void WT2HT (const float in_x, const float in_y,
15  float & out_x, float & out_y, float & out_z,
16  const HW2DReaderCommon * pW2DReaderCommon);
17 
18 static inline void WT2HT(const WT_Point_Set & in, Point * out, HW2DReaderCommon * pW2DReaderCommon);
19 
20 static inline void WT2HT(const WT_Logical_Point * points, int count, Point * out, HW2DReaderCommon * pW2DReaderCommon);
21 
22 struct Point
23 {
24  Point ()
25  {
26  x = 0;
27  y = 0;
28  z = 0;
29  }
30 
31  Point(const WT_Integer32 xx, const WT_Integer32 yy, const HW2DReaderCommon * pHW2DReaderCommon)
32  { WT2HT(xx, yy, x, y, z, pHW2DReaderCommon); }
33 
34  Point(const WT_Logical_Point p, const HW2DReaderCommon * pHW2DReaderCommon)
35  { WT2HT(p.m_x, p.m_y, x, y, z, pHW2DReaderCommon); }
36 
37  Point (const float xx, const float yy, const HW2DReaderCommon * pHW2DReaderCommon)
38  { WT2HT (xx, yy, x, y, z, pHW2DReaderCommon); }
39 
40  float x, y, z;
41 };
42 
43 class PointSet
44 {
45 public:
46  PointSet(const WT_Logical_Point * points, WT_Integer32 count, HW2DReaderCommon * pW2DReaderCommon);
47  PointSet(const WT_Point_Set & ps, HW2DReaderCommon * pW2DReaderCommon);
48  ~PointSet();
49 
50  Point * points() const { return m_pts; }
51  int count() const { return m_count; }
52  Point * GetPoint(int idx) { return &m_pts[idx]; }
53 
54 private:
55  void set(const WT_Logical_Point * points);
56  void set(const WT_Point_Set & in);
57 
58  Point m_pts_static[32];
59  Point * m_pts;
60  int m_count;
61  bool m_isDynamic;
62 
63  HW2DReaderCommon * m_pW2DReaderCommon;
64 };
65 
66 //update bounds functions
67 static inline void update_bounds(WT_Logical_Box & lhlb, const WT_Logical_Box & rhlb)
68 {
69  if( rhlb.m_min.m_x < lhlb.m_min.m_x )
70  lhlb.m_min.m_x = rhlb.m_min.m_x;
71 
72  if( rhlb.m_min.m_y < lhlb.m_min.m_y )
73  lhlb.m_min.m_y = rhlb.m_min.m_y;
74 
75  if( rhlb.m_max.m_x > lhlb.m_max.m_x )
76  lhlb.m_max.m_x = rhlb.m_max.m_x;
77 
78  if( rhlb.m_max.m_y > lhlb.m_max.m_y )
79  lhlb.m_max.m_y = rhlb.m_max.m_y;
80 }
81 
82 static inline void update_bounds(WT_Logical_Box & lhlb, const WT_Logical_Point & wt_point)
83 {
84  if( wt_point.m_x < lhlb.m_min.m_x )
85  lhlb.m_min.m_x = wt_point.m_x;
86  else if( wt_point.m_x > lhlb.m_max.m_x )
87  lhlb.m_max.m_x = wt_point.m_x;
88 
89  if( wt_point.m_y < lhlb.m_min.m_y )
90  lhlb.m_min.m_y = wt_point.m_y;
91  else if( wt_point.m_y > lhlb.m_max.m_y )
92  lhlb.m_max.m_y = wt_point.m_y;
93 }
94 
95 static inline void update_bounds(WT_Logical_Box & lhlb, const int nPoints, const WT_Logical_Point * pPoints)
96 {
97  for( int i = 0; i < nPoints; i++ )
98  update_bounds(lhlb, pPoints[i]);
99 }
100 
101 static void WT2HT(const WT_Integer32 in_x, const WT_Integer32 in_y,
102  float & out_x, float & out_y, float & out_z,
103  const HW2DReaderCommon * pW2DReaderCommon)
104 {
105  if(pW2DReaderCommon->m_CoordMode == HW2DReaderCommon::recentered_coords)
106  {
107  out_x = in_x - pW2DReaderCommon->m_x_extents;
108  out_y = in_y - pW2DReaderCommon->m_y_extents;
109  out_z = pW2DReaderCommon->m_z_plane;
110  }
111  else if(pW2DReaderCommon->m_CoordMode == HW2DReaderCommon::application_coords)
112  {
113  WT_Point3D pt_in((double)in_x, (double)in_y);
114  WT_Point3D pt_out = pW2DReaderCommon->m_pWhipUnits->transform_from_DWF_to_application(pt_in);
115  out_x = pt_out.m_x;
116  out_y = pt_out.m_y;
117  out_z = pW2DReaderCommon->m_z_plane;
118  }
119  else
120  {
121  out_x = in_x;
122  out_y = in_y;
123  out_z = pW2DReaderCommon->m_z_plane;
124  }
125 }
126 
127 static void WT2HT(const WT_Logical_Point & in, Point & out, const HW2DReaderCommon * pW2DReaderCommon)
128 { WT2HT(in.m_x, in.m_y, out.x, out.y, out.z, pW2DReaderCommon); }
129 
130 static void WT2HT (const float in_x, const float in_y,
131  float & out_x, float & out_y, float & out_z,
132  const HW2DReaderCommon * pW2DReaderCommon)
133 {
134  if (pW2DReaderCommon->m_CoordMode == HW2DReaderCommon::recentered_coords)
135  {
136  out_x = in_x - pW2DReaderCommon->m_x_extents;
137  out_y = in_y - pW2DReaderCommon->m_y_extents;
138  out_z = pW2DReaderCommon->m_z_plane;
139  }
140  else if(pW2DReaderCommon->m_CoordMode == HW2DReaderCommon::application_coords)
141  {
142  WT_Point3D pt_in((double)in_x, (double)in_y);
143  WT_Point3D pt_out = pW2DReaderCommon->m_pWhipUnits->transform_from_DWF_to_application(pt_in);
144  out_x = pt_out.m_x;
145  out_y = pt_out.m_y;
146  out_z = pW2DReaderCommon->m_z_plane;
147  }
148  else
149  {
150  out_x = in_x;
151  out_y = in_y;
152  out_z = pW2DReaderCommon->m_z_plane;
153  }
154 }
155 
156 static void WT2HT(const WT_Point_Set & in, Point * out, HW2DReaderCommon * pW2DReaderCommon)
157 {
158  WT_Logical_Point * wlp = in.points();
159 
160  for (int i = 0; i < in.count(); i++)
161  WT2HT(wlp[i], out[i], pW2DReaderCommon);
162 }
163 
164 static void WT2HT(const WT_Logical_Point * points, int count, Point * out, HW2DReaderCommon * pW2DReaderCommon)
165 {
166  for (int i = 0; i < count; i++)
167  WT2HT(points[i], out[i], pW2DReaderCommon);
168 }
169 
170 void eliminate_special_chars(char * zString);
171 void set_2d_view_mode(HBaseView * hbv);
172 void set_3d_view_mode(HBaseView * hbv);
173 
174 #endif //HDWFMISC_H
Definition: HDWFMisc.h:43
Definition: HDWFMisc.h:22
The HBaseView class defines and manages a view of model information.
Definition: HBaseView.h:332
Definition: HW2DReaderCommon.h:33