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 #ifndef lint
00038 static const char RCSid[] = "@(#)$Header: /cvsroot/brlcad/brlcad/src/libbn/font.c,v 14.12 2006/09/07 01:19:17 lbutler Exp $ (ARL)";
00039 #endif
00040
00041 #include "common.h"
00042
00043
00044
00045 #include <stdio.h>
00046 #include <math.h>
00047 #ifdef HAVE_STRING_H
00048 #include <string.h>
00049 #endif
00050
00051 #include "machine.h"
00052 #include "vmath.h"
00053 #include "bu.h"
00054 #include "bn.h"
00055 #include "vectfont.h"
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 void
00075 bn_vlist_3string(struct bu_list *vhead,
00076 struct bu_list *free_hd,
00077 const char *string,
00078 const vect_t origin,
00079 const mat_t rot,
00080 double scale)
00081
00082
00083 {
00084 register unsigned char *cp;
00085 double offset;
00086 int ysign;
00087 vect_t temp;
00088 vect_t loc;
00089 mat_t xlate_to_origin;
00090 mat_t mat;
00091
00092 if( string == NULL || *string == '\0' )
00093 return;
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 MAT_IDN( xlate_to_origin );
00106 MAT_DELTAS( xlate_to_origin, origin[X], origin[Y], origin[Z] );
00107 bn_mat_mul( mat, xlate_to_origin, rot );
00108
00109
00110 if( tp_cindex[040] == 0 ) tp_setup();
00111
00112
00113 offset = 0;
00114 for( cp = (unsigned char *)string ; *cp; cp++, offset += scale ) {
00115 register TINY *p;
00116 register int stroke;
00117
00118 VSET( temp, offset, 0, 0 );
00119 MAT4X3PNT( loc, mat, temp );
00120 BN_ADD_VLIST(free_hd, vhead, loc, BN_VLIST_LINE_MOVE );
00121
00122 for( p = tp_cindex[*cp]; ((stroke= *p)) != LAST; p++ ) {
00123 int draw;
00124
00125 if( (stroke)==NEGY ) {
00126 ysign = (-1);
00127 stroke = *++p;
00128 } else
00129 ysign = 1;
00130
00131
00132 if( stroke < 0 ) {
00133 stroke = -stroke;
00134 draw = 0;
00135 } else
00136 draw = 1;
00137
00138
00139 VSET( temp, (stroke/11) * 0.1 * scale + offset,
00140 (ysign * (stroke%11)) * 0.1 * scale, 0 );
00141 MAT4X3PNT( loc, mat, temp );
00142 if( draw ) {
00143 BN_ADD_VLIST( free_hd, vhead, loc, BN_VLIST_LINE_DRAW );
00144 } else {
00145 BN_ADD_VLIST( free_hd, vhead, loc, BN_VLIST_LINE_MOVE );
00146 }
00147 }
00148 }
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 void
00170 bn_vlist_2string(struct bu_list *vhead,
00171 struct bu_list *free_hd,
00172 const char *string,
00173 double x,
00174 double y,
00175 double scale,
00176 double theta)
00177 {
00178 mat_t mat;
00179 vect_t p;
00180
00181 bn_mat_angles( mat, 0.0, 0.0, theta );
00182 VSET( p, x, y, 0 );
00183 bn_vlist_3string( vhead, free_hd, string, p, mat, scale );
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194