19 #include <grass/gstypes.h>
22 static void init_cplane(
void);
24 static float Cp_pt[4], Cp_norm[MAX_CPLANES][4];
25 static float Cp_trans[MAX_CPLANES][3], Cp_rot[MAX_CPLANES][3];
26 static int Cp_ison[MAX_CPLANES];
28 static void init_cplane(
void)
35 for (i = 0; i < MAX_CPLANES; i++) {
38 Cp_norm[i][
Y] = Cp_norm[i][Z] = 0.0;
40 Cp_rot[i][
X] = Cp_trans[i][
X] = 0.0;
41 Cp_rot[i][
Y] = Cp_trans[i][
Y] = 0.0;
42 Cp_rot[i][Z] = Cp_trans[i][Z] = 0.0;
57 float sx, sy, sz, ppt[3];
66 ppt[0] = (pt[0] + Cp_pt[0]) * sx;
67 ppt[1] = (pt[1] + Cp_pt[1]) * sy;
68 ppt[2] = (pt[2] + Cp_pt[2] - zmin) * sz;
70 params[0] = norm[0] * sx;
71 params[1] = norm[1] * sy;
72 params[2] = norm[2] * sz;
74 params[3] = -ppt[0] * params[0] - ppt[1] * params[1] - ppt[2] * params[2];
90 for (i = 0; i < MAX_CPLANES; i++) {
106 static int first = 1;
146 for (i = 0; i < MAX_CPLANES; i++) {
147 onstate[i] = Cp_ison[i];
167 for (ons = i = 0; i < MAX_CPLANES; i++) {
169 thru[
X] = Cp_pt[
X] + Cp_trans[ons][
X];
170 thru[
Y] = Cp_pt[
Y] + Cp_trans[ons][
Y];
171 thru[Z] = Cp_pt[Z] + Cp_trans[ons][Z];
172 planes[ons][
X] = -Cp_norm[ons][
X];
173 planes[ons][
Y] = -Cp_norm[ons][
Y];
174 planes[ons][Z] = -Cp_norm[ons][Z];
175 planes[ons][W] = -(DOT3(planes[ons], thru));
192 v[0][
X] = v[0][W] = 1.0;
193 v[0][
Y] = v[0][Z] = 0.0;
196 P_rot(Cp_rot[num][Z],
'z');
197 P_rot(Cp_rot[num][
Y],
'y');
198 P_rot(Cp_rot[num][
X],
'x');
231 Cp_trans[
num][
X] = tx;
232 Cp_trans[
num][
Y] = ty;
233 Cp_trans[
num][Z] = tz;
250 float len, dir[3], bgn[2], end[2], px, py, fencenorm[3];
253 if ((was_on = Cp_ison[cpnum])) {
259 dir[
X] = -Cp_norm[cpnum][
Y];
260 dir[
Y] = Cp_norm[cpnum][
X];
263 px = Cp_trans[cpnum][
X] + Cp_pt[
X];
264 py = Cp_trans[cpnum][
Y] + Cp_pt[
Y];
273 bgn[
X] = px + len * dir[
X];
274 bgn[
Y] = py + len * dir[
Y];
275 end[
X] = px - len * dir[
X];
276 end[
Y] = py - len * dir[
Y];
278 fencenorm[
X] = -Cp_norm[cpnum][
X];
279 fencenorm[
Y] = -Cp_norm[cpnum][
Y];
280 fencenorm[Z] = -Cp_norm[cpnum][Z];
304 for (i = 0; i < MAX_CPLANES; i++) {
323 Cp_pt[
Y] + Cp_trans[num][
Y], Cp_pt[Z] + Cp_trans[num][Z]);
352 for (i = 0; i < MAX_CPLANES; i++) {
void gsd_zwritemask(unsigned long n)
Write out z-mask.
void P_transform(int num_vert, float(*in)[4], float(*out)[4])
Transform array of vectors using current T matrix.
void gsd_cplane_settrans(int num, float tx, float ty, float tz)
ADD.
int gs_get_datacenter(float *cen)
Get data center point.
int gs_get_data_avg_zmax(float *azmax)
Get average z-max value.
void gsd_def_clipplane(int num, double *params)
Define clip plane.
void gsd_do_scale(int doexag)
Set current scale.
void gsd_cplane_off(int num)
Turn off clip plane.
int GS_v3norm(float *v1)
Change v1 so that it is a unit vector (2D)
void gsd_bgnpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
void P_rot(float angle, char axis)
Rotate matrix.
int P_popmatrix(void)
Pop top of matrix stack, placing it into the current transformation matrix.
void gsd_color_func(unsigned int col)
Set current color.
void gsd_get_cplanes_state(int *onstate)
Get cplane state.
void gsd_update_cpnorm(int num)
ADD.
void gsd_translate(float dx, float dy, float dz)
Multiply the current matrix by a translation matrix.
int gsd_wall(float *bgn, float *end, float *norm)
ADD.
void gsd_update_cplanes(void)
Update cplaces.
int GS_get_zrange(float *min, float *max, int doexag)
Get z-extent for all loaded surfaces.
void gsd_pushmatrix(void)
Push the current matrix stack.
int P_pushmatrix(void)
Push current transformation matrix onto matrix stack.
void gsd_rot(float angle, char axis)
ADD.
void gsd_draw_cplane_fence(geosurf *surf1, geosurf *surf2, int cpnum)
ADD.
void gsd_blend(int yesno)
Specify pixel arithmetic.
void gsd_vert_func(float *pt)
ADD.
void gsd_cplane_setrot(int num, float rx, float ry, float rz)
ADD.
void gsd_endpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
int gsd_get_cplanes(Point4 *planes)
Get cplaces.
int GS_dv3norm(double *dv1)
Changes v1 so that it is a unit vector.
void gsd_popmatrix(void)
Pop the current matrix stack.
int GS_get_longdim(float *dim)
Get largest dimension.
void gsd_cplane_on(int num)
ADD.
float GS_P2distance(float *from, float *to)
Calculate distance in plane.
unsigned int GS_default_draw_color(void)
Get default draw color.
void gsd_scale(float xs, float ys, float zs)
Multiply the current matrix by a general scaling matrix.
float GS_global_exag(void)
Get global z-exag value.
void gsd_set_clipplane(int num, int able)
Set clip plane.
void GS_get_scale(float *sx, float *sy, float *sz, int doexag)
Get axis scale.
void gsd_def_cplane(int num, float *pt, float *norm)
Define cplace.
void gsd_draw_cplane(int num)
Draw cplane.