00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef lint
00050 static const char RCSid[] = "@(#)$Header: /cvsroot/brlcad/brlcad/src/libbn/symbol.c,v 14.10 2006/09/05 04:19:55 lbutler Exp $ (ARL)";
00051 #endif
00052
00053 #include "common.h"
00054
00055
00056
00057 #include <stdio.h>
00058 #ifdef HAVE_STRING_H
00059 #include <string.h>
00060 #else
00061 #include <strings.h>
00062 #endif
00063 #include <math.h>
00064
00065 #include "machine.h"
00066 #include "vmath.h"
00067 #include "plot3.h"
00068 #include "vectfont.h"
00069
00070
00071
00072
00073 void
00074 tp_3symbol(FILE *fp, char *string, fastf_t *origin, fastf_t *rot, double scale)
00075
00076
00077
00078
00079
00080 {
00081 register unsigned char *cp;
00082 double offset;
00083 int ysign;
00084 vect_t temp;
00085 vect_t loc;
00086 mat_t xlate_to_origin;
00087 mat_t mat;
00088
00089 if( string == NULL || *string == '\0' )
00090 return;
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 MAT_IDN( xlate_to_origin );
00103 MAT_DELTAS( xlate_to_origin, origin[X], origin[Y], origin[Z] );
00104 bn_mat_mul( mat, xlate_to_origin, rot );
00105
00106
00107 if( tp_cindex[040] == 0 ) tp_setup();
00108
00109
00110 offset = 0;
00111 for( cp = (unsigned char *)string ; *cp; cp++, offset += scale ) {
00112 register TINY *p;
00113 register int stroke;
00114
00115 VSET( temp, offset, 0, 0 );
00116 MAT4X3PNT( loc, mat, temp );
00117 pdv_3move( fp, loc );
00118
00119 for( p = tp_cindex[*cp]; (stroke= *p) != LAST; p++ ) {
00120 int draw;
00121
00122 if( stroke==NEGY ) {
00123 ysign = (-1);
00124 stroke = *++p;
00125 } else
00126 ysign = 1;
00127
00128
00129 if( stroke < 0 ) {
00130 stroke = -stroke;
00131 draw = 0;
00132 } else
00133 draw = 1;
00134
00135
00136 VSET( temp, (stroke/11) * 0.1 * scale + offset,
00137 (ysign * (stroke%11)) * 0.1 * scale, 0 );
00138 MAT4X3PNT( loc, mat, temp );
00139 if( draw )
00140 pdv_3cont( fp, loc );
00141 else
00142 pdv_3move( fp, loc );
00143 }
00144 }
00145 }
00146
00147
00148
00149
00150
00151 void
00152 tp_2symbol(FILE *fp, char *string, double x, double y, double scale, double theta)
00153
00154
00155
00156
00157
00158
00159 {
00160 mat_t mat;
00161 vect_t p;
00162
00163 bn_mat_angles( mat, 0.0, 0.0, theta );
00164 VSET( p, x, y, 0 );
00165 tp_3symbol( fp, string, p, mat, scale );
00166 }
00167
00168
00169
00170
00171 void
00172 PL_FORTRAN(f2symb, F2SYMB)( fp, string, x, y, scale, theta )
00173 FILE **fp;
00174 char *string;
00175 float *x;
00176 float *y;
00177 float *scale;
00178 float *theta;
00179 {
00180 char buf[128];
00181
00182 strncpy( buf, string, sizeof(buf)-1 );
00183 buf[sizeof(buf)-1] = '\0';
00184 tp_2symbol( *fp, buf, *x, *y, *scale, *theta );
00185 }
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195