JunkBox_Lib++ (for Windows) 1.10.1
Loading...
Searching...
No Matches
Window.h
Go to the documentation of this file.
1#ifndef __JBXL_CPP_WINDOW_H_
2#define __JBXL_CPP_WINDOW_H_
3
11#include "Graph.h"
12
13//
14namespace jbxl {
15
16/*
17template <typename T> void wSetPixel(MSGraph<T> vp, double x, double y, int cc)
18template <typename T> T wGetPixel(MSGraph<T> vp, double x, double y)
19template <typename T> void wLine(MSGraph<T> vp, double x1, double y1, double x2, double y2, int cc)
20
21template <typename T> void wDraw(MSGraph<T>* vp, double x, double y, int cc)
22template <typename T> void wDraw_rel(MSGraph<T>* vp, double x, double y, int cc)
23
24template <typename T> void wSetPixel3D(MSGraph<T> vp, double x, double y, double z, int cc)
25template <typename T> T wGetPixel3D(MSGraph<T> vp, double x, double y, double z)
26template <typename T> void wLine3D(MSGraph<T> vp, double x1, double y1, double z1, double x2, double y2, double z2, int cc)
27
28template <typename T> void wDraw3D(MSGraph<T>* vp, double x, double y, double z, int cc)
29template <typename T> void wDraw_rel3D(MSGraph<T>* vp, double x, double y, double z, int cc)
30*/
31
32
43template <typename T> void wSetPixel(MSGraph<T> vp, double x, double y, int cc)
44{
45 int i = (int)((x - vp.wZeroX)*vp.wRateX);
46 int j = (int)((vp.wZeroY - y)*vp.wRateY);
47
48 if (i>=0 && i<vp.xs && j>=0 && j<vp.ys) vp.point(i, j) = (T)cc;
49}
50
51
63template <typename T> void wSetPixel3D(MSGraph<T> vp, double x, double y, double z, int cc)
64{
65 int i = (int)((vp.wZeroX - x)*vp.wRateX);
66 int j = (int)((y - vp.wZeroY)*vp.wRateY);
67 int k = (int)((vp.wZeroZ - z)*vp.wRateZ);
68
69 if (i>=0 && i<vp.xs && j>=0 && j<vp.ys && k>=0 && k<vp.zs) vp.point(i, j, k) = (T)cc;
70}
71
72
82template <typename T> T wGetPixel(MSGraph<T> vp, double x, double y)
83{
84 int i = (int)((x - vp.wZeroX)*vp.wRateX);
85 int j = (int)((vp.wZeroY - y)*vp.wRateY);
86
87 if (i>=0 && i<vp.xs && j>=0 && j<vp.ys) return vp.point(i, j);
88 else return vp.zero;
89}
90
91
102template <typename T> T wGetPixel3D(MSGraph<T> vp, double x, double y, double z)
103{
104 int i = (int)((vp.wZeroX - x)*vp.wRateX);
105 int j = (int)((y - vp.wZeroY)*vp.wRateY);
106 int k = (int)((vp.wZeroZ - z)*vp.wRateZ);
107
108 if (i>=0 && i<vp.xs && j>=0 && j<vp.ys && k>=0 && k<vp.zs) return vp.point(i, j, k);
109 else return vp.zero;
110}
111
112
125template <typename T> void wLine(MSGraph<T> vp, double x1, double y1, double x2, double y2, int cc)
126{
127 int i1, j1, i2, j2;
128
129 i1 = (int)((x1 - vp.wZeroX)*vp.wRateX);
130 i2 = (int)((x2 - vp.wZeroX)*vp.wRateX);
131 j1 = (int)((vp.wZeroY - y1)*vp.wRateY);
132 j2 = (int)((vp.wZeroY - y2)*vp.wRateY);
133
134 MSGraph_Line<T>(vp, i1, j1, i2, j2, cc);
135}
136
137
152template <typename T> void wLine3D(MSGraph<T> vp, double x1, double y1, double z1, double x2, double y2, double z2, int cc)
153{
154 int i1, j1, k1, i2, j2, k2;
155
156 i1 = (int)((vp.wZeroX - x1)*vp.wRateX);
157 i2 = (int)((vp.wZeroX - x2)*vp.wRateX);
158 j1 = (int)((y1 - vp.wZeroY)*vp.wRateY);
159 j2 = (int)((y2 - vp.wZeroY)*vp.wRateY);
160 k1 = (int)((vp.wZeroZ - z1)*vp.wRateZ);
161 k2 = (int)((vp.wZeroZ - z2)*vp.wRateZ);
162
163 MSGraph_Line3D<T>(vp, i1, j1, k1, i2, j2, k2, cc);
164}
165
166
167template <typename T> void wCircle3D(MSGraph<T> vp, Vector<double> ox, Vector<double> ex, double rr, int cc, int mode)
168{
169 double rate = Max(vp.wRateX, vp.wRateY);
170 rate = Max(rate, vp.wRateZ);
171 int r = (int)(rr*rate);
172
173 ox.x = (vp.wZeroX - ox.x)*vp.wRateX;
174 ox.y = (ox.y - vp.wZeroY)*vp.wRateY;
175 ox.z = (vp.wZeroZ - ox.z)*vp.wRateZ;
176
177 ex.x = -ex.x*vp.wRateX;
178 ex.y = ex.y*vp.wRateY;
179 ex.z = -ex.z*vp.wRateZ;
180
181 MSGraph_Circle3D(vp, ox, ex, r, cc, mode);
182}
183
184
195template <typename T> void wDraw(MSGraph<T>* vp, double x, double y, int cc)
196{
197 wLine<T>(*vp, vp->wNowX, vp->wNowY, x, y, cc);
198 vp->wMove(x, y);
199}
200
201
213template <typename T> void wDraw3D(MSGraph<T>* vp, double x, double y, double z, int cc)
214{
215 wLine3D<T>(*vp, vp->wNowX, vp->wNowY, vp->wNowZ, x, y, z, cc);
216 vp->wMove(x, y, z);
217}
218
219
230template <typename T> void wDraw_rel(MSGraph<T>* vp, double x, double y, int cc)
231{
232 double x2 = vp->wNowX + x;
233 double y2 = vp->wNowY + y;
234
235 wLine<T>(*vp, vp->wNowX, vp->wNowY, x2, y2, cc);
236 vp->wMove(x2, y2);
237}
238
239
251template <typename T> void wDraw_rel3D(MSGraph<T>* vp, double x, double y, double z, int cc)
252{
253 double x2 = vp->wNowX + x;
254 double y2 = vp->wNowY + y;
255 double z2 = vp->wNowZ + z;
256
257 wLine3D<T>(*vp, vp->wNowX, vp->wNowY, vp->wNowZ, x2, y2, z2, cc);
258 vp->wMove(x2, y2, z2);
259}
260
261
262} // namespace
263
264
265#endif
グラフィックデータ定義用ヘッダ for C++
double wNowZ
ペンの現地点の z成分(ワールド座標系)
Definition Gdata.h:104
double wZeroX
スクリーン座標系の原点に対するワールド座標系の x成分.
Definition Gdata.h:99
double wZeroY
スクリーン座標系の原点に対するワールド座標系の y成分.
Definition Gdata.h:100
T & point(int x, int y=0, int z=0)
座標(x,y,z)の画素値の参照
Definition Gdata.h:114
int zs
zサイズ. 4Byte. 2Dの場合は 1.
Definition Gdata.h:80
double wRateY
ワールド座標系の y成分1ドットに対するスクリーン座標系のドット数.
Definition Gdata.h:97
double wZeroZ
スクリーン座標系の原点に対するワールド座標系の z成分.
Definition Gdata.h:101
double wRateZ
ワールド座標系の z成分1ドットに対するスクリーン座標系のドット数.
Definition Gdata.h:98
double wNowX
ペンの現地点の x成分(ワールド座標系)
Definition Gdata.h:102
T zero
画素値のゼロ位.
Definition Gdata.h:82
int ys
yサイズ. 4Byte.
Definition Gdata.h:79
double wNowY
ペンの現地点の y成分(ワールド座標系)
Definition Gdata.h:103
void wMove(double x, double y, double z=0.0)
Definition Gdata.h:154
double wRateX
ワールド座標系の x成分1ドットに対するスクリーン座標系のドット数.
Definition Gdata.h:96
#define Max(x, y)
Definition common.h:247
Definition Brep.h:29
T wGetPixel(MSGraph< T > vp, double x, double y)
Definition Window.h:82
void wSetPixel(MSGraph< T > vp, double x, double y, int cc)
Definition Window.h:43
void wLine3D(MSGraph< T > vp, double x1, double y1, double z1, double x2, double y2, double z2, int cc)
Definition Window.h:152
void wDraw_rel3D(MSGraph< T > *vp, double x, double y, double z, int cc)
Definition Window.h:251
void wLine(MSGraph< T > vp, double x1, double y1, double x2, double y2, int cc)
Definition Window.h:125
T wGetPixel3D(MSGraph< T > vp, double x, double y, double z)
Definition Window.h:102
void wDraw3D(MSGraph< T > *vp, double x, double y, double z, int cc)
Definition Window.h:213
void wDraw(MSGraph< T > *vp, double x, double y, int cc)
Definition Window.h:195
void wCircle3D(MSGraph< T > vp, Vector< double > ox, Vector< double > ex, double rr, int cc, int mode)
Definition Window.h:167
void MSGraph_Circle3D(MSGraph< T > vp, Vector<> ox, Vector<> ex, int rr, int cc, int mode=OFF)
Definition Graph.h:1263
void wSetPixel3D(MSGraph< T > vp, double x, double y, double z, int cc)
Definition Window.h:63
void wDraw_rel(MSGraph< T > *vp, double x, double y, int cc)
Definition Window.h:230