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