~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Cross Reference
BRL-CAD/src/libged/typein.c

Version: ~ [ 7.24.0 ] ~

  1 /*                        T Y P E I N . C
  2  * BRL-CAD
  3  *
  4  * Copyright (c) 1985-2013 United States Government as represented by
  5  * the U.S. Army Research Laboratory.
  6  *
  7  * This program 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 program 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 /** @file libged/typein.c
 22  *
 23  * The "in" command allows solid parameters to be entered via the keyboard.
 24  *
 25  */
 26 
 27 #include "common.h"
 28 
 29 #include <stdlib.h>
 30 #include <ctype.h>
 31 #include <string.h>
 32 #include "bio.h"
 33 
 34 #include "rtgeom.h"
 35 #include "wdb.h"
 36 
 37 #include "./ged_private.h"
 38 
 39 
 40 static char *p_half[] = {
 41     "Enter X, Y, Z of outward pointing normal vector: ",
 42     "Enter Y: ",
 43     "Enter Z: ",
 44     "Enter the distance from the origin: "
 45 };
 46 
 47 
 48 static char *p_dsp_v4[] = {
 49     "Enter name of displacement-map file: ",
 50     "Enter width of displacement-map (number of values): ",
 51     "Enter length of displacement-map (number of values): ",
 52     "Normal Interpolation? 0=no 1=yes: ",
 53     "Cell size: ",
 54     "Unit elevation: "
 55 };
 56 
 57 
 58 static char *p_dsp_v5[] = {
 59     "Take data from file or database binary object [f|o]:",
 60     "Enter name of file/object: ",
 61     "Enter width of displacement-map (number of values): ",
 62     "Enter length of displacement-map (number of values): ",
 63     "Normal Interpolation? 0=no 1=yes: ",
 64     "Cut direction [ad|lR|Lr] ",
 65     "Cell size: ",
 66     "Unit elevation: "
 67 };
 68 
 69 
 70 static char *p_hf[] = {
 71     "Enter name of control file (or \"\" for none): ",
 72     "Enter name of data file (containing heights): ",
 73     "Enter 'cv' style format of data [h|n][s|u]c|s|i|l|d|8|16|32|64: ",
 74     "Enter number of values in 'x' direction: ",
 75     "Enter number of values in 'y' direction: ",
 76     "Enter '1' if data can be stored as 'short' in memory, or 0: ",
 77     "Enter factor to convert file data to mm: ",
 78     "Enter coordinates to position HF solid: ",
 79     "Enter Y coordinate: ",
 80     "Enter Z coordinate: ",
 81     "Enter direction vector for 'x' direction: ",
 82     "Enter Y coordinate: ",
 83     "Enter Z coordinate: ",
 84     "Enter direction vector for 'y' direction: ",
 85     "Enter Y coordinate: ",
 86     "Enter Z coordinate: ",
 87     "Enter length of HF in 'x' direction: ",
 88     "Enter width of HF in 'y' direction: ",
 89     "Enter scale factor for height (after conversion to mm): "
 90 };
 91 
 92 
 93 static char *p_ebm[] = {
 94     "Enter name of bit-map file: ",
 95     "Enter width of bit-map (number of cells): ",
 96     "Enter height of bit-map (number of cells): ",
 97     "Enter extrusion distance: "
 98 };
 99 
100 
101 static char *p_submodel[] = {
102     "Enter name of treetop: ",
103     "Enter space partitioning method: ",
104     "Enter name of .g file (or \"\" for none): "
105 };
106 
107 
108 static char *p_vol[] = {
109     "Enter name of file containing voxel data: ",
110     "Enter X, Y, Z dimensions of file (number of cells): ",
111     "Enter Y dimension of file (number of cells): ",
112     "Enter Z dimension of file (number of cells): ",
113     "Enter lower threshold value: ",
114     "Enter upper threshold value: ",
115     "Enter X, Y, Z dimensions of a cell: ",
116     "Enter Y dimension of a cell: ",
117     "Enter Z dimension of a cell: ",
118 };
119 
120 
121 static char *p_bot[] = {
122     "Enter number of vertices: ",
123     "Enter number of triangles: ",
124     "Enter mode (1->surface, 2->solid, 3->plate): ",
125     "Enter triangle orientation (1->unoriented, 2->counter-clockwise, 3->clockwise): ",
126     "Enter X, Y, Z",
127     "Enter Y",
128     "Enter Z",
129     "Enter three vertex numbers",
130     "Enter second vertex number",
131     "Enter third vertex number",
132     "Enter face_mode (0->centered, 1->appended) and thickness",
133     "Enter thickness"
134 };
135 
136 
137 static char *p_arbn[] = {
138     "Enter number of planes: ",
139     "Enter coefficients",
140     "Enter Y-coordinate of normal",
141     "Enter Z-coordinate of normal",
142     "Enter distance of plane along normal from origin"
143 };
144 
145 
146 static char *p_pipe[] = {
147     "Enter number of points: ",
148     "Enter X, Y, Z, inner diameter, outer diameter, and bend radius for first point: ",
149     "Enter Y: ",
150     "Enter Z: ",
151     "Enter inner diameter: ",
152     "Enter outer diameter: ",
153     "Enter bend radius: ",
154     "Enter X, Y, Z, inner diameter, outer diameter, and bend radius",
155     "Enter Y",
156     "Enter Z",
157     "Enter inner diameter",
158     "Enter outer diameter",
159     "Enter bend radius"
160 };
161 
162 
163 static char *p_ars[] = {
164     "Enter number of points per waterline, and number of waterlines: ",
165     "Enter number of waterlines: ",
166     "Enter X, Y, Z for First row point: ",
167     "Enter Y for First row point: ",
168     "Enter Z for First row point: ",
169     "Enter X  Y  Z",
170     "Enter Y",
171     "Enter Z",
172 };
173 
174 
175 static char *p_arb[] = {
176     "Enter X, Y, Z for point 1: ",
177     "Enter Y: ",
178     "Enter Z: ",
179     "Enter X, Y, Z for point 2: ",
180     "Enter Y: ",
181     "Enter Z: ",
182     "Enter X, Y, Z for point 3: ",
183     "Enter Y: ",
184     "Enter Z: ",
185     "Enter X, Y, Z for point 4: ",
186     "Enter Y: ",
187     "Enter Z: ",
188     "Enter X, Y, Z for point 5: ",
189     "Enter Y: ",
190     "Enter Z: ",
191     "Enter X, Y, Z for point 6: ",
192     "Enter Y: ",
193     "Enter Z: ",
194     "Enter X, Y, Z for point 7: ",
195     "Enter Y: ",
196     "Enter Z: ",
197     "Enter X, Y, Z for point 8: ",
198     "Enter Y: ",
199     "Enter Z: "
200 };
201 
202 
203 static char *p_sph[] = {
204     "Enter X, Y, Z of vertex: ",
205     "Enter Y: ",
206     "Enter Z: ",
207     "Enter radius: "
208 };
209 
210 
211 static char *p_ellg[] = {
212     "Enter X, Y, Z of focus point 1: ",
213     "Enter Y: ",
214     "Enter Z: ",
215     "Enter X, Y, Z of focus point 2: ",
216     "Enter Y: ",
217     "Enter Z: ",
218     "Enter axis length L: "
219 };
220 
221 
222 static char *p_ell1[] = {
223     "Enter X, Y, Z of vertex: ",
224     "Enter Y: ",
225     "Enter Z: ",
226     "Enter X, Y, Z of vector A: ",
227     "Enter Y: ",
228     "Enter Z: ",
229     "Enter radius of revolution: "
230 };
231 
232 
233 static char *p_ell[] = {
234     "Enter X, Y, Z of vertex: ",
235     "Enter Y: ",
236     "Enter Z: ",
237     "Enter X, Y, Z of vector A: ",
238     "Enter Y: ",
239     "Enter Z: ",
240     "Enter X, Y, Z of vector B: ",
241     "Enter Y: ",
242     "Enter Z: ",
243     "Enter X, Y, Z of vector C: ",
244     "Enter Y: ",
245     "Enter Z: "
246 };
247 
248 
249 static char *p_tor[] = {
250     "Enter X, Y, Z of vertex: ",
251     "Enter Y: ",
252     "Enter Z: ",
253     "Enter X, Y, Z of normal vector: ",
254     "Enter Y: ",
255     "Enter Z: ",
256     "Enter radius 1: ",
257     "Enter radius 2: "
258 };
259 
260 
261 static char *p_rcc[] = {
262     "Enter X, Y, Z of vertex: ",
263     "Enter Y: ",
264     "Enter Z: ",
265     "Enter X, Y, Z of height (H) vector: ",
266     "Enter Y: ",
267     "Enter Z: ",
268     "Enter radius: "
269 };
270 
271 
272 static char *p_tec[] = {
273     "Enter X, Y, Z of vertex: ",
274     "Enter Y: ",
275     "Enter Z: ",
276     "Enter X, Y, Z of height (H) vector: ",
277     "Enter Y: ",
278     "Enter Z: ",
279     "Enter X, Y, Z of vector A: ",
280     "Enter Y: ",
281     "Enter Z: ",
282     "Enter X, Y, Z of vector B: ",
283     "Enter Y: ",
284     "Enter Z: ",
285     "Enter ratio: "
286 };
287 
288 
289 static char *p_rec[] = {
290     "Enter X, Y, Z of vertex: ",
291     "Enter Y: ",
292     "Enter Z: ",
293     "Enter X, Y, Z of height (H) vector: ",
294     "Enter Y: ",
295     "Enter Z: ",
296     "Enter X, Y, Z of vector A: ",
297     "Enter Y: ",
298     "Enter Z: ",
299     "Enter X, Y, Z of vector B: ",
300     "Enter Y: ",
301     "Enter Z: "
302 };
303 
304 
305 static char *p_trc[] = {
306     "Enter X, Y, Z of vertex: ",
307     "Enter Y: ",
308     "Enter Z: ",
309     "Enter X, Y, Z of height (H) vector: ",
310     "Enter Y: ",
311     "Enter Z: ",
312     "Enter radius of base: ",
313     "Enter radius of top: "
314 };
315 
316 
317 static char *p_tgc[] = {
318     "Enter X, Y, Z of vertex: ",
319     "Enter Y: ",
320     "Enter Z: ",
321     "Enter X, Y, Z of height (H) vector: ",
322     "Enter Y: ",
323     "Enter Z: ",
324     "Enter X, Y, Z of vector A: ",
325     "Enter Y: ",
326     "Enter Z: ",
327     "Enter X, Y, Z of vector B: ",
328     "Enter Y: ",
329     "Enter Z: ",
330     "Enter scalar c: ",
331     "Enter scalar d: "
332 };
333 
334 
335 static char *p_box[] = {
336     "Enter X, Y, Z of vertex: ",
337     "Enter Y: ",
338     "Enter Z: ",
339     "Enter X, Y, Z of vector H: ",
340     "Enter Y: ",
341     "Enter Z: ",
342     "Enter X, Y, Z of vector W: ",
343     "Enter Y: ",
344     "Enter Z: ",
345     "Enter X, Y, Z of vector D: ",
346     "Enter Y: ",
347     "Enter Z: "
348 };
349 
350 
351 static char *p_rpp[] = {
352     "Enter XMIN, XMAX, YMIN, YMAX, ZMIN, ZMAX: ",
353     "Enter XMAX: ",
354     "Enter YMIN, YMAX, ZMIN, ZMAX: ",
355     "Enter YMAX: ",
356     "Enter ZMIN, ZMAX: ",
357     "Enter ZMAX: "
358 };
359 
360 
361 static char *p_orpp[] = {
362     "Enter XMAX, YMAX, ZMAX: ",
363     "Enter YMAX, ZMAX: ",
364     "Enter ZMAX: "
365 };
366 
367 
368 static char *p_rpc[] = {
369     "Enter X, Y, Z of vertex: ",
370     "Enter Y: ",
371     "Enter Z: ",
372     "Enter X, Y, Z, of vector H: ",
373     "Enter Y: ",
374     "Enter Z: ",
375     "Enter X, Y, Z, of vector B: ",
376     "Enter Y: ",
377     "Enter Z: ",
378     "Enter rectangular half-width, r: "
379 };
380 
381 
382 static char *p_part[] = {
383     "Enter X, Y, Z of vertex: ",
384     "Enter Y: ",
385     "Enter Z: ",
386     "Enter X, Y, Z, of vector H: ",
387     "Enter Y: ",
388     "Enter Z: ",
389     "Enter v end radius: ",
390     "Enter h end radius: "
391 };
392 
393 
394 static char *p_rhc[] = {
395     "Enter X, Y, Z of vertex: ",
396     "Enter Y: ",
397     "Enter Z: ",
398     "Enter X, Y, Z, of vector H: ",
399     "Enter Y: ",
400     "Enter Z: ",
401     "Enter X, Y, Z, of vector B: ",
402     "Enter Y: ",
403     "Enter Z: ",
404     "Enter rectangular half-width, r: ",
405     "Enter apex-to-asymptotes distance, c: "
406 };
407 
408 
409 static char *p_epa[] = {
410     "Enter X, Y, Z of vertex: ",
411     "Enter Y: ",
412     "Enter Z: ",
413     "Enter X, Y, Z, of vector H: ",
414     "Enter Y: ",
415     "Enter Z: ",
416     "Enter X, Y, Z, of vector A: ",
417     "Enter Y: ",
418     "Enter Z: ",
419     "Enter magnitude of vector B: "
420 };
421 
422 
423 static char *p_ehy[] = {
424     "Enter X, Y, Z of vertex: ",
425     "Enter Y: ",
426     "Enter Z: ",
427     "Enter X, Y, Z, of vector H: ",
428     "Enter Y: ",
429     "Enter Z: ",
430     "Enter X, Y, Z, of vector A: ",
431     "Enter Y: ",
432     "Enter Z: ",
433     "Enter magnitude of vector B: ",
434     "Enter apex-to-asymptotes distance, c: "
435 };
436 
437 
438 static char *p_hyp[] = {
439     "Enter X, Y, Z of vertex: ",
440     "Enter Y: ",
441     "Enter Z: ",
442     "Enter X, Y, Z, of vector H: ",
443     "Enter Y: ",
444     "Enter Z: ",
445     "Enter X, Y, Z, of vector A: ",
446     "Enter Y: ",
447     "Enter Z: ",
448     "Enter magnitude of vector B: ",
449     "Enter neck to base ratio, c (0, 1): "
450 };
451 
452 
453 static char *p_eto[] = {
454     "Enter X, Y, Z of vertex: ",
455     "Enter Y: ",
456     "Enter Z: ",
457     "Enter X, Y, Z, of normal vector: ",
458     "Enter Y: ",
459     "Enter Z: ",
460     "Enter radius of revolution, r: ",
461     "Enter X, Y, Z, of vector C: ",
462     "Enter Y: ",
463     "Enter Z: ",
464     "Enter magnitude of elliptical semi-minor axis, d: "
465 };
466 
467 
468 static char *p_binunif[] = {
469     "Enter minor type (f, d, c, s, i, L, C, S, I, or L): ",
470     "Enter name of file containing the data: ",
471     "Enter number of values to read (-1 for entire file): "
472 };
473 
474 
475 static char *p_extrude[] = {
476     "Enter X, Y, Z of vertex: ",
477     "Enter Y: ",
478     "Enter Z: ",
479     "Enter X, Y, Z of H: ",
480     "Enter Y: ",
481     "Enter Z: ",
482     "Enter X, Y, Z of A: ",
483     "Enter Y: ",
484     "Enter Z: ",
485     "Enter X, Y, Z of B: ",
486     "Enter Y: ",
487     "Enter Z: ",
488     "Enter name of sketch: ",
489     NULL
490 };
491 
492 
493 static char *p_grip[] = {
494     "Enter X, Y, Z of center: ",
495     "Enter Y: ",
496     "Enter Z: ",
497     "Enter X, Y, Z of normal: ",
498     "Enter Y: ",
499     "Enter Z: ",
500     "Enter Magnitude: ",
501     NULL
502 };
503 
504 
505 static char *p_superell[] = {
506     "Enter X, Y, Z of superellipse vertex: ",
507     "Enter Y: ",
508     "Enter Z: ",
509     "Enter X, Y, Z of vector A: ",
510     "Enter Y: ",
511     "Enter Z: ",
512     "Enter X, Y, Z of vector B: ",
513     "Enter Y: ",
514     "Enter Z: ",
515     "Enter X, Y, Z of vector C: ",
516     "Enter Y: ",
517     "Enter Z: ",
518     "Enter n, e of north-south and east-west power: ",
519     "Enter e: "
520 };
521 
522 
523 static char *p_metaball[] = {
524     "Enter render method: ",
525     "Enter threshold: ",
526     "Enter number of points: ",
527     "Enter X, Y, Z, field strength: ",
528     "Enter Y: ",
529     "Enter Z: ",
530     "Enter field strength: ",
531     "Enter X, Y, Z, field strength",
532     "Enter Y",
533     "Enter Z",
534     "Enter field strength"
535 };
536 
537 
538 static char *p_revolve[] = {
539     "Enter X, Y, Z of vertex: ",
540     "Enter Y: ",
541     "Enter Z: ",
542     "Enter X, Y, Z of revolve axis: ",
543     "Enter Y: ",
544     "Enter Z: ",
545     "Enter X, Y, Z of vector in start plane: ",
546     "Enter Y: ",
547     "Enter Z: ",
548     "Enter angle: ",
549     "Enter name of sketch: "
550 };
551 
552 
553 static char *p_pnts[] = {
554     "Are points in a file (yes/no)? ",
555     "Enter number of points (-1 for auto): ",
556     "Are the points orientated (yes/no)? ",
557     "Do the points have color values (yes/no)? ",
558     "Do the points differ in size (yes/no)? ",
559     "Enter default point size (>= 0.0): ",
560     "Enter X, Y, Z position",
561     "Enter Y position component",
562     "Enter Z position component",
563     "Enter X, Y, Z orientation vector",
564     "Enter Y orientation vector component",
565     "Enter Z orientation vector component",
566     "Enter R, G, B color values (0 to 255)",
567     "Enter G component color value",
568     "Enter B component color value",
569     "Enter point size (>= 0.0, -1 for default)",
570     "Enter point file path and name: ",
571     "Enter file data format (px, py, pz, cr, cg, cb, s, nx, ny, nz): ",
572     "Enter file data units ([mm|cm|m|in|ft]): "
573 };
574 
575 
576 /**
577  * helper function that infers a boolean value from a given string
578  * returning 0 or 1 for false and true respectively.
579  *
580  * False values are any answers that are case-insensitive variants of
581  * 0, "no", "false", and whitespace-only, NULL, or empty strings.
582  *
583  * True values are any answers that are not false.
584  */
585 static int
586 booleanize(const char *answer)
587 {
588     int idx = 0;
589     const char *ap;
590     static const char *noes[] = {
591         "",
592         "n",
593         "no",
594         "false",
595         NULL
596     };
597 
598     if (!answer || (strlen(answer) <= 0)) {
599         return 0;
600     }
601 
602     ap = answer;
603     while (ap[0] != '\0' && isspace((int)ap[0])) {
604         ap++;
605     }
606     if (ap[0] == '\0') {
607         return 0;
608     }
609 
610     ap = noes[idx];
611     while (ap && ap[0] != '\0') {
612         if (BU_STR_EQUIV(ap, answer)) {
613             return 0;
614         }
615         idx++;
616         ap = noes[idx];
617     }
618 
619     /* true! */
620     return 1;
621 }
622 
623 
624 static int
625 binunif_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern, const char *name)
626 {
627     unsigned int minor_type;
628 
629     intern->idb_ptr = NULL;
630 
631     if (strlen(cmd_argvs[3]) != 1) {
632         bu_vls_printf(gedp->ged_result_str, "Unrecognized minor type (%s)\n", cmd_argvs[3]);
633         return GED_ERROR;
634     }
635 
636     switch (*cmd_argvs[3]) {
637         case 'f':
638             minor_type = DB5_MINORTYPE_BINU_FLOAT;
639             break;
640         case 'd':
641             minor_type = DB5_MINORTYPE_BINU_DOUBLE;
642             break;
643         case 'c':
644             minor_type = DB5_MINORTYPE_BINU_8BITINT;
645             break;
646         case 's':
647             minor_type = DB5_MINORTYPE_BINU_16BITINT;
648             break;
649         case 'i':
650             minor_type = DB5_MINORTYPE_BINU_32BITINT;
651             break;
652         case 'l':
653             minor_type = DB5_MINORTYPE_BINU_64BITINT;
654             break;
655         case 'C':
656             minor_type = DB5_MINORTYPE_BINU_8BITINT_U;
657             break;
658         case 'S':
659             minor_type = DB5_MINORTYPE_BINU_16BITINT_U;
660             break;
661         case 'I':
662             minor_type = DB5_MINORTYPE_BINU_32BITINT_U;
663             break;
664         case 'L':
665             minor_type = DB5_MINORTYPE_BINU_64BITINT_U;
666             break;
667         default:
668             bu_log("Unrecognized minor type (%c)\n", *cmd_argvs[3]);
669             return GED_ERROR;
670     }
671     if (rt_mk_binunif (gedp->ged_wdbp, name, cmd_argvs[4], minor_type, atol(cmd_argvs[5]))) {
672         bu_vls_printf(gedp->ged_result_str,
673                       "Failed to create binary object %s from file %s\n",
674                       name, cmd_argvs[4]);
675         return GED_ERROR;
676     }
677 
678     return GED_OK;
679 }
680 
681 
682 /* E B M _ I N
683  *
684  * Read EBM solid from keyboard
685  *
686  */
687 static int
688 ebm_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
689 {
690     struct rt_ebm_internal *ebm;
691 
692     BU_ALLOC(ebm, struct rt_ebm_internal);
693     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
694     intern->idb_type = ID_EBM;
695     intern->idb_meth = &rt_functab[ID_EBM];
696     intern->idb_ptr = (genptr_t)ebm;
697     ebm->magic = RT_EBM_INTERNAL_MAGIC;
698 
699     bu_strlcpy(ebm->file, cmd_argvs[3], RT_EBM_NAME_LEN);
700     ebm->xdim = atoi(cmd_argvs[4]);
701     ebm->ydim = atoi(cmd_argvs[5]);
702     ebm->tallness = atof(cmd_argvs[6]) * gedp->ged_wdbp->dbip->dbi_local2base;
703     MAT_IDN(ebm->mat);
704 
705     return GED_OK;
706 }
707 
708 
709 /* S U B M O D E L _ I N
710  *
711  * Read submodel from keyboard
712  *
713  */
714 static int
715 submodel_in(struct ged *UNUSED(gedp), const char **cmd_argvs, struct rt_db_internal *intern)
716 {
717     struct rt_submodel_internal *sip;
718 
719     BU_ALLOC(sip, struct rt_submodel_internal);
720     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
721     intern->idb_type = ID_SUBMODEL;
722     intern->idb_meth = &rt_functab[ID_SUBMODEL];
723     intern->idb_ptr = (genptr_t)sip;
724     sip->magic = RT_SUBMODEL_INTERNAL_MAGIC;
725 
726     bu_vls_init(&sip->treetop);
727     bu_vls_strcpy(&sip->treetop, cmd_argvs[3]);
728     sip->meth = atoi(cmd_argvs[4]);
729     bu_vls_init(&sip->file);
730     bu_vls_strcpy(&sip->file, cmd_argvs[5]);
731 
732     return GED_OK;
733 }
734 
735 
736 /* D S P _ I N
737  *
738  * Read DSP solid from keyboard
739  */
740 static int
741 dsp_in_v4(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
742 {
743     struct rt_dsp_internal *dsp;
744 
745     BU_ALLOC(dsp, struct rt_dsp_internal);
746     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
747     intern->idb_type = ID_DSP;
748     intern->idb_meth = &rt_functab[ID_DSP];
749     intern->idb_ptr = (genptr_t)dsp;
750     dsp->magic = RT_DSP_INTERNAL_MAGIC;
751 
752     bu_vls_init(&dsp->dsp_name);
753     bu_vls_strcpy(&dsp->dsp_name, cmd_argvs[3]);
754 
755     dsp->dsp_xcnt = atoi(cmd_argvs[4]);
756     dsp->dsp_ycnt = atoi(cmd_argvs[5]);
757     dsp->dsp_smooth = atoi(cmd_argvs[6]);
758     MAT_IDN(dsp->dsp_stom);
759 
760     dsp->dsp_stom[0] = dsp->dsp_stom[5] =
761         atof(cmd_argvs[7]) * gedp->ged_wdbp->dbip->dbi_local2base;
762 
763     dsp->dsp_stom[10] = atof(cmd_argvs[8]) * gedp->ged_wdbp->dbip->dbi_local2base;
764 
765     bn_mat_inv(dsp->dsp_mtos, dsp->dsp_stom);
766 
767     return GED_OK;
768 }
769 
770 
771 extern void dsp_dump(struct rt_dsp_internal *dsp);
772 
773 /* D S P _ I N
774  *
775  * Read DSP solid from keyboard
776  */
777 static int
778 dsp_in_v5(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
779 {
780     struct rt_dsp_internal *dsp;
781 
782     BU_ALLOC(dsp, struct rt_dsp_internal);
783     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
784     intern->idb_type = ID_DSP;
785     intern->idb_meth = &rt_functab[ID_DSP];
786     intern->idb_ptr = (genptr_t)dsp;
787     dsp->magic = RT_DSP_INTERNAL_MAGIC;
788 
789     if (*cmd_argvs[3] == 'f' || *cmd_argvs[3] == 'F')
790         dsp->dsp_datasrc = RT_DSP_SRC_FILE;
791     else if (*cmd_argvs[3] == 'O' || *cmd_argvs[3] == 'o')
792         dsp->dsp_datasrc = RT_DSP_SRC_OBJ;
793     else
794         return GED_ERROR;
795 
796     bu_vls_init(&dsp->dsp_name);
797     bu_vls_strcpy(&dsp->dsp_name, cmd_argvs[4]);
798 
799     dsp->dsp_xcnt = atoi(cmd_argvs[5]);
800     dsp->dsp_ycnt = atoi(cmd_argvs[6]);
801     dsp->dsp_smooth = atoi(cmd_argvs[7]);
802     switch (*cmd_argvs[8]) {
803         case 'a':       /* adaptive */
804         case 'A':
805             dsp->dsp_cuttype = DSP_CUT_DIR_ADAPT;
806             break;
807         case 'l':       /* lower left to upper right */
808             dsp->dsp_cuttype = DSP_CUT_DIR_llUR;
809             break;
810         case 'L':       /* Upper Left to lower right */
811             dsp->dsp_cuttype = DSP_CUT_DIR_ULlr;
812             break;
813         default:
814             bu_log("Error: dsp_cuttype:\"%s\"\n", cmd_argvs[8]);
815             return GED_ERROR;
816             break;
817     }
818 
819     MAT_IDN(dsp->dsp_stom);
820 
821     dsp->dsp_stom[0] = dsp->dsp_stom[5] =
822         atof(cmd_argvs[9]) * gedp->ged_wdbp->dbip->dbi_local2base;
823 
824     dsp->dsp_stom[10] = atof(cmd_argvs[10]) * gedp->ged_wdbp->dbip->dbi_local2base;
825 
826     bn_mat_inv(dsp->dsp_mtos, dsp->dsp_stom);
827 
828     return GED_OK;
829 }
830 
831 
832 /* H F _ I N
833  *
834  * Read HF solid from keyboard
835  *
836  */
837 static int
838 hf_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
839 {
840     struct rt_hf_internal *hf;
841 
842     BU_ALLOC(hf, struct rt_hf_internal);
843     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
844     intern->idb_type = ID_HF;
845     intern->idb_meth = &rt_functab[ID_HF];
846     intern->idb_ptr = (genptr_t)hf;
847     hf->magic = RT_HF_INTERNAL_MAGIC;
848 
849     bu_strlcpy(hf->cfile, cmd_argvs[3], sizeof(hf->cfile));
850     bu_strlcpy(hf->dfile, cmd_argvs[4], sizeof(hf->dfile));
851     bu_strlcpy(hf->fmt, cmd_argvs[5], sizeof(hf->fmt));
852 
853     hf->w = atoi(cmd_argvs[6]);
854     hf->n = atoi(cmd_argvs[7]);
855     hf->shorts = atoi(cmd_argvs[8]);
856     hf->file2mm = atof(cmd_argvs[9]);
857     hf->v[0] = atof(cmd_argvs[10]) * gedp->ged_wdbp->dbip->dbi_local2base;
858     hf->v[1] = atof(cmd_argvs[11]) * gedp->ged_wdbp->dbip->dbi_local2base;
859     hf->v[2] = atof(cmd_argvs[12]) * gedp->ged_wdbp->dbip->dbi_local2base;
860     hf->x[0] = atof(cmd_argvs[13]);
861     hf->x[1] = atof(cmd_argvs[14]);
862     hf->x[2] = atof(cmd_argvs[15]);
863     hf->y[0] = atof(cmd_argvs[16]);
864     hf->y[1] = atof(cmd_argvs[17]);
865     hf->y[2] = atof(cmd_argvs[18]);
866     hf->xlen = atof(cmd_argvs[19]) * gedp->ged_wdbp->dbip->dbi_local2base;
867     hf->ylen = atof(cmd_argvs[20]) * gedp->ged_wdbp->dbip->dbi_local2base;
868     hf->zscale = atof(cmd_argvs[21]);
869 
870     if (hf->w < 2 || hf->n < 2) {
871         bu_vls_printf(gedp->ged_result_str, "ERROR: length or width of fta file is too small\n");
872         return GED_ERROR;
873     }
874 
875     if (hf->xlen <= 0 || hf->ylen <= 0) {
876         bu_vls_printf(gedp->ged_result_str, "ERROR: length and width of HF solid must be greater than 0\n");
877         return GED_ERROR;
878     }
879 
880     /* XXXX should check for orthogonality of 'x' and 'y' vectors */
881 
882     hf->mp = bu_open_mapped_file(hf->dfile, "hf");
883     if (!hf->mp) {
884         bu_vls_printf(gedp->ged_result_str, "ERROR: cannot open data file\n");
885         hf->mp = (struct bu_mapped_file *)NULL;
886         return GED_ERROR;
887     }
888 
889     return GED_OK;
890 }
891 
892 
893 /* V O L _ I N
894  *
895  * Read VOL solid from keyboard
896  *
897  */
898 static int
899 vol_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
900 {
901     struct rt_vol_internal *vol;
902 
903     BU_ALLOC(vol, struct rt_vol_internal);
904     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
905     intern->idb_type = ID_VOL;
906     intern->idb_meth = &rt_functab[ID_VOL];
907     intern->idb_ptr = (genptr_t)vol;
908     vol->magic = RT_VOL_INTERNAL_MAGIC;
909 
910     bu_strlcpy(vol->file, cmd_argvs[3], sizeof(vol->file));
911     vol->xdim = atoi(cmd_argvs[4]);
912     vol->ydim = atoi(cmd_argvs[5]);
913     vol->zdim = atoi(cmd_argvs[6]);
914     vol->lo = atoi(cmd_argvs[7]);
915     vol->hi = atoi(cmd_argvs[8]);
916     vol->cellsize[0] = atof(cmd_argvs[9]) * gedp->ged_wdbp->dbip->dbi_local2base;
917     vol->cellsize[1] = atof(cmd_argvs[10]) * gedp->ged_wdbp->dbip->dbi_local2base;
918     vol->cellsize[2] = atof(cmd_argvs[11]) * gedp->ged_wdbp->dbip->dbi_local2base;
919     MAT_IDN(vol->mat);
920 
921     return GED_OK;
922 }
923 
924 
925 /*
926  * B O T _ I N
927  */
928 static int
929 bot_in(struct ged *gedp, int argc, const char **argv, struct rt_db_internal *intern, char **prompt)
930 {
931     int i;
932     int num_verts, num_faces;
933     int mode, orientation;
934     int arg_count;
935     struct rt_bot_internal *bot;
936 
937     if (argc < 7) {
938         bu_vls_printf(gedp->ged_result_str, "%s", prompt[argc-3]);
939         return GED_MORE;
940     }
941 
942     num_verts = atoi(argv[3]);
943     if (num_verts < 3) {
944         bu_vls_printf(gedp->ged_result_str, "Invalid number of vertices (must be at least 3)\n");
945         return GED_ERROR;
946     }
947 
948     num_faces = atoi(argv[4]);
949     if (num_faces < 1) {
950         bu_vls_printf(gedp->ged_result_str, "Invalid number of triangles (must be at least 1)\n");
951         return GED_ERROR;
952     }
953 
954     mode = atoi(argv[5]);
955     if (mode < 1 || mode > 3) {
956         bu_vls_printf(gedp->ged_result_str, "Invalid mode (must be 1, 2, or 3)\n");
957         return GED_ERROR;
958     }
959 
960     orientation = atoi(argv[6]);
961     if (orientation < 1 || orientation > 3) {
962         bu_vls_printf(gedp->ged_result_str, "Invalid orientation (must be 1, 2, or 3)\n");
963         return GED_ERROR;
964     }
965 
966     arg_count = argc - 7;
967     if (arg_count < num_verts*3) {
968         bu_vls_printf(gedp->ged_result_str, "%s for vertex %d : ", prompt[4+arg_count%3], arg_count/3);
969         return GED_MORE;
970     }
971 
972     arg_count = argc - 7 - num_verts*3;
973     if (arg_count < num_faces*3) {
974         bu_vls_printf(gedp->ged_result_str, "%s for triangle %d : ", prompt[7+arg_count%3], arg_count/3);
975         return GED_MORE;
976     }
977 
978     if (mode == RT_BOT_PLATE) {
979         arg_count = argc - 7 - num_verts*3 - num_faces*3;
980         if (arg_count < num_faces*2) {
981             bu_vls_printf(gedp->ged_result_str, "%s for face %d : ", prompt[10+arg_count%2], arg_count/2);
982             return GED_MORE;
983         }
984     }
985 
986     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
987     intern->idb_type = ID_BOT;
988     intern->idb_meth = &rt_functab[ID_BOT];
989 
990     BU_ALLOC(bot, struct rt_bot_internal);
991     intern->idb_ptr = (genptr_t)bot;
992     bot->magic = RT_BOT_INTERNAL_MAGIC;
993     bot->num_vertices = num_verts;
994     bot->num_faces = num_faces;
995     bot->mode = mode;
996     bot->orientation = orientation;
997     bot->faces = (int *)bu_calloc(bot->num_faces * 3, sizeof(int), "bot faces");
998     bot->vertices = (fastf_t *)bu_calloc(bot->num_vertices * 3, sizeof(fastf_t), "bot vertices");
999     bot->thickness = (fastf_t *)NULL;
1000     bot->face_mode = (struct bu_bitv *)NULL;
1001 
1002     for (i = 0; i < num_verts; i++) {
1003         bot->vertices[i*3] = atof(argv[7+i*3]) * gedp->ged_wdbp->dbip->dbi_local2base;
1004         bot->vertices[i*3+1] = atof(argv[8+i*3]) * gedp->ged_wdbp->dbip->dbi_local2base;
1005         bot->vertices[i*3+2] = atof(argv[9+i*3]) * gedp->ged_wdbp->dbip->dbi_local2base;
1006     }
1007 
1008     arg_count = 7 + num_verts*3;
1009     for (i = 0; i < num_faces; i++) {
1010         bot->faces[i*3] = atoi(argv[arg_count + i*3]);
1011         bot->faces[i*3+1] = atoi(argv[arg_count + i*3 + 1]);
1012         bot->faces[i*3+2] = atoi(argv[arg_count + i*3 + 2]);
1013     }
1014 
1015     if (mode == RT_BOT_PLATE) {
1016         arg_count = 7 + num_verts*3 + num_faces*3;
1017         bot->thickness = (fastf_t *)bu_calloc(num_faces, sizeof(fastf_t), "bot thickness");
1018         bot->face_mode = bu_bitv_new(num_faces);
1019         for (i = 0; i < num_faces; i++) {
1020             int j;
1021 
1022             j = atoi(argv[arg_count + i*2]);
1023             if (j == 1)
1024                 BU_BITSET(bot->face_mode, i);
1025             else if (j != 0) {
1026                 bu_vls_printf(gedp->ged_result_str, "Invalid face mode (must be 0 or 1)\n");
1027                 return GED_ERROR;
1028             }
1029             bot->thickness[i] = atof(argv[arg_count + i*2 + 1]) * gedp->ged_wdbp->dbip->dbi_local2base;
1030         }
1031     }
1032 
1033     return GED_OK;
1034 }
1035 
1036 
1037 /*
1038  * A R B N _ I N
1039  */
1040 static int
1041 arbn_in(struct ged *gedp, int argc, const char **argv, struct rt_db_internal *intern, char **prompt)
1042 {
1043     struct rt_arbn_internal *arbn;
1044     int num_planes=0;
1045     size_t i;
1046 
1047     if (argc < 4) {
1048         bu_vls_printf(gedp->ged_result_str, "%s", prompt[argc-3]);
1049         return GED_MORE;
1050     }
1051 
1052     num_planes = atoi(argv[3]);
1053 
1054     if (argc < num_planes * 4 + 4) {
1055         bu_vls_printf(gedp->ged_result_str, "%s for plane %d : ", prompt[(argc-4)%4 + 1], 1+(argc-4)/4);
1056         return GED_MORE;
1057     }
1058 
1059     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1060     intern->idb_type = ID_ARBN;
1061     intern->idb_meth = &rt_functab[ID_ARBN];
1062 
1063     BU_ALLOC(intern->idb_ptr, struct rt_arbn_internal);
1064     arbn = (struct rt_arbn_internal *)intern->idb_ptr;
1065     arbn->magic = RT_ARBN_INTERNAL_MAGIC;
1066     arbn->neqn = num_planes;
1067     arbn->eqn = (plane_t *)bu_calloc(arbn->neqn, sizeof(plane_t), "arbn planes");
1068 
1069     /* Normal is unscaled, should have unit length; d is scaled */
1070     for (i = 0; i < arbn->neqn; i++) {
1071         arbn->eqn[i][X] = atof(argv[4+i*4]);
1072         arbn->eqn[i][Y] = atof(argv[4+i*4+1]);
1073         arbn->eqn[i][Z] = atof(argv[4+i*4+2]);
1074         arbn->eqn[i][W] = atof(argv[4+i*4+3]) * gedp->ged_wdbp->dbip->dbi_local2base;
1075     }
1076 
1077     return GED_OK;
1078 }
1079 
1080 
1081 /*
1082  * P I P E _ I N
1083  */
1084 static int
1085 pipe_in(struct ged *gedp, int argc, const char **argv, struct rt_db_internal *intern, char **prompt)
1086 {
1087     struct rt_pipe_internal *pipeip;
1088     int i, num_points;
1089 
1090     if (argc < 4) {
1091         bu_vls_printf(gedp->ged_result_str, "%s", prompt[argc-3]);
1092         return GED_MORE;
1093     }
1094 
1095     num_points = atoi(argv[3]);
1096     if (num_points < 2) {
1097         bu_vls_printf(gedp->ged_result_str, "Invalid number of points (must be at least 2)\n");
1098         return GED_ERROR;
1099     }
1100 
1101     if (argc < 10) {
1102         bu_vls_printf(gedp->ged_result_str, "%s", prompt[argc-3]);
1103         return GED_MORE;
1104     }
1105 
1106     if (argc < 4 + num_points*6) {
1107         bu_vls_printf(gedp->ged_result_str, "%s for point %d : ", prompt[7+(argc-10)%6], 1+(argc-4)/6);
1108         return GED_MORE;
1109     }
1110 
1111     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1112     intern->idb_type = ID_PIPE;
1113     intern->idb_meth = &rt_functab[ID_PIPE];
1114 
1115     BU_ALLOC(intern->idb_ptr, struct rt_pipe_internal);
1116     pipeip = (struct rt_pipe_internal *)intern->idb_ptr;
1117     pipeip->pipe_magic = RT_PIPE_INTERNAL_MAGIC;
1118     BU_LIST_INIT(&pipeip->pipe_segs_head);
1119     for (i = 4; i < argc; i += 6) {
1120         struct wdb_pipept *pipept;
1121 
1122         BU_ALLOC(pipept, struct wdb_pipept);
1123         pipept->pp_coord[0] = atof(argv[i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1124         pipept->pp_coord[1] = atof(argv[i+1]) * gedp->ged_wdbp->dbip->dbi_local2base;
1125         pipept->pp_coord[2] = atof(argv[i+2]) * gedp->ged_wdbp->dbip->dbi_local2base;
1126         pipept->pp_id = atof(argv[i+3]) * gedp->ged_wdbp->dbip->dbi_local2base;
1127         pipept->pp_od = atof(argv[i+4]) * gedp->ged_wdbp->dbip->dbi_local2base;
1128         pipept->pp_bendradius = atof(argv[i+5]) * gedp->ged_wdbp->dbip->dbi_local2base;
1129 
1130         BU_LIST_INSERT(&pipeip->pipe_segs_head, &pipept->l);
1131     }
1132 
1133     if (rt_pipe_ck(&pipeip->pipe_segs_head)) {
1134         bu_vls_printf(gedp->ged_result_str, "Illegal pipe, solid not made!!\n");
1135         return GED_ERROR;
1136     }
1137 
1138     return GED_OK;
1139 }
1140 
1141 
1142 /*
1143  * A R S _ I N
1144  */
1145 static int
1146 ars_in(struct ged *gedp, int argc, const char **argv, struct rt_db_internal *intern, char **prompt)
1147 {
1148     struct rt_ars_internal *arip;
1149     size_t i;
1150     size_t total_points;
1151     int cv;     /* current curve (waterline) # */
1152     size_t axis;        /* current fastf_t in waterline */
1153     int ncurves_minus_one;
1154     int num_pts = 0;
1155     int num_curves = 0;
1156     int vals_present, total_vals_needed;
1157 
1158     vals_present = argc - 3;
1159 
1160     if (vals_present > 0) {
1161         num_pts = atoi(argv[3]);
1162         if (num_pts < 3) {
1163             bu_vls_printf(gedp->ged_result_str, "points per waterline must be >= 3\n");
1164             intern->idb_meth = &rt_functab[ID_ARS];
1165             return GED_ERROR;
1166         }
1167     }
1168 
1169     if (vals_present > 1) {
1170         num_curves = atoi(argv[4]);
1171         if (num_curves < 3) {
1172             bu_vls_printf(gedp->ged_result_str, "points per waterline must be >= 3\n");
1173             intern->idb_meth = &rt_functab[ID_ARS];
1174             return GED_ERROR;
1175         }
1176     }
1177 
1178     if (vals_present < 5) {
1179         /* for #rows, #pts/row & first point,
1180          * pre-formatted prompts exist
1181          */
1182         bu_vls_printf(gedp->ged_result_str, "%s", prompt[vals_present]);
1183         return GED_MORE;
1184     }
1185 
1186     total_vals_needed = 2 +             /* #rows, #pts/row */
1187         (ELEMENTS_PER_POINT * 2) +      /* the first point, and very last */
1188         (num_pts * ELEMENTS_PER_POINT * (num_curves-2)); /* the curves */
1189 
1190     if (vals_present < (total_vals_needed - ELEMENTS_PER_POINT)) {
1191         /* if we're looking for points on the curves, and not
1192          * the last point which makes up the last curve, we
1193          * have to format up a prompt string
1194          */
1195 
1196         switch ((vals_present-2) % 3) {
1197             case 0:
1198                 bu_vls_printf(gedp->ged_result_str, "%s for Waterline %d, Point %d : ",
1199                               prompt[5],
1200                               1+(argc-8)/3/num_pts,
1201                               ((argc-8)/3)%num_pts);
1202                 break;
1203             case 1:
1204                 bu_vls_printf(gedp->ged_result_str, "%s for Waterline %d, Point %d : ",
1205                               prompt[6],
1206                               1+(argc-8)/3/num_pts,
1207                               ((argc-8)/3)%num_pts);
1208                 break;
1209             case 2:
1210                 bu_vls_printf(gedp->ged_result_str, "%s for Waterline %d, Point %d : ",
1211                               prompt[7],
1212                               1+(argc-8)/3/num_pts,
1213                               ((argc-8)/3)%num_pts);
1214                 break;
1215         }
1216 
1217         return GED_MORE;
1218     } else if (vals_present < total_vals_needed) {
1219         /* we're looking for the last point which is used for all points
1220          * on the last curve
1221          */
1222 
1223         switch ((vals_present-2) % 3) {
1224             case 0:
1225                 bu_vls_printf(gedp->ged_result_str, "%s for pt of last Waterline : %d, %d",
1226                               prompt[5],
1227                               1+(argc-8)/3/num_pts,
1228                               ((argc-8)/3)%num_pts);
1229                 break;
1230             case 1:
1231                 bu_vls_printf(gedp->ged_result_str, "%s for pt of last Waterline : %d, %d",
1232                               prompt[6],
1233                               1+(argc-8)/3/num_pts,
1234                               ((argc-8)/3)%num_pts);
1235                 break;
1236             case 2:
1237                 bu_vls_printf(gedp->ged_result_str, "%s for pt of last Waterline : %d, %d",
1238                               prompt[7],
1239                               1+(argc-8)/3/num_pts,
1240                               ((argc-8)/3)%num_pts);
1241                 break;
1242         }
1243 
1244         return GED_MORE;
1245     }
1246 
1247     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1248     intern->idb_type = ID_ARS;
1249     intern->idb_meth = &rt_functab[ID_ARS];
1250 
1251     BU_ALLOC(intern->idb_ptr, struct rt_ars_internal);
1252     arip = (struct rt_ars_internal *)intern->idb_ptr;
1253     arip->magic = RT_ARS_INTERNAL_MAGIC;
1254     arip->pts_per_curve = num_pts;
1255     arip->ncurves = num_curves;
1256     ncurves_minus_one = arip->ncurves - 1;
1257     total_points = arip->ncurves * arip->pts_per_curve;
1258 
1259     arip->curves = (fastf_t **)bu_malloc((arip->ncurves+1) * sizeof(fastf_t *), "ars curve ptrs");
1260     for (i = 0; i < arip->ncurves+1; i++) {
1261         /* Leave room for first point to be repeated */
1262         arip->curves[i] = (fastf_t *)bu_malloc((arip->pts_per_curve+1) * sizeof(point_t), "ars curve");
1263     }
1264 
1265     /* fill in the point of the first row */
1266     arip->curves[0][0] = atof(argv[5]) * gedp->ged_wdbp->dbip->dbi_local2base;
1267     arip->curves[0][1] = atof(argv[6]) * gedp->ged_wdbp->dbip->dbi_local2base;
1268     arip->curves[0][2] = atof(argv[7]) * gedp->ged_wdbp->dbip->dbi_local2base;
1269 
1270     /* The first point is duplicated across the first curve */
1271     for (i = 1; i < arip->pts_per_curve; ++i) {
1272         VMOVE(arip->curves[0]+3*i, arip->curves[0]);
1273     }
1274 
1275     cv = 1;
1276     axis = 0;
1277     /* scan each of the other points we've already got */
1278     for (i = 8; i < (size_t)argc && i < total_points * ELEMENTS_PER_POINT; ++i) {
1279         arip->curves[cv][axis] = atof(argv[i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1280         if (++axis >= arip->pts_per_curve * ELEMENTS_PER_POINT) {
1281             axis = 0;
1282             cv++;
1283         }
1284     }
1285 
1286     /* The first point is duplicated across the last curve */
1287     for (i = 1; i < arip->pts_per_curve; ++i) {
1288         VMOVE(arip->curves[ncurves_minus_one]+3*i,
1289               arip->curves[ncurves_minus_one]);
1290     }
1291 
1292     return GED_OK;
1293 }
1294 
1295 
1296 /* H A L F _ I N () :           reads halfspace parameters from keyboard
1297  * returns 0 if successful read
1298  * 1 if unsuccessful read
1299  */
1300 static int
1301 half_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern, const char *name)
1302 {
1303     vect_t norm;
1304     double d;
1305 
1306     intern->idb_ptr = NULL;
1307 
1308     norm[X] = atof(cmd_argvs[3+0]);
1309     norm[Y] = atof(cmd_argvs[3+1]);
1310     norm[Z] = atof(cmd_argvs[3+2]);
1311     d = atof(cmd_argvs[3+3]) * gedp->ged_wdbp->dbip->dbi_local2base;
1312 
1313     if (MAGNITUDE(norm) < RT_LEN_TOL) {
1314         bu_vls_printf(gedp->ged_result_str, "ERROR, normal vector is too small!\n");
1315         return GED_ERROR;
1316     }
1317 
1318     VUNITIZE(norm);
1319     if (mk_half(gedp->ged_wdbp, name, norm, d) < 0)
1320         return GED_ERROR;
1321 
1322     return GED_OK;
1323 }
1324 
1325 
1326 /* A R B _ I N () :     reads arb parameters from keyboard
1327  * returns 0 if successful read
1328  * 1 if unsuccessful read
1329  */
1330 static int
1331 arb_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1332 {
1333     int i, j, n;
1334     struct rt_arb_internal *aip;
1335 
1336     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1337     intern->idb_type = ID_ARB8;
1338     intern->idb_meth = &rt_functab[ID_ARB8];
1339     BU_ALLOC(intern->idb_ptr, struct rt_arb_internal);
1340     aip = (struct rt_arb_internal *)intern->idb_ptr;
1341     aip->magic = RT_ARB_INTERNAL_MAGIC;
1342 
1343     n = atoi(&cmd_argvs[2][3]); /* get # from "arb#" */
1344     for (j = 0; j < n; j++)
1345         for (i = 0; i < ELEMENTS_PER_POINT; i++)
1346             aip->pt[j][i] = atof(cmd_argvs[3+i+3*j]) * gedp->ged_wdbp->dbip->dbi_local2base;
1347 
1348     if (BU_STR_EQUAL("arb4", cmd_argvs[2])) {
1349         VMOVE(aip->pt[7], aip->pt[3]);
1350         VMOVE(aip->pt[6], aip->pt[3]);
1351         VMOVE(aip->pt[5], aip->pt[3]);
1352         VMOVE(aip->pt[4], aip->pt[3]);
1353         VMOVE(aip->pt[3], aip->pt[0]);
1354     } else if (BU_STR_EQUAL("arb5", cmd_argvs[2])) {
1355         VMOVE(aip->pt[7], aip->pt[4]);
1356         VMOVE(aip->pt[6], aip->pt[4]);
1357         VMOVE(aip->pt[5], aip->pt[4]);
1358     } else if (BU_STR_EQUAL("arb6", cmd_argvs[2])) {
1359         VMOVE(aip->pt[7], aip->pt[5]);
1360         VMOVE(aip->pt[6], aip->pt[5]);
1361         VMOVE(aip->pt[5], aip->pt[4]);
1362     } else if (BU_STR_EQUAL("arb7", cmd_argvs[2])) {
1363         VMOVE(aip->pt[7], aip->pt[4]);
1364     }
1365 
1366     return GED_OK;      /* success */
1367 }
1368 
1369 
1370 /* S P H _ I N () :     reads sph parameters from keyboard
1371  * returns 0 if successful read
1372  * 1 if unsuccessful read
1373  */
1374 static int
1375 sph_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern, const char *name)
1376 {
1377     point_t center;
1378     fastf_t r;
1379     int i;
1380 
1381     intern->idb_ptr = NULL;
1382 
1383     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1384         center[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1385     }
1386     r = atof(cmd_argvs[6]) * gedp->ged_wdbp->dbip->dbi_local2base;
1387 
1388     if (r < RT_LEN_TOL) {
1389         bu_vls_printf(gedp->ged_result_str, "ERROR, radius must be greater than zero!\n");
1390         return GED_ERROR;
1391     }
1392 
1393     if (mk_sph(gedp->ged_wdbp, name, center, r) < 0)
1394         return GED_ERROR;
1395     return GED_OK;
1396 }
1397 
1398 
1399 /* E L L _ I N () :     reads ell parameters from keyboard
1400  * returns 0 if successful read
1401  * 1 if unsuccessful read
1402  */
1403 static int
1404 ell_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1405 {
1406     fastf_t len, mag_b, r_rev, vals[12];
1407     int i, n;
1408     struct rt_ell_internal *eip;
1409 
1410     n = 12;                             /* ELL has twelve params */
1411     if (cmd_argvs[2][3] != '\0')        /* ELLG and ELL1 have seven */
1412         n = 7;
1413 
1414     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1415     intern->idb_type = ID_ELL;
1416     intern->idb_meth = &rt_functab[ID_ELL];
1417     BU_ALLOC(intern->idb_ptr, struct rt_ell_internal);
1418     eip = (struct rt_ell_internal *)intern->idb_ptr;
1419     eip->magic = RT_ELL_INTERNAL_MAGIC;
1420 
1421     /* convert typed in args to reals */
1422     for (i = 0; i < n; i++) {
1423         vals[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1424     }
1425 
1426     if (BU_STR_EQUAL("ell", cmd_argvs[2])) {
1427         /* everything's ok */
1428         /* V, A, B, C */
1429         VMOVE(eip->v, &vals[0]);
1430         VMOVE(eip->a, &vals[3]);
1431         VMOVE(eip->b, &vals[6]);
1432         VMOVE(eip->c, &vals[9]);
1433         return GED_OK;
1434     }
1435 
1436     if (BU_STR_EQUAL("ellg", cmd_argvs[2])) {
1437         /* V, f1, f2, len */
1438         /* convert ELLG format into ELL1 format */
1439         len = vals[6];
1440         /* V is halfway between the foci */
1441         VADD2(eip->v, &vals[0], &vals[3]);
1442         VSCALE(eip->v, eip->v, 0.5);
1443         VSUB2(eip->b, &vals[3], &vals[0]);
1444         mag_b = MAGNITUDE(eip->b);
1445         if (NEAR_ZERO(mag_b, RT_LEN_TOL)) {
1446             bu_vls_printf(gedp->ged_result_str, "ERROR, foci are coincident!\n");
1447             return GED_ERROR;
1448         }
1449         /* calculate A vector */
1450         VSCALE(eip->a, eip->b, .5*len/mag_b);
1451         /* calculate radius of revolution (for ELL1 format) */
1452         r_rev = sqrt(MAGSQ(eip->a) - (mag_b*.5)*(mag_b*.5));
1453     } else if (BU_STR_EQUAL("ell1", cmd_argvs[2])) {
1454         /* V, A, r */
1455         VMOVE(eip->v, &vals[0]);
1456         VMOVE(eip->a, &vals[3]);
1457         r_rev = vals[6];
1458     } else {
1459         r_rev = 0;
1460     }
1461 
1462     /* convert ELL1 format into ELLG format */
1463     /* calculate B vector */
1464     bn_vec_ortho(eip->b, eip->a);
1465     VUNITIZE(eip->b);
1466     VSCALE(eip->b, eip->b, r_rev);
1467 
1468     /* calculate C vector */
1469     VCROSS(eip->c, eip->a, eip->b);
1470     VUNITIZE(eip->c);
1471     VSCALE(eip->c, eip->c, r_rev);
1472     return GED_OK;
1473 }
1474 
1475 
1476 /* T O R _ I N () :     reads tor parameters from keyboard
1477  * returns 0 if successful read
1478  * 1 if unsuccessful read
1479  */
1480 static int
1481 tor_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1482 {
1483     int i;
1484     struct rt_tor_internal *tip;
1485 
1486     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1487     intern->idb_type = ID_TOR;
1488     intern->idb_meth = &rt_functab[ID_TOR];
1489     BU_ALLOC(intern->idb_ptr, struct rt_tor_internal);
1490     tip = (struct rt_tor_internal *)intern->idb_ptr;
1491     tip->magic = RT_TOR_INTERNAL_MAGIC;
1492 
1493     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1494         tip->v[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1495         tip->h[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1496     }
1497     tip->r_a = atof(cmd_argvs[9]) * gedp->ged_wdbp->dbip->dbi_local2base;
1498     tip->r_h = atof(cmd_argvs[10]) * gedp->ged_wdbp->dbip->dbi_local2base;
1499     /* Check for radius 2 >= radius 1 */
1500     if (tip->r_a <= tip->r_h) {
1501         bu_vls_printf(gedp->ged_result_str, "ERROR, radius 2 >= radius 1 ....\n");
1502         return GED_ERROR;
1503     }
1504 
1505     if (MAGNITUDE(tip->h) < RT_LEN_TOL) {
1506         bu_vls_printf(gedp->ged_result_str, "ERROR, normal must be greater than zero!\n");
1507         return GED_ERROR;
1508     }
1509 
1510     return GED_OK;
1511 }
1512 
1513 
1514 /* T G C _ I N () :     reads tgc parameters from keyboard
1515  * returns 0 if successful read
1516  * 1 if unsuccessful read
1517  */
1518 static int
1519 tgc_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1520 {
1521     fastf_t r1, r2;
1522     int i;
1523     struct rt_tgc_internal *tip;
1524 
1525     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1526     intern->idb_type = ID_TGC;
1527     intern->idb_meth = &rt_functab[ID_TGC];
1528     BU_ALLOC(intern->idb_ptr, struct rt_tgc_internal);
1529     tip = (struct rt_tgc_internal *)intern->idb_ptr;
1530     tip->magic = RT_TGC_INTERNAL_MAGIC;
1531 
1532     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1533         tip->v[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1534         tip->h[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1535         tip->a[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1536         tip->b[i] = atof(cmd_argvs[12+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1537     }
1538     r1 = atof(cmd_argvs[15]) * gedp->ged_wdbp->dbip->dbi_local2base;
1539     r2 = atof(cmd_argvs[16]) * gedp->ged_wdbp->dbip->dbi_local2base;
1540 
1541     if (MAGNITUDE(tip->h) < RT_LEN_TOL
1542         || MAGNITUDE(tip->a) < RT_LEN_TOL
1543         || MAGNITUDE(tip->b) < RT_LEN_TOL
1544         || r1 < RT_LEN_TOL || r2 < RT_LEN_TOL) {
1545         bu_vls_printf(gedp->ged_result_str, "ERROR, all dimensions must be greater than zero!\n");
1546         return GED_ERROR;
1547     }
1548 
1549     /* calculate C */
1550     VMOVE(tip->c, tip->a);
1551     VUNITIZE(tip->c);
1552     VSCALE(tip->c, tip->c, r1);
1553 
1554     /* calculate D */
1555     VMOVE(tip->d, tip->b);
1556     VUNITIZE(tip->d);
1557     VSCALE(tip->d, tip->d, r2);
1558 
1559     return GED_OK;
1560 }
1561 
1562 
1563 /* R C C _ I N () :     reads rcc parameters from keyboard
1564  * returns 0 if successful read
1565  * 1 if unsuccessful read
1566  */
1567 static int
1568 rcc_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1569 {
1570     fastf_t r;
1571     int i;
1572     struct rt_tgc_internal *tip;
1573 
1574     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1575     intern->idb_type = ID_TGC;
1576     intern->idb_meth = &rt_functab[ID_TGC];
1577     BU_ALLOC(intern->idb_ptr, struct rt_tgc_internal);
1578     tip = (struct rt_tgc_internal *)intern->idb_ptr;
1579     tip->magic = RT_TGC_INTERNAL_MAGIC;
1580 
1581     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1582         tip->v[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1583         tip->h[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1584     }
1585     r = atof(cmd_argvs[9]) * gedp->ged_wdbp->dbip->dbi_local2base;
1586 
1587     if (MAGNITUDE(tip->h) < RT_LEN_TOL || r < RT_LEN_TOL) {
1588         bu_vls_printf(gedp->ged_result_str, "ERROR, all dimensions must be greater than zero!\n");
1589         return GED_ERROR;
1590     }
1591 
1592     bn_vec_ortho(tip->a, tip->h);
1593     VUNITIZE(tip->a);
1594     VCROSS(tip->b, tip->h, tip->a);
1595     VUNITIZE(tip->b);
1596 
1597     VSCALE(tip->a, tip->a, r);
1598     VSCALE(tip->b, tip->b, r);
1599     VMOVE(tip->c, tip->a);
1600     VMOVE(tip->d, tip->b);
1601 
1602     return GED_OK;
1603 }
1604 
1605 
1606 /* T E C _ I N () :     reads tec parameters from keyboard
1607  * returns 0 if successful read
1608  * 1 if unsuccessful read
1609  */
1610 static int
1611 tec_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1612 {
1613     fastf_t ratio;
1614     int i;
1615     struct rt_tgc_internal *tip;
1616 
1617     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1618     intern->idb_type = ID_TGC;
1619     intern->idb_meth = &rt_functab[ID_TGC];
1620     BU_ALLOC(intern->idb_ptr, struct rt_tgc_internal);
1621     tip = (struct rt_tgc_internal *)intern->idb_ptr;
1622     tip->magic = RT_TGC_INTERNAL_MAGIC;
1623 
1624     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1625         tip->v[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1626         tip->h[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1627         tip->a[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1628         tip->b[i] = atof(cmd_argvs[12+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1629     }
1630     ratio = atof(cmd_argvs[15]);
1631     if (MAGNITUDE(tip->h) < RT_LEN_TOL
1632         || MAGNITUDE(tip->a) < RT_LEN_TOL
1633         || MAGNITUDE(tip->b) < RT_LEN_TOL
1634         || ratio < RT_LEN_TOL) {
1635         bu_vls_printf(gedp->ged_result_str, "ERROR, all dimensions must be greater than zero!\n");
1636         return GED_ERROR;
1637     }
1638 
1639     VSCALE(tip->c, tip->a, 1./ratio);   /* C vector */
1640     VSCALE(tip->d, tip->b, 1./ratio);   /* D vector */
1641 
1642     return GED_OK;
1643 }
1644 
1645 
1646 /* R E C _ I N () :     reads rec parameters from keyboard
1647  * returns 0 if successful read
1648  * 1 if unsuccessful read
1649  */
1650 static int
1651 rec_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1652 {
1653     int i;
1654     struct rt_tgc_internal *tip;
1655 
1656     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1657     intern->idb_type = ID_TGC;
1658     intern->idb_meth = &rt_functab[ID_TGC];
1659     BU_ALLOC(intern->idb_ptr, struct rt_tgc_internal);
1660     tip = (struct rt_tgc_internal *)intern->idb_ptr;
1661     tip->magic = RT_TGC_INTERNAL_MAGIC;
1662 
1663     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1664         tip->v[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1665         tip->h[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1666         tip->a[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1667         tip->b[i] = atof(cmd_argvs[12+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1668     }
1669 
1670     if (MAGNITUDE(tip->h) < RT_LEN_TOL
1671         || MAGNITUDE(tip->a) < RT_LEN_TOL
1672         || MAGNITUDE(tip->b) < RT_LEN_TOL) {
1673         bu_vls_printf(gedp->ged_result_str, "ERROR, all dimensions must be greater than zero!\n");
1674         return GED_ERROR;
1675     }
1676 
1677     VMOVE(tip->c, tip->a);              /* C vector */
1678     VMOVE(tip->d, tip->b);              /* D vector */
1679 
1680     return GED_OK;
1681 }
1682 
1683 
1684 /* T R C _ I N () :     reads trc parameters from keyboard
1685  * returns 0 if successful read
1686  * 1 if unsuccessful read
1687  */
1688 static int
1689 trc_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1690 {
1691     fastf_t r1, r2;
1692     int i;
1693     struct rt_tgc_internal *tip;
1694 
1695     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1696     intern->idb_type = ID_TGC;
1697     intern->idb_meth = &rt_functab[ID_TGC];
1698     BU_ALLOC(intern->idb_ptr, struct rt_tgc_internal);
1699     tip = (struct rt_tgc_internal *)intern->idb_ptr;
1700     tip->magic = RT_TGC_INTERNAL_MAGIC;
1701 
1702     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1703         tip->v[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1704         tip->h[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1705     }
1706     r1 = atof(cmd_argvs[9]) * gedp->ged_wdbp->dbip->dbi_local2base;
1707     r2 = atof(cmd_argvs[10]) * gedp->ged_wdbp->dbip->dbi_local2base;
1708 
1709     if (MAGNITUDE(tip->h) < RT_LEN_TOL
1710         || r1 < RT_LEN_TOL || r2 < RT_LEN_TOL) {
1711         bu_vls_printf(gedp->ged_result_str, "ERROR, all dimensions must be greater than zero!\n");
1712         return GED_ERROR;
1713     }
1714 
1715     bn_vec_ortho(tip->a, tip->h);
1716     VUNITIZE(tip->a);
1717     VCROSS(tip->b, tip->h, tip->a);
1718     VUNITIZE(tip->b);
1719     VMOVE(tip->c, tip->a);
1720     VMOVE(tip->d, tip->b);
1721 
1722     VSCALE(tip->a, tip->a, r1);
1723     VSCALE(tip->b, tip->b, r1);
1724     VSCALE(tip->c, tip->c, r2);
1725     VSCALE(tip->d, tip->d, r2);
1726 
1727     return GED_OK;
1728 }
1729 
1730 
1731 /* B O X _ I N () :     reads box parameters from keyboard
1732  * returns 0 if successful read
1733  * 1 if unsuccessful read
1734  */
1735 static int
1736 box_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1737 {
1738     int i;
1739     struct rt_arb_internal *aip;
1740     vect_t Dpth, Hgt, Vrtx, Wdth;
1741 
1742     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1743     intern->idb_type = ID_ARB8;
1744     intern->idb_meth = &rt_functab[ID_ARB8];
1745     BU_ALLOC(intern->idb_ptr, struct rt_arb_internal);
1746     aip = (struct rt_arb_internal *)intern->idb_ptr;
1747     aip->magic = RT_ARB_INTERNAL_MAGIC;
1748 
1749     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1750         Vrtx[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1751         Hgt[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1752         Wdth[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1753         Dpth[i] = atof(cmd_argvs[12+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1754     }
1755 
1756     if (MAGNITUDE(Dpth) < RT_LEN_TOL || MAGNITUDE(Hgt) < RT_LEN_TOL
1757         || MAGNITUDE(Wdth) < RT_LEN_TOL) {
1758         bu_vls_printf(gedp->ged_result_str, "ERROR, all dimensions must be greater than zero!\n");
1759         return GED_ERROR;
1760     }
1761 
1762     if (BU_STR_EQUAL("box", cmd_argvs[2])) {
1763         VMOVE(aip->pt[0], Vrtx);
1764         VADD2(aip->pt[1], Vrtx, Wdth);
1765         VADD3(aip->pt[2], Vrtx, Wdth, Hgt);
1766         VADD2(aip->pt[3], Vrtx, Hgt);
1767         VADD2(aip->pt[4], Vrtx, Dpth);
1768         VADD3(aip->pt[5], Vrtx, Dpth, Wdth);
1769         VADD4(aip->pt[6], Vrtx, Dpth, Wdth, Hgt);
1770         VADD3(aip->pt[7], Vrtx, Dpth, Hgt);
1771     } else {
1772         /* "raw" */
1773         VADD2(aip->pt[0], Vrtx, Wdth);
1774         VADD2(aip->pt[1], Vrtx, Hgt);
1775         VADD2(aip->pt[2], aip->pt[1], Dpth);
1776         VADD2(aip->pt[3], aip->pt[0], Dpth);
1777         VMOVE(aip->pt[4], Vrtx);
1778         VMOVE(aip->pt[5], Vrtx);
1779         VADD2(aip->pt[6], Vrtx, Dpth);
1780         VMOVE(aip->pt[7], aip->pt[6]);
1781     }
1782 
1783     return GED_OK;
1784 }
1785 
1786 
1787 /* R P P _ I N () :     reads rpp parameters from keyboard
1788  * returns GED_OK if successful read
1789  * GED_ERROR if unsuccessful read
1790  */
1791 static int
1792 rpp_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern, const char *name)
1793 {
1794     point_t min, max;
1795 
1796     intern->idb_ptr = NULL;
1797 
1798     min[X] = atof(cmd_argvs[3+0]) * gedp->ged_wdbp->dbip->dbi_local2base;
1799     max[X] = atof(cmd_argvs[3+1]) * gedp->ged_wdbp->dbip->dbi_local2base;
1800     min[Y] = atof(cmd_argvs[3+2]) * gedp->ged_wdbp->dbip->dbi_local2base;
1801     max[Y] = atof(cmd_argvs[3+3]) * gedp->ged_wdbp->dbip->dbi_local2base;
1802     min[Z] = atof(cmd_argvs[3+4]) * gedp->ged_wdbp->dbip->dbi_local2base;
1803     max[Z] = atof(cmd_argvs[3+5]) * gedp->ged_wdbp->dbip->dbi_local2base;
1804 
1805     if (min[X] >= max[X]) {
1806         bu_vls_printf(gedp->ged_result_str, "ERROR, XMIN:(%lg) greater than XMAX:(%lg) !\n", min[X], max[X]);
1807         return GED_ERROR;
1808     }
1809     if (min[Y] >= max[Y]) {
1810         bu_vls_printf(gedp->ged_result_str, "ERROR, YMIN:(%lg) greater than YMAX:(%lg) !\n", min[Y], max[Y]);
1811         return GED_ERROR;
1812     }
1813     if (min[Z] >= max[Z]) {
1814         bu_vls_printf(gedp->ged_result_str, "ERROR, ZMIN:(%lg) greater than ZMAX:(%lg)!\n", min[Z], max[Z]);
1815         return GED_ERROR;
1816     }
1817 
1818     if (mk_rpp(gedp->ged_wdbp, name, min, max) < 0)
1819         return 1;
1820 
1821     return GED_OK;
1822 }
1823 
1824 
1825 /*
1826  * O R P P _ I N ()
1827  *
1828  * Reads origin-min rpp (box) parameters from keyboard
1829  * returns 0 if successful read
1830  * 1 if unsuccessful read
1831  */
1832 static int
1833 orpp_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern, const char *name)
1834 {
1835     point_t min, max;
1836 
1837     intern->idb_ptr = NULL;
1838 
1839     VSETALL(min, 0);
1840     max[X] = atof(cmd_argvs[3+0]) * gedp->ged_wdbp->dbip->dbi_local2base;
1841     max[Y] = atof(cmd_argvs[3+1]) * gedp->ged_wdbp->dbip->dbi_local2base;
1842     max[Z] = atof(cmd_argvs[3+2]) * gedp->ged_wdbp->dbip->dbi_local2base;
1843 
1844     if (min[X] >= max[X]) {
1845         bu_vls_printf(gedp->ged_result_str, "ERROR, XMIN greater than XMAX!\n");
1846         return GED_ERROR;
1847     }
1848     if (min[Y] >= max[Y]) {
1849         bu_vls_printf(gedp->ged_result_str, "ERROR, YMIN greater than YMAX!\n");
1850         return GED_ERROR;
1851     }
1852     if (min[Z] >= max[Z]) {
1853         bu_vls_printf(gedp->ged_result_str, "ERROR, ZMIN greater than ZMAX!\n");
1854         return GED_ERROR;
1855     }
1856 
1857     if (mk_rpp(gedp->ged_wdbp, name, min, max) < 0)
1858         return GED_ERROR;
1859 
1860     return GED_OK;
1861 }
1862 
1863 
1864 /* P A R T _ I N () :   reads particle parameters from keyboard
1865  * returns 0 if successful read
1866  * 1 if unsuccessful read
1867  */
1868 static int
1869 part_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1870 {
1871     int i;
1872     struct rt_part_internal *part_ip;
1873 
1874     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1875     intern->idb_type = ID_PARTICLE;
1876     intern->idb_meth = &rt_functab[ID_PARTICLE];
1877     BU_ALLOC(intern->idb_ptr, struct rt_part_internal);
1878     part_ip = (struct rt_part_internal *)intern->idb_ptr;
1879     part_ip->part_magic = RT_PART_INTERNAL_MAGIC;
1880 
1881     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1882         part_ip->part_V[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1883         part_ip->part_H[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1884     }
1885     part_ip->part_vrad = atof(cmd_argvs[9]) * gedp->ged_wdbp->dbip->dbi_local2base;
1886     part_ip->part_hrad = atof(cmd_argvs[10]) * gedp->ged_wdbp->dbip->dbi_local2base;
1887 
1888     if (MAGNITUDE(part_ip->part_H) < RT_LEN_TOL
1889         || part_ip->part_vrad <= RT_LEN_TOL
1890         || part_ip->part_hrad <= RT_LEN_TOL) {
1891         bu_vls_printf(gedp->ged_result_str, "ERROR, height, v radius and h radius must be greater than zero!\n");
1892         return GED_ERROR;
1893     }
1894 
1895     return GED_OK;
1896 }
1897 
1898 
1899 /* R P C _ I N () :     reads rpc parameters from keyboard
1900  * returns 0 if successful read
1901  * 1 if unsuccessful read
1902  */
1903 static int
1904 rpc_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1905 {
1906     int i;
1907     struct rt_rpc_internal *rip;
1908 
1909     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1910     intern->idb_type = ID_RPC;
1911     intern->idb_meth = &rt_functab[ID_RPC];
1912     BU_ALLOC(intern->idb_ptr, struct rt_rpc_internal);
1913     rip = (struct rt_rpc_internal *)intern->idb_ptr;
1914     rip->rpc_magic = RT_RPC_INTERNAL_MAGIC;
1915 
1916     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1917         rip->rpc_V[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1918         rip->rpc_H[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1919         rip->rpc_B[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1920     }
1921     rip->rpc_r = atof(cmd_argvs[12]) * gedp->ged_wdbp->dbip->dbi_local2base;
1922 
1923     if (MAGNITUDE(rip->rpc_H) < RT_LEN_TOL
1924         || MAGNITUDE(rip->rpc_B) < RT_LEN_TOL
1925         || rip->rpc_r <= RT_LEN_TOL) {
1926         bu_vls_printf(gedp->ged_result_str, "ERROR, height, breadth, and width must be greater than zero!\n");
1927         return GED_ERROR;
1928     }
1929 
1930     return GED_OK;
1931 }
1932 
1933 
1934 /* R H C _ I N () :     reads rhc parameters from keyboard
1935  * returns 0 if successful read
1936  * 1 if unsuccessful read
1937  */
1938 static int
1939 rhc_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1940 {
1941     int i;
1942     struct rt_rhc_internal *rip;
1943 
1944     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1945     intern->idb_type = ID_RHC;
1946     intern->idb_meth = &rt_functab[ID_RHC];
1947     BU_ALLOC(intern->idb_ptr, struct rt_rhc_internal);
1948     rip = (struct rt_rhc_internal *)intern->idb_ptr;
1949     rip->rhc_magic = RT_RHC_INTERNAL_MAGIC;
1950 
1951     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1952         rip->rhc_V[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1953         rip->rhc_H[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1954         rip->rhc_B[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1955     }
1956     rip->rhc_r = atof(cmd_argvs[12]) * gedp->ged_wdbp->dbip->dbi_local2base;
1957     rip->rhc_c = atof(cmd_argvs[13]) * gedp->ged_wdbp->dbip->dbi_local2base;
1958 
1959     if (MAGNITUDE(rip->rhc_H) < RT_LEN_TOL
1960         || MAGNITUDE(rip->rhc_B) < RT_LEN_TOL
1961         || rip->rhc_r <= RT_LEN_TOL || rip->rhc_c <= RT_LEN_TOL) {
1962         bu_vls_printf(gedp->ged_result_str, "ERROR, height, breadth, and width must be greater than zero!\n");
1963         return GED_ERROR;
1964     }
1965 
1966     return GED_OK;
1967 }
1968 
1969 
1970 /* E P A _ I N () :     reads epa parameters from keyboard
1971  * returns 0 if successful read
1972  * 1 if unsuccessful read
1973  */
1974 static int
1975 epa_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
1976 {
1977     int i;
1978     struct rt_epa_internal *rip;
1979 
1980     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
1981     intern->idb_type = ID_EPA;
1982     intern->idb_meth = &rt_functab[ID_EPA];
1983     BU_ALLOC(intern->idb_ptr, struct rt_epa_internal);
1984     rip = (struct rt_epa_internal *)intern->idb_ptr;
1985     rip->epa_magic = RT_EPA_INTERNAL_MAGIC;
1986 
1987     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
1988         rip->epa_V[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1989         rip->epa_H[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1990         rip->epa_Au[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
1991     }
1992     rip->epa_r1 = MAGNITUDE(rip->epa_Au);
1993     rip->epa_r2 = atof(cmd_argvs[12]) * gedp->ged_wdbp->dbip->dbi_local2base;
1994     VUNITIZE(rip->epa_Au);
1995 
1996     if (MAGNITUDE(rip->epa_H) < RT_LEN_TOL
1997         || rip->epa_r1 <= RT_LEN_TOL || rip->epa_r2 <= RT_LEN_TOL) {
1998         bu_vls_printf(gedp->ged_result_str, "ERROR, height and axes must be greater than zero!\n");
1999         return GED_ERROR;
2000     }
2001 
2002     if (rip->epa_r2 > rip->epa_r1) {
2003         bu_vls_printf(gedp->ged_result_str, "ERROR, |A| must be greater than |B|!\n");
2004         return GED_ERROR;
2005     }
2006 
2007     return GED_OK;
2008 }
2009 
2010 
2011 /* E H Y _ I N () :     reads ehy parameters from keyboard
2012  * returns 0 if successful read
2013  * 1 if unsuccessful read
2014  */
2015 static int
2016 ehy_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
2017 {
2018     int i;
2019     struct rt_ehy_internal *rip;
2020 
2021     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
2022     intern->idb_type = ID_EHY;
2023     intern->idb_meth = &rt_functab[ID_EHY];
2024     BU_ALLOC(intern->idb_ptr, struct rt_ehy_internal);
2025     rip = (struct rt_ehy_internal *)intern->idb_ptr;
2026     rip->ehy_magic = RT_EHY_INTERNAL_MAGIC;
2027 
2028     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
2029         rip->ehy_V[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2030         rip->ehy_H[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2031         rip->ehy_Au[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2032     }
2033     rip->ehy_r1 = MAGNITUDE(rip->ehy_Au);
2034     rip->ehy_r2 = atof(cmd_argvs[12]) * gedp->ged_wdbp->dbip->dbi_local2base;
2035     rip->ehy_c = atof(cmd_argvs[13]) * gedp->ged_wdbp->dbip->dbi_local2base;
2036     VUNITIZE(rip->ehy_Au);
2037 
2038     if (MAGNITUDE(rip->ehy_H) < RT_LEN_TOL
2039         || rip->ehy_r1 <= RT_LEN_TOL || rip->ehy_r2 <= RT_LEN_TOL
2040         || rip->ehy_c <= RT_LEN_TOL) {
2041         bu_vls_printf(gedp->ged_result_str, "ERROR, height, axes, and distance to asymptotes must be greater than zero!\n");
2042         return GED_ERROR;
2043     }
2044 
2045     if (!NEAR_ZERO(VDOT(rip->ehy_H, rip->ehy_Au), RT_DOT_TOL)) {
2046         bu_vls_printf(gedp->ged_result_str, "ERROR, major axis must be perpendicular to height vector!\n");
2047         return GED_ERROR;
2048     }
2049 
2050     if (rip->ehy_r2 > rip->ehy_r1) {
2051         bu_vls_printf(gedp->ged_result_str, "ERROR, |A| must be greater than |B|!\n");
2052         return GED_ERROR;
2053     }
2054 
2055     return GED_OK;
2056 }
2057 
2058 
2059 /* H Y P _ I N () :     reads hyp parameters from keyboard
2060  * returns 0 if successful read
2061  * 1 if unsuccessful read
2062  */
2063 static int
2064 hyp_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
2065 {
2066     int i;
2067     struct rt_hyp_internal *rip;
2068     vect_t inH, inAu;
2069     point_t inV;
2070     fastf_t inB, inC;
2071 
2072     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
2073     intern->idb_type = ID_HYP;
2074     intern->idb_meth = &rt_functab[ID_HYP];
2075     BU_ALLOC(intern->idb_ptr, struct rt_hyp_internal);
2076     rip = (struct rt_hyp_internal *)intern->idb_ptr;
2077     rip->hyp_magic = RT_HYP_INTERNAL_MAGIC;
2078 
2079     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
2080         inV[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2081         inH[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2082         inAu[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2083     }
2084     inB = atof(cmd_argvs[12]) * gedp->ged_wdbp->dbip->dbi_local2base;
2085     inC = atof(cmd_argvs[13]) * gedp->ged_wdbp->dbip->dbi_local2base;
2086 
2087     rip->hyp_b = inB;
2088     rip->hyp_bnr = inC;
2089     VMOVE(rip->hyp_Hi, inH);
2090     VMOVE(rip->hyp_Vi, inV);
2091     VMOVE(rip->hyp_A, inAu);
2092 
2093     if (rip->hyp_b > MAGNITUDE(rip->hyp_A)) {
2094         vect_t majorAxis;
2095         fastf_t minorLen;
2096 
2097         minorLen = MAGNITUDE(rip->hyp_A);
2098         VCROSS(majorAxis, rip->hyp_Hi, rip->hyp_A);
2099         VSCALE(rip->hyp_A, majorAxis, rip->hyp_b);
2100         rip->hyp_b = minorLen;
2101     }
2102 
2103 
2104     if (MAGNITUDE(rip->hyp_Hi)*0.5 < RT_LEN_TOL
2105         || MAGNITUDE(rip->hyp_A) * rip->hyp_bnr <= RT_LEN_TOL
2106         || rip->hyp_b <= RT_LEN_TOL) {
2107         bu_vls_printf(gedp->ged_result_str, "ERROR, height, axes, and distance to asymptotes must be greater than zero!\n");
2108         return GED_ERROR;
2109     }
2110 
2111     if (!NEAR_ZERO(VDOT(rip->hyp_Hi, rip->hyp_A), RT_DOT_TOL)) {
2112         bu_vls_printf(gedp->ged_result_str, "ERROR, major axis must be perpendicular to height vector!\n");
2113         return GED_ERROR;
2114     }
2115 
2116     if (inC >= 1 || inC <=0) {
2117         bu_vls_printf(gedp->ged_result_str, "ERROR, neck to base ratio must be between 0 and 1!\n");
2118         return GED_ERROR;
2119 
2120     }
2121 
2122     return GED_OK;
2123 }
2124 
2125 
2126 /* E T O _ I N () :     reads eto parameters from keyboard
2127  * returns 0 if successful read
2128  * 1 if unsuccessful read
2129  */
2130 static int
2131 eto_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
2132 {
2133     int i;
2134     struct rt_eto_internal *eip;
2135 
2136     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
2137     intern->idb_type = ID_ETO;
2138     intern->idb_meth = &rt_functab[ID_ETO];
2139     BU_ALLOC(intern->idb_ptr, struct rt_eto_internal);
2140     eip = (struct rt_eto_internal *)intern->idb_ptr;
2141     eip->eto_magic = RT_ETO_INTERNAL_MAGIC;
2142 
2143     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
2144         eip->eto_V[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2145         eip->eto_N[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2146         eip->eto_C[i] = atof(cmd_argvs[10+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2147     }
2148     eip->eto_r = atof(cmd_argvs[9]) * gedp->ged_wdbp->dbip->dbi_local2base;
2149     eip->eto_rd = atof(cmd_argvs[13]) * gedp->ged_wdbp->dbip->dbi_local2base;
2150 
2151     if (MAGNITUDE(eip->eto_N) < RT_LEN_TOL
2152         || MAGNITUDE(eip->eto_C) < RT_LEN_TOL
2153         || eip->eto_r <= RT_LEN_TOL || eip->eto_rd <= RT_LEN_TOL) {
2154         bu_vls_printf(gedp->ged_result_str, "ERROR, normal, axes, and radii must be greater than zero!\n");
2155         return GED_ERROR;
2156     }
2157 
2158     if (eip->eto_rd > MAGNITUDE(eip->eto_C)) {
2159         bu_vls_printf(gedp->ged_result_str, "ERROR, |C| must be greater than |D|!\n");
2160         return GED_ERROR;
2161     }
2162 
2163     return GED_OK;
2164 }
2165 
2166 
2167 /* E X T R U D E _ I N () :     reads extrude parameters from keyboard
2168  * returns 0 if successful read
2169  * 1 if unsuccessful read
2170  */
2171 static int
2172 extrude_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
2173 {
2174     int i;
2175     struct rt_extrude_internal *eip;
2176     struct rt_db_internal tmp_ip;
2177     struct directory *dp;
2178 
2179     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
2180     intern->idb_type = ID_EXTRUDE;
2181     intern->idb_meth = &rt_functab[ID_EXTRUDE];
2182     BU_ALLOC(intern->idb_ptr, struct rt_extrude_internal);
2183     eip = (struct rt_extrude_internal *)intern->idb_ptr;
2184     eip->magic = RT_EXTRUDE_INTERNAL_MAGIC;
2185 
2186     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
2187         eip->V[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2188         eip->h[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2189         eip->u_vec[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2190         eip->v_vec[i] = atof(cmd_argvs[12+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2191     }
2192     eip->sketch_name = bu_strdup(cmd_argvs[15]);
2193     /* eip->keypoint = atoi(cmd_argvs[16]); */
2194 
2195     if ((dp=db_lookup(gedp->ged_wdbp->dbip, eip->sketch_name, LOOKUP_NOISY)) == RT_DIR_NULL) {
2196         bu_vls_printf(gedp->ged_result_str, "Cannot find sketch (%s) for extrusion (%s)\n",
2197                       eip->sketch_name, cmd_argvs[1]);
2198         eip->skt = (struct rt_sketch_internal *)NULL;
2199         return GED_ERROR;
2200     }
2201 
2202     if (rt_db_get_internal(&tmp_ip, dp, gedp->ged_wdbp->dbip, bn_mat_identity, &rt_uniresource) != ID_SKETCH) {
2203         bu_vls_printf(gedp->ged_result_str, "Cannot import sketch (%s) for extrusion (%s)\n",
2204                       eip->sketch_name, cmd_argvs[1]);
2205         eip->skt = (struct rt_sketch_internal *)NULL;
2206         return GED_ERROR;
2207     } else
2208         eip->skt = (struct rt_sketch_internal *)tmp_ip.idb_ptr;
2209 
2210     return GED_OK;
2211 }
2212 
2213 
2214 /* R E V O L V E _ I N () :     reads extrude parameters from keyboard
2215  * returns 0 if successful read
2216  * 1 if unsuccessful read
2217  */
2218 static int
2219 revolve_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
2220 {
2221     int i;
2222     struct rt_revolve_internal *rip;
2223     struct rt_db_internal tmp_ip;
2224     struct directory *dp;
2225 
2226     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
2227     intern->idb_type = ID_REVOLVE;
2228     intern->idb_meth = &rt_functab[ID_REVOLVE];
2229     BU_ALLOC(intern->idb_ptr, struct rt_revolve_internal);
2230     rip = (struct rt_revolve_internal *)intern->idb_ptr;
2231     rip->magic = RT_REVOLVE_INTERNAL_MAGIC;
2232 
2233     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
2234         rip->v3d[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2235         rip->axis3d[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2236         rip->r[i] = atof(cmd_argvs[9+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2237     }
2238     rip->ang = atof(cmd_argvs[12]) * DEG2RAD;
2239 
2240     bu_vls_init(&rip->sketch_name);
2241     bu_vls_strcpy(&rip->sketch_name, cmd_argvs[13]);
2242 
2243     VUNITIZE(rip->r);
2244     VUNITIZE(rip->axis3d);
2245 
2246     if ((dp=db_lookup(gedp->ged_wdbp->dbip, bu_vls_addr(&rip->sketch_name), LOOKUP_NOISY)) == RT_DIR_NULL) {
2247         bu_vls_printf(gedp->ged_result_str, "Cannot find sketch (%s) for revolve (%s)\n",
2248                       bu_vls_addr(&rip->sketch_name), cmd_argvs[1]);
2249         rip->skt = (struct rt_sketch_internal *)NULL;
2250         return GED_ERROR;
2251     }
2252 
2253     if (rt_db_get_internal(&tmp_ip, dp, gedp->ged_wdbp->dbip, bn_mat_identity, &rt_uniresource) != ID_SKETCH) {
2254         bu_vls_printf(gedp->ged_result_str, "Cannot import sketch (%s) for revolve (%s)\n",
2255                       bu_vls_addr(&rip->sketch_name), cmd_argvs[1]);
2256         rip->skt = (struct rt_sketch_internal *)NULL;
2257         return GED_ERROR;
2258     } else
2259         rip->skt = (struct rt_sketch_internal *)tmp_ip.idb_ptr;
2260 
2261     return GED_OK;
2262 }
2263 
2264 
2265 /* G R I P _ I N () :           reads grip parameters from keyboard
2266  * returns 0 if successful read
2267  * 1 if unsuccessful read
2268  */
2269 static int
2270 grip_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern)
2271 {
2272     int i;
2273     struct rt_grip_internal *gip;
2274 
2275     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
2276     intern->idb_type = ID_GRIP;
2277     intern->idb_meth = &rt_functab[ID_GRIP];
2278     BU_ALLOC(intern->idb_ptr, struct rt_grip_internal);
2279     gip = (struct rt_grip_internal *)intern->idb_ptr;
2280     gip->magic = RT_GRIP_INTERNAL_MAGIC;
2281 
2282     for (i = 0; i < ELEMENTS_PER_POINT; i++) {
2283         gip->center[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2284         gip->normal[i] = atof(cmd_argvs[6+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2285     }
2286 
2287     gip->mag = atof(cmd_argvs[9]);
2288 
2289     return GED_OK;
2290 }
2291 
2292 
2293 /* S U P E R E L L _ I N () :           reads superell parameters from keyboard
2294  * returns 0 if successful read
2295  * 1 if unsuccessful read
2296  */
2297 static int
2298 superell_in(struct ged *gedp, char *cmd_argvs[], struct rt_db_internal *intern)
2299 {
2300     fastf_t vals[14];
2301     int i, n;
2302     struct rt_superell_internal *eip;
2303 
2304     n = 14;                             /* SUPERELL has 12 (same as ELL) + 2 (for <n, e>) params */
2305 
2306     intern->idb_type = ID_SUPERELL;
2307     intern->idb_meth = &rt_functab[ID_SUPERELL];
2308     BU_ALLOC(intern->idb_ptr, struct rt_superell_internal);
2309     eip = (struct rt_superell_internal *)intern->idb_ptr;
2310     eip->magic = RT_SUPERELL_INTERNAL_MAGIC;
2311 
2312     /* convert typed in args to reals and convert to local units */
2313     for (i = 0; i < n - 2; i++) {
2314         vals[i] = atof(cmd_argvs[3+i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2315     }
2316     vals[12] = atof(cmd_argvs[3 + 12]);
2317     vals[13] = atof(cmd_argvs[3 + 13]);
2318 
2319     /* V, A, B, C */
2320     VMOVE(eip->v, &vals[0]);
2321     VMOVE(eip->a, &vals[3]);
2322     VMOVE(eip->b, &vals[6]);
2323     VMOVE(eip->c, &vals[9]);
2324     eip->n = vals[12];
2325     eip->e = vals[13];
2326 
2327     return GED_OK;
2328 }
2329 
2330 
2331 /*
2332  * M E T A B A L L _ I N
2333  *
2334  * This is very much not reentrant, and probably a good deal uglier than it
2335  * should be.
2336  */
2337 static int
2338 metaball_in(struct ged *gedp, int argc, const char **argv, struct rt_db_internal *intern, char **prompt)
2339 {
2340     struct rt_metaball_internal *metaball;
2341     static int i, num_points;
2342     static fastf_t threshold = -1.0;
2343     static long method = 0;
2344 
2345     if (argc < 4) {
2346         bu_vls_printf(gedp->ged_result_str, "%s", prompt[argc-3]);
2347         return GED_MORE;
2348     }
2349     method = atof(argv[3]);
2350 
2351     if (argc < 5) {
2352         bu_vls_printf(gedp->ged_result_str, "%s", prompt[argc-3]);
2353         return GED_MORE;
2354     }
2355     threshold = atof(argv[4]);
2356 
2357     if (threshold < 0.0) {
2358         bu_vls_printf(gedp->ged_result_str, "Threshold may not be negative.\n");
2359         return GED_ERROR;
2360     }
2361 
2362     if (argc < 6) {
2363         bu_vls_printf(gedp->ged_result_str, "%s", prompt[argc-3]);
2364         return GED_MORE;
2365     }
2366 
2367     num_points = atoi(argv[5]);
2368     if (num_points < 1) {
2369         bu_vls_printf(gedp->ged_result_str, "Invalid number of points (must be at least 1)\n");
2370         return GED_ERROR;
2371     }
2372 
2373     if (argc < 10) {
2374         bu_vls_printf(gedp->ged_result_str, "%s", prompt[argc-3]);
2375         return GED_MORE;
2376     }
2377 
2378     if (argc < 6 + num_points*4) {
2379         bu_vls_printf(gedp->ged_result_str, "%s for point %d : ", prompt[6+(argc-9)%4], 1+(argc-5)/4);
2380         return GED_MORE;
2381     }
2382 
2383     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
2384     intern->idb_type = ID_METABALL;
2385     intern->idb_meth = &rt_functab[ID_METABALL];
2386 
2387     BU_ALLOC(intern->idb_ptr, struct rt_metaball_internal);
2388     metaball = (struct rt_metaball_internal *)intern->idb_ptr;
2389     metaball->magic = RT_METABALL_INTERNAL_MAGIC;
2390     metaball->threshold = threshold;
2391     metaball->method = method;
2392     BU_LIST_INIT(&metaball->metaball_ctrl_head);
2393 
2394     /*
2395      * since we use args instead of the num_points, it's possible to have
2396      * MORE points than the value in the num_points field if it's all on one
2397      * line. Is that a bug, or a feature?
2398      */
2399     for (i = 6; i < argc; i += 4) {
2400         struct wdb_metaballpt *metaballpt;
2401 
2402         BU_ALLOC(metaballpt, struct wdb_metaballpt);
2403         metaballpt->coord[0] = atof(argv[i]) * gedp->ged_wdbp->dbip->dbi_local2base;
2404         metaballpt->coord[1] = atof(argv[i+1]) * gedp->ged_wdbp->dbip->dbi_local2base;
2405         metaballpt->coord[2] = atof(argv[i+2]) * gedp->ged_wdbp->dbip->dbi_local2base;
2406         metaballpt->fldstr = atof(argv[i+3]) * gedp->ged_wdbp->dbip->dbi_local2base;
2407         metaballpt->sweat = 1.0;
2408 
2409         BU_LIST_INSERT(&metaball->metaball_ctrl_head, &metaballpt->l);
2410     }
2411 
2412     return GED_OK;
2413 }
2414 
2415 
2416 /* P N T S _ I N */
2417 static int
2418 pnts_in(struct ged *gedp, int argc, const char **argv, struct rt_db_internal *intern, char **prompt) {
2419     unsigned long i;
2420     unsigned long numPoints;
2421     long readPoints;
2422     struct rt_pnts_internal *pnts;
2423     void *headPoint = NULL;
2424 
2425     rt_pnt_type type;
2426 
2427     int oriented = 0;
2428     int hasColor = 0;
2429     int hasScale = 0;
2430     double defaultSize = 0.0;
2431 
2432     int valuesPerPoint;
2433     int nextPrompt;
2434 
2435     double local2base = gedp->ged_wdbp->dbip->dbi_local2base;
2436 
2437     /* prompt if points file */
2438     if (argc < 4) {
2439         bu_vls_printf(gedp->ged_result_str, "%s", prompt[0]);
2440         return GED_MORE;
2441     }
2442 
2443     /* if points are in a file */
2444     if ((BU_STR_EQUAL(argv[3], "yes")) || (BU_STR_EQUAL(argv[3], "y"))) {
2445 
2446         /* prompt for point file path and name */
2447         if (argc < 5) {
2448             bu_vls_printf(gedp->ged_result_str, "%s", prompt[16]);
2449             return GED_MORE;
2450         }
2451 
2452         /* prompt for file data format */
2453         if (argc < 6) {
2454             bu_vls_printf(gedp->ged_result_str, "%s", prompt[17]);
2455             return GED_MORE;
2456         }
2457 
2458         /* prompt for file data units */
2459         if (argc < 7) {
2460             bu_vls_printf(gedp->ged_result_str, "%s", prompt[18]);
2461             return GED_MORE;
2462         }
2463 
2464         /* prompt for default point size */
2465         if (argc < 8) {
2466             bu_vls_printf(gedp->ged_result_str, "%s", prompt[5]);
2467             return GED_MORE;
2468         }
2469 
2470         /* call function(s) to validate 'point file data format string' and return the
2471          * point-cloud type.
2472          */
2473 
2474         /* call function(s) to validate the units string and return the conversion factor to
2475          * millimeters.
2476          */
2477 
2478         /* call function(s) to read point cloud data and save into database.
2479          */
2480 
2481         bu_log("The ability to create a pnts primitive from a data file is not yet implemented.\n");
2482 
2483         return GED_ERROR;
2484 
2485     } /* endif to process point data file */
2486 
2487 
2488     /* prompt for readPoints if not entered */
2489     if (argc < 5) {
2490         bu_vls_printf(gedp->ged_result_str, "%s", prompt[1]);
2491         return GED_MORE;
2492     }
2493     readPoints = atol(argv[4]);
2494     if (readPoints < 0) {
2495         /* negative means automatically figure out how many points */
2496         readPoints = -1;
2497     }
2498 
2499     /* prompt for orientation */
2500     if (argc < 6) {
2501         bu_vls_printf(gedp->ged_result_str, "%s", prompt[2]);
2502         return GED_MORE;
2503     }
2504     oriented = booleanize(argv[5]);
2505 
2506     /* prompt for color */
2507     if (argc < 7) {
2508         bu_vls_printf(gedp->ged_result_str, "%s", prompt[3]);
2509         return GED_MORE;
2510     }
2511     hasColor = booleanize(argv[6]);
2512 
2513     /* prompt for uniform scale */
2514     if (argc < 8) {
2515         bu_vls_printf(gedp->ged_result_str, "%s", prompt[4]);
2516         return GED_MORE;
2517     }
2518     hasScale = booleanize(argv[7]); /* has scale if not uniform */
2519 
2520     /* prompt for size of points if not entered */
2521     if (argc < 9) {
2522         bu_vls_printf(gedp->ged_result_str, "%s", prompt[5]);
2523         return GED_MORE;
2524     }
2525     defaultSize = atof(argv[8]);
2526     if (defaultSize < 0.0) {
2527         defaultSize = 0.0;
2528         bu_log("WARNING: default point size must be non-negative, using zero\n");
2529     }
2530 
2531     /* how many values are we expecting per point */
2532     valuesPerPoint = ELEMENTS_PER_POINT;
2533     type = RT_PNT_TYPE_PNT;
2534     if (hasColor) {
2535         /* R G B */
2536         type = (rt_pnt_type)((int)type | (int)RT_PNT_TYPE_COL);
2537         valuesPerPoint += 3;
2538     }
2539     if (hasScale) {
2540         /* scale value */
2541         type = (rt_pnt_type)((int)type | (int)RT_PNT_TYPE_SCA);
2542         valuesPerPoint += 1;
2543     }
2544     if (oriented) {
2545         /* vector */
2546         valuesPerPoint += ELEMENTS_PER_VECT;
2547         type = (rt_pnt_type)((int)type | (int)RT_PNT_TYPE_NRM);
2548     }
2549 
2550     /* reset argc/argv to be just point data */
2551     argc -= 9;
2552     argv += 9;
2553     nextPrompt = argc % valuesPerPoint;
2554 
2555     /* determine the number of points */
2556     if (readPoints < 0) {
2557         /* determine count from argc */
2558         if (nextPrompt != 0) {
2559             bu_log("WARNING: Data mismatch.\n"
2560                    "\tFound %d extra values after reading %d points.\n"
2561                    "\tExpecting %d values per point.\n"
2562                    "\tOnly using %d points.\n",
2563                    nextPrompt,
2564                    argc / valuesPerPoint,
2565                    valuesPerPoint,
2566                    argc / valuesPerPoint);
2567         }
2568         numPoints = argc / valuesPerPoint;
2569     } else {
2570         numPoints = (unsigned long)readPoints;
2571     }
2572 
2573     /* prompt for X, Y, Z of points */
2574     if ((unsigned long)argc < numPoints * (unsigned long)valuesPerPoint) {
2575         int nextAsk = nextPrompt + 6;
2576         struct bu_vls vls = BU_VLS_INIT_ZERO;
2577 
2578         switch (type) {
2579             case RT_PNT_TYPE_PNT:
2580                 /* do nothing, they're in order */
2581                 break;
2582             case RT_PNT_TYPE_COL:
2583                 if (nextPrompt > 2) {
2584                     nextAsk += 3;
2585                 }
2586                 break;
2587             case RT_PNT_TYPE_SCA:
2588                 if (nextPrompt > 2) {
2589                     nextAsk += 6;
2590                 }
2591                 break;
2592             case RT_PNT_TYPE_NRM:
2593                 /* do nothing, they're in order */
2594                 break;
2595             case RT_PNT_TYPE_COL_SCA:
2596                 if (nextPrompt > 2) {
2597                     nextAsk += 3;
2598                 }
2599                 break;
2600             case RT_PNT_TYPE_COL_NRM:
2601                 /* do nothing, they're in order */
2602                 break;
2603             case RT_PNT_TYPE_SCA_NRM:
2604                 if (nextPrompt > 5) {
2605                     nextAsk += 3;
2606                 }
2607                 break;
2608             case RT_PNT_TYPE_COL_SCA_NRM:
2609                 /* do nothing, they're in order */
2610                 break;
2611         }
2612 
2613         bu_vls_printf(&vls, "%s for point %d: ",
2614                       prompt[nextAsk],
2615                       (argc + valuesPerPoint) / valuesPerPoint);
2616 
2617         bu_vls_printf(gedp->ged_result_str, "%s", bu_vls_addr(&vls));
2618 
2619         bu_vls_free(&vls);
2620         return GED_MORE;
2621     }
2622 
2623     /* now we have everything we need to allocate an internal */
2624 
2625     /* init database structure */
2626     intern->idb_major_type = DB5_MAJORTYPE_BRLCAD;
2627     intern->idb_type = ID_PNTS;
2628     intern->idb_meth = &rt_functab[ID_PNTS];
2629     BU_ALLOC(intern->idb_ptr, struct rt_pnts_internal);
2630 
2631     /* init internal structure */
2632     pnts = (struct rt_pnts_internal *) intern->idb_ptr;
2633     pnts->magic = RT_PNTS_INTERNAL_MAGIC;
2634     pnts->scale = defaultSize;
2635     pnts->type = type;
2636     pnts->count = numPoints;
2637     pnts->point = NULL;
2638 
2639     /* empty list head */
2640     switch (type) {
2641         case RT_PNT_TYPE_PNT:
2642             BU_ALLOC(headPoint, struct pnt);
2643             BU_LIST_INIT(&(((struct pnt *)headPoint)->l));
2644             break;
2645         case RT_PNT_TYPE_COL:
2646             BU_ALLOC(headPoint, struct pnt_color);
2647             BU_LIST_INIT(&(((struct pnt_color *)headPoint)->l));
2648             break;
2649         case RT_PNT_TYPE_SCA:
2650             BU_ALLOC(headPoint, struct pnt_scale);
2651             BU_LIST_INIT(&(((struct pnt_scale *)headPoint)->l));
2652             break;
2653         case RT_PNT_TYPE_NRM:
2654             BU_ALLOC(headPoint, struct pnt_normal);
2655             BU_LIST_INIT(&(((struct pnt_normal *)headPoint)->l));
2656             break;
2657         case RT_PNT_TYPE_COL_SCA:
2658             BU_ALLOC(headPoint, struct pnt_color_scale);
2659             BU_LIST_INIT(&(((struct pnt_color_scale *)headPoint)->l));
2660             break;
2661         case RT_PNT_TYPE_COL_NRM:
2662             BU_ALLOC(headPoint, struct pnt_color_normal);
2663             BU_LIST_INIT(&(((struct pnt_color_normal *)headPoint)->l));
2664             break;
2665         case RT_PNT_TYPE_SCA_NRM:
2666             BU_ALLOC(headPoint, struct pnt_scale_normal);
2667             BU_LIST_INIT(&(((struct pnt_scale_normal *)headPoint)->l));
2668             break;
2669         case RT_PNT_TYPE_COL_SCA_NRM:
2670             BU_ALLOC(headPoint, struct pnt_color_scale_normal);
2671             BU_LIST_INIT(&(((struct pnt_color_scale_normal *)headPoint)->l));
2672             break;
2673     }
2674     pnts->point = headPoint;
2675 
2676     /* store points in list */
2677     for (i = 0; i < numPoints * valuesPerPoint; i += valuesPerPoint) {
2678         void *point;
2679 
2680         /* bu_log("%d: [%s, %s, %s]\n", ((i-5)/3)+1, argv[i], argv[i+1], argv[i+2]); */
2681         switch (type) {
2682             case RT_PNT_TYPE_PNT:
2683                 BU_ALLOC(point, struct pnt);
2684                 ((struct pnt *)point)->v[X] = strtod(argv[i + 0], NULL) * local2base;
2685                 ((struct pnt *)point)->v[Y] = strtod(argv[i + 1], NULL) * local2base;
2686                 ((struct pnt *)point)->v[Z] = strtod(argv[i + 2], NULL) * local2base;
2687                 BU_LIST_PUSH(&(((struct pnt *)headPoint)->l), &((struct pnt *)point)->l);
2688                 break;
2689             case RT_PNT_TYPE_COL:
2690                 BU_ALLOC(point, struct pnt_color);
2691                 ((struct pnt_color *)point)->v[X] = strtod(argv[i + 0], NULL) * local2base;
2692                 ((struct pnt_color *)point)->v[Y] = strtod(argv[i + 1], NULL) * local2base;
2693                 ((struct pnt_color *)point)->v[Z] = strtod(argv[i + 2], NULL) * local2base;
2694                 ((struct pnt_color *)point)->c.buc_magic = BU_COLOR_MAGIC;
2695                 ((struct pnt_color *)point)->c.buc_rgb[0 /* RED */] = strtod(argv[i + 3], NULL);
2696                 ((struct pnt_color *)point)->c.buc_rgb[1 /* GRN */] = strtod(argv[i + 4], NULL);
2697                 ((struct pnt_color *)point)->c.buc_rgb[2 /* BLU */] = strtod(argv[i + 5], NULL);
2698                 BU_LIST_PUSH(&(((struct pnt_color *)headPoint)->l), &((struct pnt_color *)point)->l);
2699                 break;
2700             case RT_PNT_TYPE_SCA:
2701                 BU_ALLOC(point, struct pnt_scale);
2702                 ((struct pnt_scale *)point)->v[X] = strtod(argv[i + 0], NULL) * local2base;
2703                 ((struct pnt_scale *)point)->v[Y] = strtod(argv[i + 1], NULL) * local2base;
2704                 ((struct pnt_scale *)point)->v[Z] = strtod(argv[i + 2], NULL) * local2base;
2705                 ((struct pnt_scale *)point)->s = strtod(argv[i + 3], NULL) * local2base;
2706                 BU_LIST_PUSH(&(((struct pnt_scale *)headPoint)->l), &((struct pnt_scale *)point)->l);
2707                 break;
2708             case RT_PNT_TYPE_NRM:
2709                 BU_ALLOC(point, struct pnt_normal);
2710                 ((struct pnt_normal *)point)->v[X] = strtod(argv[i + 0], NULL) * local2base;
2711                 ((struct pnt_normal *)point)->v[Y] = strtod(argv[i + 1], NULL) * local2base;
2712                 ((struct pnt_normal *)point)->v[Z] = strtod(argv[i + 2], NULL) * local2base;
2713                 ((struct pnt_normal *)point)->n[X] = strtod(argv[i + 3], NULL) * local2base;
2714                 ((struct pnt_normal *)point)->n[Y] = strtod(argv[i + 4], NULL) * local2base;
2715                 ((struct pnt_normal *)point)->n[Z] = strtod(argv[i + 5], NULL) * local2base;
2716                 BU_LIST_PUSH(&(((struct pnt_normal *)headPoint)->l), &((struct pnt_normal *)point)->l);
2717                 break;
2718             case RT_PNT_TYPE_COL_SCA:
2719                 BU_ALLOC(point, struct pnt_color_scale);
2720                 ((struct pnt_color_scale *)point)->v[X] = strtod(argv[i + 0], NULL) * local2base;
2721                 ((struct pnt_color_scale *)point)->v[Y] = strtod(argv[i + 1], NULL) * local2base;
2722                 ((struct pnt_color_scale *)point)->v[Z] = strtod(argv[i + 2], NULL) * local2base;
2723                 ((struct pnt_color_scale *)point)->c.buc_magic = BU_COLOR_MAGIC;
2724                 ((struct pnt_color_scale *)point)->c.buc_rgb[0 /* RED */] = strtod(argv[i + 3], NULL);
2725                 ((struct pnt_color_scale *)point)->c.buc_rgb[1 /* GRN */] = strtod(argv[i + 4], NULL);
2726                 ((struct pnt_color_scale *)point)->c.buc_rgb[2 /* BLU */] = strtod(argv[i + 5], NULL);
2727                 ((struct pnt_color_scale *)point)->s = strtod(argv[i + 6], NULL) * local2base;
2728                 BU_LIST_PUSH(&(((struct pnt_color_scale *)headPoint)->l), &((struct pnt_color_scale *)point)->l);
2729                 break;
2730             case RT_PNT_TYPE_COL_NRM:
2731                 BU_ALLOC(point, struct pnt_color_normal);
2732                 ((struct pnt_color_normal *)point)->v[X] = strtod(argv[i + 0], NULL) * local2base;
2733                 ((struct pnt_color_normal *)point)->v[Y] = strtod(argv[i + 1], NULL) * local2base;
2734                 ((struct pnt_color_normal *)point)->v[Z] = strtod(argv[i + 2], NULL) * local2base;
2735                 ((struct pnt_color_normal *)point)->n[X] = strtod(argv[i + 3], NULL) * local2base;
2736                 ((struct pnt_color_normal *)point)->n[Y] = strtod(argv[i + 4], NULL) * local2base;
2737                 ((struct pnt_color_normal *)point)->n[Z] = strtod(argv[i + 5], NULL) * local2base;
2738                 ((struct pnt_color_normal *)point)->c.buc_magic = BU_COLOR_MAGIC;
2739                 ((struct pnt_color_normal *)point)->c.buc_rgb[0 /* RED */] = strtod(argv[i + 6], NULL);
2740                 ((struct pnt_color_normal *)point)->c.buc_rgb[1 /* GRN */] = strtod(argv[i + 7], NULL);
2741                 ((struct pnt_color_normal *)point)->c.buc_rgb[2 /* BLU */] = strtod(argv[i + 8], NULL);
2742                 BU_LIST_PUSH(&(((struct pnt_color_normal *)headPoint)->l), &((struct pnt_color_normal *)point)->l);
2743                 break;
2744             case RT_PNT_TYPE_SCA_NRM:
2745                 BU_ALLOC(point, struct pnt_scale_normal);
2746                 ((struct pnt_scale_normal *)point)->v[X] = strtod(argv[i + 0], NULL) * local2base;
2747                 ((struct pnt_scale_normal *)point)->v[Y] = strtod(argv[i + 1], NULL) * local2base;
2748                 ((struct pnt_scale_normal *)point)->v[Z] = strtod(argv[i + 2], NULL) * local2base;
2749                 ((struct pnt_scale_normal *)point)->n[X] = strtod(argv[i + 3], NULL) * local2base;
2750                 ((struct pnt_scale_normal *)point)->n[Y] = strtod(argv[i + 4], NULL) * local2base;
2751                 ((struct pnt_scale_normal *)point)->n[Z] = strtod(argv[i + 5], NULL) * local2base;
2752                 ((struct pnt_scale_normal *)point)->s = strtod(argv[i + 6], NULL) * local2base;
2753                 BU_LIST_PUSH(&(((struct pnt_scale_normal *)headPoint)->l), &((struct pnt_scale_normal *)point)->l);
2754                 break;
2755             case RT_PNT_TYPE_COL_SCA_NRM:
2756                 BU_ALLOC(point, struct pnt_color_scale_normal);
2757                 ((struct pnt_color_scale_normal *)point)->v[X] = strtod(argv[i + 0], NULL) * local2base;
2758                 ((struct pnt_color_scale_normal *)point)->v[Y] = strtod(argv[i + 1], NULL) * local2base;
2759                 ((struct pnt_color_scale_normal *)point)->v[Z] = strtod(argv[i + 2], NULL) * local2base;
2760                 ((struct pnt_color_scale_normal *)point)->n[X] = strtod(argv[i + 3], NULL) * local2base;
2761                 ((struct pnt_color_scale_normal *)point)->n[Y] = strtod(argv[i + 4], NULL) * local2base;
2762                 ((struct pnt_color_scale_normal *)point)->n[Z] = strtod(argv[i + 5], NULL) * local2base;
2763                 ((struct pnt_color_scale_normal *)point)->c.buc_magic = BU_COLOR_MAGIC;
2764                 ((struct pnt_color_scale_normal *)point)->c.buc_rgb[0 /* RED */] = strtod(argv[i + 6], NULL);
2765                 ((struct pnt_color_scale_normal *)point)->c.buc_rgb[1 /* GRN */] = strtod(argv[i + 7], NULL);
2766                 ((struct pnt_color_scale_normal *)point)->c.buc_rgb[2 /* BLU */] = strtod(argv[i + 8], NULL);
2767                 ((struct pnt_color_scale_normal *)point)->s = strtod(argv[i + 9], NULL) * local2base;
2768                 BU_LIST_PUSH(&(((struct pnt_color_scale_normal *)headPoint)->l), &((struct pnt_color_scale_normal *)point)->l);
2769                 break;
2770         }
2771     }
2772 
2773     return GED_OK;
2774 }
2775 
2776 
2777 int
2778 ged_in(struct ged *gedp, int argc, const char *argv[])
2779 {
2780     struct directory *dp;
2781     char *name;
2782     struct rt_db_internal internal;
2783     char **menu;
2784     int nvals, (*fn_in)();
2785 
2786     GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
2787     GED_CHECK_READ_ONLY(gedp, GED_ERROR);
2788     GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
2789 
2790     /* initialize result */
2791     bu_vls_trunc(gedp->ged_result_str, 0);
2792 
2793     /* Get the name of the solid to be created */
2794     if (argc < 2) {
2795         bu_vls_printf(gedp->ged_result_str, "Enter name of solid: ");
2796         return GED_MORE;
2797     }
2798     if (db_lookup(gedp->ged_wdbp->dbip,  argv[1], LOOKUP_QUIET) != RT_DIR_NULL) {
2799         bu_vls_printf(gedp->ged_result_str, "%s: %s already exists", argv[0], argv[1]);
2800         return GED_ERROR;
2801     }
2802     if (db_version(gedp->ged_wdbp->dbip) < 5 && (int)strlen(argv[1]) > NAMESIZE) {
2803         bu_vls_printf(gedp->ged_result_str, "%s: ERROR, v4 names are limited to %d characters\n", argv[0], NAMESIZE);
2804         return GED_ERROR;
2805     }
2806     /* Save the solid name */
2807     name = (char *)argv[1];
2808 
2809     /* Get the solid type to be created and make it */
2810     if (argc < 3) {
2811         bu_vls_printf(gedp->ged_result_str, "Enter solid type: ");
2812         return GED_MORE;
2813     }
2814 
2815     RT_DB_INTERNAL_INIT(&internal);
2816 
2817     /*
2818      * Decide which solid to make and get the rest of the args
2819      * make name <half|arb[4-8]|sph|ell|ellg|ell1|tor|tgc|tec|
2820      rec|trc|rcc|box|raw|rpp|rpc|rhc|epa|ehy|hyp|eto|superell>
2821     */
2822     if (BU_STR_EQUAL(argv[2], "ebm")) {
2823         nvals = 4;
2824         menu = p_ebm;
2825         fn_in = ebm_in;
2826     } else if (BU_STR_EQUAL(argv[2], "arbn")) {
2827         switch (arbn_in(gedp, argc, argv, &internal, &p_arbn[0])) {
2828             case GED_ERROR:
2829                 bu_vls_printf(gedp->ged_result_str, "%s: ERROR, ARBN not made!\n", argv[0]);
2830                 rt_db_free_internal(&internal);
2831                 return GED_ERROR;
2832             case GED_MORE:
2833                 return GED_MORE;
2834         }
2835         goto do_new_update;
2836     } else if (BU_STR_EQUAL(argv[2], "bot")) {
2837         switch (bot_in(gedp, argc, argv, &internal, &p_bot[0])) {
2838             case GED_ERROR:
2839                 bu_vls_printf(gedp->ged_result_str, "%s: ERROR, BOT not made!\n", argv[0]);
2840                 rt_db_free_internal(&internal);
2841                 return GED_ERROR;
2842             case GED_MORE:
2843                 return GED_MORE;
2844         }
2845         goto do_new_update;
2846     } else if (BU_STR_EQUAL(argv[2], "submodel")) {
2847         nvals = 3;
2848         menu = p_submodel;
2849         fn_in = submodel_in;
2850     } else if (BU_STR_EQUAL(argv[2], "vol")) {
2851         nvals = 9;
2852         menu = p_vol;
2853         fn_in = vol_in;
2854     } else if (BU_STR_EQUAL(argv[2], "hf")) {
2855         if (db_version(gedp->ged_wdbp->dbip) < 5) {
2856             nvals = 19;
2857             menu = p_hf;
2858             fn_in = hf_in;
2859             bu_vls_printf(gedp->ged_result_str, "%s: the height field is deprecated. Use the dsp primitive.\n", argv[0]);
2860         } else {
2861             bu_vls_printf(gedp->ged_result_str, "%s: the height field is deprecated. Use the dsp primitive.\n", argv[0]);
2862             return GED_ERROR;
2863         }
2864     } else if (BU_STR_EQUAL(argv[2], "poly") ||
2865                BU_STR_EQUAL(argv[2], "pg")) {
2866         bu_vls_printf(gedp->ged_result_str, "%s: the polysolid is deprecated and not supported by this command.\nUse the bot primitive.\n", argv[0]);
2867         return GED_ERROR;
2868     } else if (BU_STR_EQUAL(argv[2], "dsp")) {
2869         if (db_version(gedp->ged_wdbp->dbip) < 5) {
2870             nvals = 6;
2871             menu = p_dsp_v4;
2872             fn_in = dsp_in_v4;
2873         } else {
2874             nvals = 8;
2875             menu = p_dsp_v5;
2876             fn_in = dsp_in_v5;
2877         }
2878 
2879     } else if (BU_STR_EQUAL(argv[2], "pipe")) {
2880         switch (pipe_in(gedp, argc, argv, &internal, &p_pipe[0])) {
2881             case GED_ERROR:
2882                 bu_vls_printf(gedp->ged_result_str, "%s: ERROR, pipe not made!\n", argv[0]);
2883                 rt_db_free_internal(&internal);
2884                 return GED_ERROR;
2885             case GED_MORE:
2886                 return GED_MORE;
2887         }
2888         goto do_new_update;
2889     } else if (BU_STR_EQUAL(argv[2], "metaball")) {
2890         switch (metaball_in(gedp, argc, argv, &internal, &p_metaball[0])) {
2891             case GED_ERROR:
2892                 bu_vls_printf(gedp->ged_result_str, "%s: ERROR, metaball not made!\n", argv[0]);
2893                 rt_db_free_internal(&internal);
2894                 return GED_ERROR;
2895             case GED_MORE:
2896                 return GED_MORE;
2897         }
2898         goto do_new_update;
2899     } else if (BU_STR_EQUAL(argv[2], "ars")) {
2900         switch (ars_in(gedp, argc, argv, &internal, &p_ars[0])) {
2901             case GED_ERROR:
2902                 bu_vls_printf(gedp->ged_result_str, "%s: ERROR, ars not made!\n", argv[0]);
2903                 rt_db_free_internal(&internal);
2904                 return GED_ERROR;
2905             case GED_MORE:
2906                 return GED_MORE;
2907         }
2908         goto do_new_update;
2909     } else if (BU_STR_EQUAL(argv[2], "half")) {
2910         nvals = 3*1 + 1;
2911         menu = p_half;
2912         fn_in = half_in;
2913     } else if (bu_strncmp(argv[2], "arb", 3) == 0) {
2914         int n = atoi(&argv[2][3]);
2915 
2916         if (n < 4 || 8 < n) {
2917             bu_vls_printf(gedp->ged_result_str,
2918                           "%s: ERROR: %s not supported!\nsupported arbs: arb4 arb5 arb6 arb7 arb8\n",
2919                           argv[0], argv[2]);
2920             return GED_ERROR;
2921         }
2922 
2923         nvals = 3*n;
2924         menu = p_arb;
2925         fn_in = arb_in;
2926     } else if (BU_STR_EQUAL(argv[2], "sph")) {
2927         nvals = 3*1 + 1;
2928         menu = p_sph;
2929         fn_in = sph_in;
2930     } else if (BU_STR_EQUAL(argv[2], "ellg")) {
2931         nvals = 3*2 + 1;
2932         menu = p_ellg;
2933         fn_in = ell_in;
2934     } else if (BU_STR_EQUAL(argv[2], "ell")) {
2935         nvals = 3*4;
2936         menu = p_ell;
2937         fn_in = ell_in;
2938     } else if (BU_STR_EQUAL(argv[2], "ell1")) {
2939         nvals = 3*2 + 1;
2940         menu = p_ell1;
2941         fn_in = ell_in;
2942     } else if (BU_STR_EQUAL(argv[2], "tor")) {
2943         nvals = 3*2 + 2;
2944         menu = p_tor;
2945         fn_in = tor_in;
2946     } else if (BU_STR_EQUAL(argv[2], "tgc")) {
2947         nvals = 3*4 + 2;
2948         menu = p_tgc;
2949         fn_in = tgc_in;
2950     } else if (BU_STR_EQUAL(argv[2], "tec")) {
2951         nvals = 3*4 + 1;
2952         menu = p_tec;
2953         fn_in = tec_in;
2954     } else if (BU_STR_EQUAL(argv[2], "rec")) {
2955         nvals = 3*4;
2956         menu = p_rec;
2957         fn_in = rec_in;
2958     } else if (BU_STR_EQUAL(argv[2], "trc")) {
2959         nvals = 3*2 + 2;
2960         menu = p_trc;
2961         fn_in = trc_in;
2962     } else if (BU_STR_EQUAL(argv[2], "rcc")) {
2963         nvals = 3*2 + 1;
2964         menu = p_rcc;
2965         fn_in = rcc_in;
2966     } else if (BU_STR_EQUAL(argv[2], "box")
2967                || BU_STR_EQUAL(argv[2], "raw")) {
2968         nvals = 3*4;
2969         menu = p_box;
2970         fn_in = box_in;
2971     } else if (BU_STR_EQUAL(argv[2], "rpp")) {
2972         nvals = 3*2;
2973         menu = p_rpp;
2974         fn_in = rpp_in;
2975     } else if (BU_STR_EQUAL(argv[2], "orpp")) {
2976         nvals = 3*1;
2977         menu = p_orpp;
2978         fn_in = orpp_in;
2979     } else if (BU_STR_EQUAL(argv[2], "rpc")) {
2980         nvals = 3*3 + 1;
2981         menu = p_rpc;
2982         fn_in = rpc_in;
2983     } else if (BU_STR_EQUAL(argv[2], "rhc")) {
2984         nvals = 3*3 + 2;
2985         menu = p_rhc;
2986         fn_in = rhc_in;
2987     } else if (BU_STR_EQUAL(argv[2], "epa")) {
2988         nvals = 3*3 + 1;
2989         menu = p_epa;
2990         fn_in = epa_in;
2991     } else if (BU_STR_EQUAL(argv[2], "ehy")) {
2992         nvals = 3*3 + 2;
2993         menu = p_ehy;
2994         fn_in = ehy_in;
2995     } else if (BU_STR_EQUAL(argv[2], "hyp")) {
2996         nvals = 3*3 + 2;
2997         menu = p_hyp;
2998         fn_in = hyp_in;
2999     } else if (BU_STR_EQUAL(argv[2], "eto")) {
3000         nvals = 3*3 + 2;
3001         menu = p_eto;
3002         fn_in = eto_in;
3003     } else if (BU_STR_EQUAL(argv[2], "part")) {
3004         nvals = 2*3 + 2;
3005         menu = p_part;
3006         fn_in = part_in;
3007     } else if (BU_STR_EQUAL(argv[2], "binunif")) {
3008         if (db_version(gedp->ged_wdbp->dbip) < 5) {
3009             bu_vls_printf(gedp->ged_result_str,
3010                           "%s: the binunif primitive is not supported by this command when using an old style database",
3011                           argv[0]);
3012             return GED_ERROR;
3013         } else {
3014             nvals = 3;
3015             menu = p_binunif;
3016             fn_in = binunif_in;
3017         }
3018     } else if (BU_STR_EQUAL(argv[2], "extrude")) {
3019         nvals = 4*3 + 1;
3020         menu = p_extrude;
3021         fn_in = extrude_in;
3022     } else if (BU_STR_EQUAL(argv[2], "revolve")) {
3023         nvals = 3*3 + 2;
3024         menu = p_revolve;
3025         fn_in = revolve_in;
3026     } else if (BU_STR_EQUAL(argv[2], "grip")) {
3027         nvals = 2*3 + 1;
3028         menu = p_grip;
3029         fn_in = grip_in;
3030     } else if (BU_STR_EQUAL(argv[2], "superell")) {
3031         nvals = 3*4 + 2;
3032         menu = p_superell;
3033         fn_in = superell_in;
3034     } else if (BU_STR_EQUAL(argv[2], "pnts")) {
3035         switch (pnts_in(gedp, argc, argv, &internal, p_pnts)) {
3036             case GED_ERROR:
3037                 bu_vls_printf(gedp->ged_result_str, "%s: ERROR, pnts not made!\n", argv[0]);
3038                 rt_db_free_internal(&internal);
3039                 return GED_ERROR;
3040             case GED_MORE:
3041                 return GED_MORE;
3042         }
3043 
3044         goto do_new_update;
3045     } else if (BU_STR_EQUAL(argv[2], "cline") ||
3046                BU_STR_EQUAL(argv[2], "grip") ||
3047                BU_STR_EQUAL(argv[2], "nmg") ||
3048                BU_STR_EQUAL(argv[2], "nurb") ||
3049                BU_STR_EQUAL(argv[2], "sketch") ||
3050                BU_STR_EQUAL(argv[2], "spline")) {
3051         bu_vls_printf(gedp->ged_result_str, "%s: the %s primitive is not supported by this command", argv[0], argv[2]);
3052         return GED_ERROR;
3053     } else {
3054         bu_vls_printf(gedp->ged_result_str, "%s: %s is not a known primitive\n", argv[0], argv[2]);
3055         return GED_ERROR;
3056     }
3057 
3058     /* Read arguments */
3059     if (argc < 3+nvals) {
3060         bu_vls_printf(gedp->ged_result_str, "%s", menu[argc-3]);
3061         return GED_MORE;
3062     }
3063 
3064     if (fn_in(gedp, argv, &internal, name) != 0) {
3065         bu_vls_printf(gedp->ged_result_str, "%s: ERROR %s not made!\n", argv[0], argv[2]);
3066         if (internal.idb_ptr) {
3067             /* a few input functions do not use the internal pointer
3068              * only free it, if it has been used
3069              */
3070             rt_db_free_internal(&internal);
3071         }
3072         return GED_ERROR;
3073     }
3074 
3075 do_new_update:
3076     /* The function may have already written via LIBWDB */
3077     if (internal.idb_ptr != NULL) {
3078         dp=db_diradd(gedp->ged_wdbp->dbip, name, RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (genptr_t)&internal.idb_type);
3079         if (dp == RT_DIR_NULL) {
3080             rt_db_free_internal(&internal);
3081             bu_vls_printf(gedp->ged_result_str, "%s: Cannot add '%s' to directory\n", argv[0], name);
3082             return GED_ERROR;
3083         }
3084         if (rt_db_put_internal(dp, gedp->ged_wdbp->dbip, &internal, &rt_uniresource) < 0) {
3085             rt_db_free_internal(&internal);
3086             bu_vls_printf(gedp->ged_result_str, "%s: Database write error, aborting\n", argv[0]);
3087             return GED_ERROR;
3088         }
3089     }
3090 
3091     bu_vls_printf(gedp->ged_result_str, "%s", argv[1]);
3092     return GED_OK;
3093 }
3094 
3095 
3096 /*
3097  * Local Variables:
3098  * mode: C
3099  * tab-width: 8
3100  * indent-tabs-mode: t
3101  * c-file-style: "stroustrup"
3102  * End:
3103  * ex: shiftwidth=4 tabstop=8
3104  */
3105 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.