BRL-CAD
list.c
Go to the documentation of this file.
1 /* L I S T . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 #include "common.h"
22 
23 #include <stdio.h>
24 #include "vmath.h"
25 #include "plot3.h"
26 
27 /* Modes for internal flag */
28 #define TP_MARK 1 /* Draw marks */
29 #define TP_LINE 2 /* Draw lines */
30 
31 
32 void
33 tp_i2list(register FILE *fp, register int *x, register int *y, register int npoints)
34 
35 /* array of points */
36 /* array of points */
37 
38 {
39  if (npoints <= 0)
40  return;
41 
42  pl_move(fp, *x++, *y++);
43  while (--npoints > 0)
44  pl_cont(fp, *x++, *y++);
45 }
46 
47 
48 void
49 tp_2list(register FILE *fp, register double *x, register double *y, register int npoints)
50 
51 /* array of points */
52 /* array of points */
53 
54 {
55  if (npoints <= 0)
56  return;
57 
58  pd_move(fp, *x++, *y++);
59  while (--npoints > 0)
60  pd_cont(fp, *x++, *y++);
61 }
62 
63 
64 void
65 PL_FORTRAN(f2list, F2LIST)(FILE **fpp, float *x, float *y, int *n)
66 {
67  register int npoints = *n-1; /* FORTRAN uses 1-based subscripts */
68  register FILE *fp = *fpp;
69 
70  if (npoints <= 0)
71  return;
72 
73  pd_move(fp, *x++, *y++);
74  while (--npoints > 0)
75  pd_cont(fp, *x++, *y++);
76 }
77 
78 
79 void
80 tp_3list(FILE *fp, register double *x, register double *y, register double *z, register int npoints)
81 {
82  if (npoints <= 0)
83  return;
84 
85  pd_3move(fp, *x++, *y++, *z++);
86  while (--npoints > 0)
87  pd_3cont(fp, *x++, *y++, *z++);
88 }
89 
90 
91 void
92 PL_FORTRAN(f3list, F3LIST)(FILE **fpp, float *x, float *y, float *z, int *n)
93 {
94  register int npoints = *n-1; /* FORTRAN uses 1-based subscripts */
95  register FILE *fp = *fpp;
96 
97  if (npoints <= 0)
98  return;
99 
100  pd_3move(fp, *x++, *y++, *z++);
101  while (--npoints > 0)
102  pd_3cont(fp, *x++, *y++, *z++);
103 }
104 
105 
106 void
107 tp_2mlist(FILE *fp, register double *x, register double *y, int npoints, int flag, int mark, int interval, double size)
108 
109 
110 /* arrays of points */
111 
112 /* TP_MARK|TP_LINE */
113 /* marker character to use */
114 /* marker drawn every N points */
115 /* marker size */
116 {
117  register int i; /* index variable */
118  register int counter; /* interval counter */
119 
120  if (npoints <= 0)
121  return;
122 
123  if (flag & TP_LINE)
124  tp_2list(fp, x, y, npoints);
125  if (flag & TP_MARK) {
126  tp_2marker(fp, mark, *x++, *y++, size);
127  counter = 1; /* Already plotted one */
128  for (i=1; i<npoints; i++) {
129  if (counter >= interval) {
130  tp_2marker(fp, mark, *x, *y, size);
131  counter = 0; /* We made a mark */
132  }
133  x++; y++;
134  counter++; /* One more point done */
135  }
136  }
137 }
138 
139 
140 void
141 PL_FORTRAN(f2mlst, F2MLST)(FILE **fp, float *x, float *y, int *np, int *flag /* indicates user's mode request */, int *mark, int *interval, float *size)
142 {
143  register int i; /* index variable */
144  register int counter; /* interval counter */
145  register int npoints = *np-1;
146 
147  if (npoints <= 0)
148  return;
149 
150  if (*flag & TP_LINE)
151  PL_FORTRAN(f2list, F2LIST)(fp, x, y, np);
152  if (*flag & TP_MARK) {
153  tp_2marker(*fp, *mark, *x++, *y++, *size);
154  counter = 1; /* We already plotted one */
155  for (i=1; i<npoints; i++) {
156  if (counter >= *interval) {
157  tp_2marker(*fp, *mark, *x, *y, *size);
158  counter = 0; /* Made a mark */
159  }
160  x++; y++;
161  counter++; /* One more point done */
162  }
163  }
164 }
165 
166 
167 /*
168  * Local Variables:
169  * mode: C
170  * tab-width: 8
171  * indent-tabs-mode: t
172  * c-file-style: "stroustrup"
173  * End:
174  * ex: shiftwidth=4 tabstop=8
175  */
void pl_cont(register FILE *plotfp, int x, int y)
Definition: plot3.c:232
void PL_FORTRAN(f2list, F2LIST)
Definition: list.c:65
Header file for the BRL-CAD common definitions.
void tp_3list(FILE *fp, register double *x, register double *y, register double *z, register int npoints)
Definition: list.c:80
void tp_2marker(FILE *fp, register int c, double x, double y, double scale)
Definition: marker.c:54
void pd_3move(register FILE *plotfp, double x, double y, double z)
Definition: plot3.c:624
size_t counter[MAX_PSW]
Definition: bu_parallel.c:42
void pd_move(register FILE *plotfp, double x, double y)
Definition: plot3.c:463
void tp_2mlist(FILE *fp, register double *x, register double *y, int npoints, int flag, int mark, int interval, double size)
Definition: list.c:107
void pd_3cont(register FILE *plotfp, double x, double y, double z)
Definition: plot3.c:636
void pd_cont(register FILE *plotfp, double x, double y)
Definition: plot3.c:469
void tp_i2list(register FILE *fp, register int *x, register int *y, register int npoints)
Definition: list.c:33
#define TP_MARK
Definition: list.c:28
void pl_move(register FILE *plotfp, int x, int y)
Definition: plot3.c:220
void tp_2list(register FILE *fp, register double *x, register double *y, register int npoints)
Definition: list.c:49
#define TP_LINE
Definition: list.c:29