Revision: 76154
http://sourceforge.net/p/brlcad/code/76154
Author: starseeker
Date: 2020-06-18 17:10:24 +0000 (Thu, 18 Jun 2020)
Log Message:
-----------
Go ahead and merge the burst changes back from the branch - this should be
fairly self contained.
Modified Paths:
--------------
brlcad/trunk/regress/burst/CMakeLists.txt
brlcad/trunk/regress/burst/ktank.b
brlcad/trunk/src/burst/CMakeLists.txt
brlcad/trunk/src/libbu/units.c
Added Paths:
-----------
brlcad/trunk/regress/burst/echo.b
brlcad/trunk/regress/burst/ktank_colors.ids
brlcad/trunk/src/burst/burst.cpp
brlcad/trunk/src/burst/burst.h
brlcad/trunk/src/burst/grid.cpp
brlcad/trunk/src/burst/idents.cpp
brlcad/trunk/src/burst/old/
brlcad/trunk/src/burst/paint.cpp
Removed Paths:
-------------
brlcad/trunk/src/burst/Hm.c
brlcad/trunk/src/burst/HmGetc.c
brlcad/trunk/src/burst/HmGlob.c
brlcad/trunk/src/burst/Mm.h
brlcad/trunk/src/burst/Sc.c
brlcad/trunk/src/burst/Sc.h
brlcad/trunk/src/burst/ascii.h
brlcad/trunk/src/burst/burst.c
brlcad/trunk/src/burst/burst.h
brlcad/trunk/src/burst/error.c
brlcad/trunk/src/burst/extern.h
brlcad/trunk/src/burst/fb.c
brlcad/trunk/src/burst/glob.c
brlcad/trunk/src/burst/grid.c
brlcad/trunk/src/burst/gridrotate.c
brlcad/trunk/src/burst/idents.c
brlcad/trunk/src/burst/paint.c
brlcad/trunk/src/burst/plot.c
brlcad/trunk/src/burst/prnt.c
brlcad/trunk/src/burst/trie.c
brlcad/trunk/src/burst/ui.c
Property Changed:
----------------
brlcad/trunk/
brlcad/trunk/NEWS
brlcad/trunk/doc/
brlcad/trunk/include/
brlcad/trunk/regress/
brlcad/trunk/src/libbu/
Index: brlcad/trunk
===================================================================
--- brlcad/trunk 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk 2020-06-18 17:10:24 UTC (rev 76154)
Property changes on: brlcad/trunk
___________________________________________________________________
Modified: svn:mergeinfo
## -1,5 +1,5 ##
/brlcad/branches/RELEASE:57439,57447-57860,69901-69913,70323-70333,71915-72242,72525-72534,72826-72858,74376-74454,74964-75140,75372-75685
-/brlcad/branches/bioh:75720-75736,75740-75742,75860-75891,75894-75986
+/brlcad/branches/bioh:75720-75736,75740-75742,75860-75891,75894-75986,76088-76153
/brlcad/branches/brep-debug:61373,61375,61404,61427,61429,61470,61544,61567,61576,61999,62018,62094,62098,62107,62117,62406,62416-62519,62521-62584,62593-62614,62623,62658,62660-62674,62681-62771,62876,62901,62907,62910,62925,62928,62931-63025,63027,63051,63054-63056,63069,63071-63073,63122,63160-63161,63165,63171,63184,63187,63189-63190,63193-63196,63200,63202,63205-63210,63213,63219-63225,63232-63233,63236,63238,63338,63350-63353,63481,63618,63669,64173-64174,64176-64177,64229-64233,64242,64244,64360-64362,65165,65245,65249,65334,65833-65834,66370-66375,66931-66932,66934,67012-67015,67018-67019,67021-67022,67406,67740,67746-67748,67950,67952,68144-68145,68636,68640-68643,68820,69081,69109,69168,69206,69289,69346,69460-69461,69582-69583,69719-69721,69857-69859,69927,69995-69996,70148-70149,70347-70349,70377,70526-70527,71006-71007,71009-71022,71046-71047,71049,71096-71100
/brlcad/branches/bullet:62518
/brlcad/branches/cmake:43219
Index: brlcad/trunk/NEWS
===================================================================
--- brlcad/trunk/NEWS 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/NEWS 2020-06-18 17:10:24 UTC (rev 76154)
Property changes on: brlcad/trunk/NEWS
___________________________________________________________________
Modified: svn:mergeinfo
## -1,5 +1,5 ##
/brlcad/branches/RELEASE/NEWS:57439,57447-57860,68609-68613,69901-69913,70323-70333,71915-72242,72525-72534,72826-72858,74376-74454,74964-75140
-/brlcad/branches/bioh/NEWS:75894-75986
+/brlcad/branches/bioh/NEWS:75894-75986,76088-76153
/brlcad/branches/brep-debug/NEWS:61373,61375,61404,61427,61429,61470,61544,61567,61576,61999,62018,62094,62098,62107,62117,62406,62416-62519,62521-62584,62593-62614,62623,62658,62660-62674,62681-62771,62876,62901,62907,62910,62925,62928,62931-63025,63027,63051,63054-63056,63069,63071-63073,63122,63160-63161,63165,63171,63184,63187,63189-63190,63193-63196,63200,63202,63205-63210,63213,63219-63225,63232-63233,63236,63238,63338,63350-63353,63481,63618,63669,64173-64174,64176-64177,64229-64233,64242,64244,64360-64362,65165,65245,65249,65334,65833-65834,66370-66375,66931-66932,66934,67012-67015,67018-67019,67021-67022,67406,67740,67746-67748,67950,67952,68144-68145,68636,68640-68643,68820,69081,69109,69168,69206,69289,69346,69460-69461,69582-69583,69719-69721,69857-69859,69927,69995-69996,70148-70149,70347-70349,70377,70526-70527,71006-71007,71009-71022,71046-71047,71049,71096-71100
/brlcad/branches/bullet/NEWS:62518
/brlcad/branches/cmake/NEWS:43219
Index: brlcad/trunk/doc
===================================================================
--- brlcad/trunk/doc 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/doc 2020-06-18 17:10:24 UTC (rev 76154)
Property changes on: brlcad/trunk/doc
___________________________________________________________________
Modified: svn:mergeinfo
## -1,5 +1,5 ##
/brlcad/branches/RELEASE/doc:57439,57447-57860,69901-69913,71917-72242,72525-72534,72826-72858,74376-74454,74964-75140
-/brlcad/branches/bioh/doc:75894-75986
+/brlcad/branches/bioh/doc:75894-75986,76088-76153
/brlcad/branches/brep-debug/doc:61373,61375,61404,61427,61429,61470,61544,61567,61576,61999,62018,62094,62098,62107,62117,62406,62416-62519,62521-62584,62593-62614,62623,62658,62660-62674,62681-62771,62876,62901,62907,62910,62925,62928,62931-63025,63027,63051,63054-63056,63069,63071-63073,63122,63160-63161,63165,63171,63184,63187,63189-63190,63193-63196,63200,63202,63205-63210,63213,63219-63225,63232-63233,63236,63238,63338,63350-63353,63481,63618,63669,64173-64174,64176-64177,64229-64233,64242,64244,64360-64362,65165,65245,65249,65334,65833-65834,66370-66375,66931-66932,66934,67012-67015,67018-67019,67021-67022,67406,67740,67746-67748,67950,67952,68144-68145,68636,68640-68643,68820,69081,69109,69206,69289,69346,69460-69461,69582-69583,69719-69721,69857-69859,69927
/brlcad/branches/bullet/doc:62518
/brlcad/branches/cmake/doc:43219
Index: brlcad/trunk/include
===================================================================
--- brlcad/trunk/include 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/include 2020-06-18 17:10:24 UTC (rev 76154)
Property changes on: brlcad/trunk/include
___________________________________________________________________
Modified: svn:mergeinfo
## -1,5 +1,5 ##
/brlcad/branches/RELEASE/include:57439,57447-57860,69901-69913,71915-72242,72525-72534,72826-72858,74376-74454,74964-75140,75372-75681
-/brlcad/branches/bioh/include:75720-75736,75740-75742,75860-75891,75894-75986
+/brlcad/branches/bioh/include:75720-75736,75740-75742,75860-75891,75894-75986,76088-76153
/brlcad/branches/brep-debug/include:61373,61375,61404,61427,61429,61470,61544,61567,61576,61999,62018,62094,62098,62107,62117,62406,62416-62519,62521-62584,62593-62614,62623,62658,62660-62674,62681-62771,62876,62901,62907,62910,62925,62928,62931-63025,63027,63051,63054-63056,63069,63071-63073,63122,63160-63161,63165,63171,63184,63187,63189-63190,63193-63196,63200,63202,63205-63210,63213,63219-63225,63232-63233,63236,63238,63338,63350-63353,63481,63618,63669,64173-64174,64176-64177,64229-64233,64242,64244,64360-64362,65165,65245,65249,65334,65833-65834,66370-66375,66931-66932,66934,67012-67015,67018-67019,67021-67022,67406,67740,67746-67748,67950,67952,68144-68145,68636,68640-68643,68820,69081,69109,69206,69289,69346,69460-69461,69582-69583,69719-69721,69857-69859,69927
/brlcad/branches/bullet/include:62518
/brlcad/branches/cmake/include:43219
Index: brlcad/trunk/regress
===================================================================
--- brlcad/trunk/regress 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/regress 2020-06-18 17:10:24 UTC (rev 76154)
Property changes on: brlcad/trunk/regress
___________________________________________________________________
Modified: svn:mergeinfo
## -1,5 +1,5 ##
/brlcad/branches/RELEASE/regress:57439,57447-57860,69901-69913,71917-72242,72525-72534,72826-72858,74376-74454,75372-75681
-/brlcad/branches/bioh/regress:75860-75891,75894-75986
+/brlcad/branches/bioh/regress:75860-75891,75894-75986,76088-76153
/brlcad/branches/brep-debug/regress:61373,61375,61404,61427,61429,61470,61544,61567,61576,61999,62018,62094,62098,62107,62117,62406,62416-62519,62521-62584,62593-62614,62623,62658,62660-62674,62681-62771,62876,62901,62907,62910,62925,62928,62931-63025,63027,63051,63054-63056,63069,63071-63073,63122,63160-63161,63165,63171,63184,63187,63189-63190,63193-63196,63200,63202,63205-63210,63213,63219-63225,63232-63233,63236,63238,63338,63350-63353,63481,63618,63669,64173-64174,64176-64177,64229-64233,64242,64244,64360-64362,65165,65245,65249,65334,65833-65834,66370-66375,66931-66932,66934,67012-67015,67018-67019,67021-67022,67406,67740,67746-67748,67950,67952,68144-68145,68636,68640-68643,68820,69081,69109,69206,69289,69346,69460-69461,69582-69583,69719-69721,69857-69859,69927
/brlcad/branches/bullet/regress:62518
/brlcad/branches/cmake/regress:43219
Modified: brlcad/trunk/regress/burst/CMakeLists.txt
===================================================================
--- brlcad/trunk/regress/burst/CMakeLists.txt 2020-06-18 15:37:23 UTC (rev
76153)
+++ brlcad/trunk/regress/burst/CMakeLists.txt 2020-06-18 17:10:24 UTC (rev
76154)
@@ -3,6 +3,7 @@
ktank_air.ids
ktank_armor.ids
ktank_crit.ids
+ ktank_colors.ids
)
BRLCAD_REGRESSION_TEST(regress-burst "burst;ktank.g" EXEC burst)
@@ -29,6 +30,7 @@
CMAKEFILES(
CMakeLists.txt
+ echo.b
${BURST_INPUT_FILES}
)
Copied: brlcad/trunk/regress/burst/echo.b (from rev 76153,
brlcad/branches/bioh/regress/burst/echo.b)
===================================================================
--- brlcad/trunk/regress/burst/echo.b (rev 0)
+++ brlcad/trunk/regress/burst/echo.b 2020-06-18 17:10:24 UTC (rev 76154)
@@ -0,0 +1,39 @@
+attack-direction 35 25
+critical-comp-file ccf.file
+deflect-spall-cone yes
+dither-cells yes
+enclose-target
+enclose-portion 1 2 3 4
+#error-file error.file
+grid-file grid.file
+ground-plane yes 10 2 -2 3 -3
+burst-air-file ba.file
+histogram-file histo.file
+image-file image.file
+input-2d-shot 10 20
+input-3d-shot 10 20 30
+max-barriers 3
+max-spall-rays 7
+plot-file plot.file
+read-2d-shot-file 2dshot.file
+read-3d-shot-file 3dshot.file
+burst-armor-file armor.file
+read-burst-file rburst.file
+read-input-file input.file
+report-overlaps yes
+shotline-burst yes
+shotline-file shotline.file
+target-file target.file
+target-objects obj1 obj2 obj3
+units inches
+units feet
+units millimeters
+units centimeters
+units meters
+write-input-file inputs.file
+burst-coordinates 20 30 40
+burst-distance 10.0
+burst-file burst.file
+cell-size 11.0
+color-file color.file
+cone-half-angle 45
Modified: brlcad/trunk/regress/burst/ktank.b
===================================================================
--- brlcad/trunk/regress/burst/ktank.b 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/regress/burst/ktank.b 2020-06-18 17:10:24 UTC (rev 76154)
@@ -7,7 +7,7 @@
burst-air-file ktank_air.ids
burst-armor-file ktank_armor.ids
critical-comp-file ktank_crit.ids
-#color-file ktank_burst_colors
+color-file ktank_colors.ids
burst-distance 0
cell-size 16
attack-direction 0 0
Copied: brlcad/trunk/regress/burst/ktank_colors.ids (from rev 76153,
brlcad/branches/bioh/regress/burst/ktank_colors.ids)
===================================================================
--- brlcad/trunk/regress/burst/ktank_colors.ids (rev 0)
+++ brlcad/trunk/regress/burst/ktank_colors.ids 2020-06-18 17:10:24 UTC (rev
76154)
@@ -0,0 +1 @@
+100 120 0 252 0
Modified: brlcad/trunk/src/burst/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/burst/CMakeLists.txt 2020-06-18 15:37:23 UTC (rev
76153)
+++ brlcad/trunk/src/burst/CMakeLists.txt 2020-06-18 17:10:24 UTC (rev
76154)
@@ -1,42 +1,36 @@
+# Until the new code is proved out, keep the original around
+# as burst-old
+add_subdirectory(old)
+
+set(LDIR "${BRLCAD_SOURCE_DIR}/src/other/linenoise")
+
set(BURST_INCLUDE_DIRS
+ ${BU_INCLUDE_DIRS}
${FB_INCLUDE_DIRS}
${RT_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}/src/other/linenoise
)
list(REMOVE_DUPLICATES BURST_INCLUDE_DIRS)
include_directories(${BURST_INCLUDE_DIRS})
set(burst_SOURCES
- Hm.c
- HmGetc.c
- HmGlob.c
- Sc.c
- burst.c
- error.c
- fb.c
- glob.c
- grid.c
- gridrotate.c
- idents.c
- paint.c
- plot.c
- prnt.c
- trie.c
- ui.c
+ burst.cpp
+ grid.cpp
+ idents.cpp
+ paint.cpp
+ ${LDIR}/utf8.c
+ ${LDIR}/linenoise.c
)
+BRLCAD_ADDEXEC(burst "${burst_SOURCES}" "librt;libfb;libbu;${M_LIBRARY}")
-BRLCAD_ADDEXEC(burst "${burst_SOURCES}" "librt;libfb;${M_LIBRARY}")
-
-set(burst_noinst_HEADERS
+set(burst_ignore
CMakeLists.txt
- ascii.h
burst.h
- extern.h
- Mm.h
- Sc.h
+ burst.format
)
-CMAKEFILES(${burst_noinst_HEADERS} burst.format)
+CMAKEFILES(${burst_ignore})
# Local Variables:
# tab-width: 8
Deleted: brlcad/trunk/src/burst/Hm.c
===================================================================
--- brlcad/trunk/src/burst/Hm.c 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/src/burst/Hm.c 2020-06-18 17:10:24 UTC (rev 76154)
@@ -1,1130 +0,0 @@
-/* H M . C
- * BRL-CAD
- *
- * Copyright (c) 2004-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- *
- */
-/** @file burst/Hm.c
- *
- * This code is derived in part from menuhit(9.3) in AT&T 9th Edition
- * UNIX, Version 1 Programmer's Manual.
- */
-
-#include "common.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-
-#include "bu/file.h"
-
-#include "./Sc.h"
-#include "./Mm.h"
-#include "./extern.h"
-
-#if defined(HAVE_FDOPEN) && !defined(HAVE_DECL_FDOPEN)
-extern FILE *fdopen(int fd, const char *mode);
-#endif
-
-#define ErLog brst_log
-
-#define HmDEBUG 0
-
-#ifndef Max
-# define Max(_a, _b) ((_a)<(_b)?(_b):(_a))
-# define Min(_a, _b) ((_a)>(_b)?(_b):(_a))
-#endif
-
-#define HmRingbell() (void) putchar('\07'), (void) fflush(stdout)
-
-/* Keys for manipulating menus. */
-#define Ctrl(c_) ((c_)&037)
-#define M_DEBUG Ctrl('?')
-#define M_DOWN 'd'
-#define M_HELP 'h'
-#define M_MYXMOUSE Ctrl('X')
-#define M_NOSELECT 'q'
-#define M_REDRAW Ctrl('L')
-#define M_SELECT ' '
-#define M_UP 'u'
-
-
-/* Alternate keys for conformance to standard conventions. */
-#define A_UP Ctrl('P')
-#define A_DOWN Ctrl('N')
-#define A_HELP '?'
-
-#define P_OFF (0)
-#define P_ON (1)
-#define P_FORCE (1<<1)
-
-#define PutMenuChar(_c, _co, _ro, _map, _bit) {\
- static int lro = -1, lco = -1;\
- if ((_map) & (_bit) || (_bit) == 0) {\
- if (lco++ != (_co)-1 || lro != (_ro)) {\
- (void) ScMvCursor(_co, _ro);\
- lco = _co;\
- }\
- (void) putchar((_c));\
- }\
- (_bit) <<= 1;\
- (_co)++;\
-}
-
-
-static int HmDirty = 0;
-static int HmPkgInit = 0;
-
-static HmWindow *windows = NULL;
-
-#define HmENTRY (itemp-win->menup->item)
-#define HmHEIGHT Min(win->height, HmMaxVis)
-typedef struct nmllist HmLList;
-struct nmllist
-{
- HmItem *itemp;
- HmLList *next;
-};
-
-
-/*
- void HmBanner(char *pgmname, int borderchr)
-
- Print program name and row of border characters to delimit the top
- of the scrolling region.
-*/
-void
-HmBanner(const char *pgmname, int borderchr)
-{
- int column;
- char *p;
-#define HmBUFLEN 81
- static char HmPgmName[HmBUFLEN] = "No name";
- static int HmBorderChr = '_';
- if (pgmname != NULL) {
- bu_strlcpy(HmPgmName, pgmname, sizeof(HmPgmName));
- HmBorderChr = borderchr;
- }
- (void) ScMvCursor(HmLftMenu, HmYBORDER);
- for (column = 1; column <= 3; column++)
- (void) putc(HmBorderChr, stdout);
- for (p = HmPgmName; column <= ScCO && *p != '\0'; column++, p++)
- (void) putc((int)(*p), stdout);
- for (; column <= ScCO; column++)
- (void) putc(HmBorderChr, stdout);
- return;
-}
-
-
-/*
- void HmPrntItem(HmItem *itemp) (DEBUG)
-
- Print contents of itemp.
-*/
-static void
-HmPrntItem(HmItem *itemp)
-{
- (void) ErLog("\t\tHmPrntItem(0x%x)\n", itemp);
- for (; itemp->text != (char *) NULL; itemp++) {
- (void) ErLog("\t\t\ttext=\"%s\"\n", itemp->text);
- (void) ErLog("\t\t\thelp=\"%s\"\n", itemp->help == (char *) NULL ?
"(null)" : itemp->help);
- (void) ErLog("\t\t\tnext=0x%x\n", itemp->next);
- (void) ErLog("\t\t\tdfn=0x%x\n", itemp->dfn);
- (void) ErLog("\t\t\tbfn=0x%x\n", itemp->bfn);
- (void) ErLog("\t\t\thfn=0x%x\n", itemp->hfn);
- (void) ErLog("\t\t\tdata=%d\n", itemp->data);
- (void) ErLog("\t\t\t----\n");
- }
- (void) ErLog("\t\t\ttext=0x%x\n", itemp->text);
- return;
-}
-
-
-/*
- void HmPrntMenu(menup) (DEBUG)
-
- Print "windows" stack.
-*/
-static void
-HmPrntMenu(HmMenu *menup)
-{
- (void) ErLog("\tHmPrntMenu(0x%x)\n", menup);
- (void) ErLog("\t\tgenerator=0x%x\n", menup->generator);
- (void) ErLog("\t\tprevtop=%d\n", menup->prevtop);
- (void) ErLog("\t\tprevhit=%d\n", menup->prevhit);
- (void) ErLog("\t\tsticky=%s\n", menup->sticky ? "true" : "false");
- HmPrntItem(menup->item);
- return;
-}
-
-
-/*
- void HmPrntWindows(void) (DEBUG)
-
- Print "windows" stack.
-*/
-static void
-HmPrntWindows(void)
-{
- HmWindow *win;
- (void) ErLog("HmPrntWindows()\n");
- for (win = windows; win != (HmWindow *) NULL; win = win->next) {
- (void) ErLog("\twin=0x%x\n", win);
- (void) ErLog("\tmenup=0x%x\n", win->menup);
- (void) ErLog("\tmenux=%d\n", win->menux);
- (void) ErLog("\tmenuy=%d\n", win->menuy);
- (void) ErLog("\twidth=%d\n", win->width);
- (void) ErLog("\theight=%d\n", win->height);
- (void) ErLog("\tdirty=0x%x\n", win->dirty);
- (void) ErLog("\tnext=0x%x\n", win->next);
- HmPrntMenu(win->menup);
- }
- return;
-}
-
-
-/*
- void HmFreeItems(Hmitem *itemp)
-
- Free storage (allocated with malloc) for an array of HmItem's.
-*/
-static void
-HmFreeItems(HmItem *itemp)
-{
- HmItem *citemp;
- int count;
- for (citemp = itemp, count = 1;
- citemp->text != (char *) NULL;
- citemp++, count++
- ) {
- MmStrFree(citemp->text);
- if (citemp->help != (char *) NULL)
- MmStrFree(citemp->help);
- }
- MmVFree(count, HmItem, itemp);
- return;
-}
-
-
-/*
- void HmFreeLList(HmLList *listp)
-
- Free storage (allocated with malloc) for a linked-list of
- HmItem's.
-*/
-static void
-HmFreeLList(HmLList *listp)
-{
- HmLList *tp;
- for (; listp != (HmLList *) NULL; listp = tp) {
- MmFree(HmItem, listp->itemp);
- tp = listp->next;
- MmFree(HmLList, listp);
- }
- return;
-}
-
-
-/*
- void HmPutItem(HmWindow *win, HmItem *itemp, int flag)
-
- Display menu entry itemp.
-
- Win is the menu control structure for itemp.
-
- Flag is a bit flag and the following bits are meaningful:
-
- P_FORCE means draw the entire entry regardless of the
- value of the dirty bitmap.
- P_ON means this entry is current so highlight it.
-*/
-static void
-HmPutItem(HmWindow *win, HmItem *itemp, int flag)
-{
- int label_len = strlen(itemp->text);
- static char buf[HmMAXLINE];
- char *p = buf;
- int col = win->menux;
- int row = win->menuy+
- (HmENTRY-win->menup->prevtop)+1;
- int width = win->width;
- int bitmap = flag & P_FORCE ?
- ~0 : win->dirty[row-win->menuy];
- int bit = 1;
- int writemask = 0;
- if (bitmap == 0)
- return;
- if (itemp->text[0] & 0200) {
- /* right-justified */
- int i;
- label_len--;
- for (i = 0; i < width - label_len; i++)
- *p++ = itemp->text[0] & 0177;
- for (i = 1; itemp->text[i] != '\0'; i++)
- *p++ = itemp->text[i];
- } else /* left-justified */
- if (itemp->text[label_len-1] & 0200) {
- int i;
- label_len--;
- for (i = 0; !(itemp->text[i] & 0200); i++)
- *p++ = itemp->text[i];
- for (; i < width; i++)
- *p++ = itemp->text[label_len] & 0177;
- } else {
- /* centered */
- int i, j;
- for (i = 0; i < (width - label_len)/2; i++)
- *p++ = ' ';
- for (j = 0; itemp->text[j] != '\0'; j++)
- *p++ = itemp->text[j];
- for (i += j; i < width; i++)
- *p++ = ' ';
- }
- *p = '\0';
-
- PutMenuChar('|', col, row, bitmap, bit);
- if (flag & P_ON)
- (void) ScSetStandout();
- else
- (void) ScClrStandout();
-
- /* Optimized printing of entry. */
- if (bitmap == ~0) {
- (void) fputs(buf, stdout);
- col += p-buf;
- bit <<= p-buf;
- } else {
- int i;
- for (i = 0; i < p-buf; i++)
- writemask |= 1<<(i+1);
- for (i = 0; i < p-buf; i++) {
- if ((bitmap & writemask) == writemask)
- break;
- writemask &= ~bit;
- PutMenuChar(buf[i], col, row, bitmap, bit);
- }
- if (i < p-buf) {
- (void) ScMvCursor(col, row);
- (void) fputs(&buf[i], stdout);
- col += (p-buf) - i;
- bit <<= (p-buf) - i;
- }
- }
-
- if (flag & P_ON)
- (void) ScClrStandout();
- PutMenuChar('|', col, row, bitmap, bit);
- return;
-}
-
-
-/*
- void HmPutBorder(HmWindow *win, row, char mark)
-
- Draw the horizontal border for row of win->menup using mark
- for the corner characters.
-*/
-static void
-HmPutBorder(HmWindow *win, int row, char mark)
-{
- int i;
- int col = win->menux;
- int bitmap = win->dirty[row - win->menuy];
- static char buf[HmMAXLINE];
- char *p = buf;
- if (bitmap == 0)
- return; /* No dirty bits. */
- *p++ = mark;
- for (i = 0; i < win->width; i++)
- *p++ = '-';
- *p++ = mark;
- *p = '\0';
- if (bitmap == ~0) {
- /* All bits dirty. */
- (void) ScMvCursor(col, row);
- (void) fputs(buf, stdout);
- } else {
- int bit = 1;
-
- for (i = 0; i < p - buf; i++)
- PutMenuChar(buf[i], col, row, bitmap, bit);
- }
- return;
-}
-
-
-/*
- void HmSetbit(HmWindow *win, int col, int row)
-
- Mark as dirty, the bit in win->dirty that corresponds to
- col and row of the screen.
-*/
-static void
-HmSetbit(HmWindow *win, int col, int row)
-{
- int bit = col - win->menux;
-#if HmDEBUG && 0
- (void) ErLog("HmSetbit:menu{<%d, %d>, <%d, %d>}col=%d, row=%d\n",
- win->menux, win->menux+win->width+1,
- win->menuy, win->menuy+HmHEIGHT+1,
- col, row
- );
-#endif
- win->dirty[row-win->menuy] |= bit == 0 ? 1 : 1 << bit;
-#if HmDEBUG && 0
- (void) ErLog("\tdirty[%d]=0x%x\r\n",
- row-win->menuy, win->dirty[row-win->menuy]
- );
-#endif
- return;
-}
-
-
-/*
- void HmClrmap(HmWindow *win)
-
- Mark as clean, the entire dirty bitmap for win.
-*/
-static void
-HmClrmap(HmWindow *win)
-{
- int row;
- int height = HmHEIGHT;
- for (row = 0; row <= height+1; row++)
- win->dirty[row] = 0;
- return;
-}
-
-
-/*
- void HmSetmap(HmWindow *win)
-
- Mark as dirty the entire dirty bitmap for win.
-*/
-static void
-HmSetmap(HmWindow *win)
-{
- int row;
- int height = HmHEIGHT;
- for (row = 0; row <= height+1; row++)
- win->dirty[row] = ~0; /* 0xffff... */
- return;
-}
-
-
-/*
- HmWindow *HmInWin(x, y, HmWindow *win)
-
- Return pointer to top window in stack, starting with win whose
- boundaries contain the screen coordinate <x, y>. If the point
- is outside of all these windows, return 0.
-*/
-static HmWindow *
-HmInWin(int x, int y, HmWindow *win)
-{
-#if HmDEBUG && 0
- if (win != (HmWindow *) NULL)
- (void) ErLog("HmInWin:x=%d y=%d win{<%d, %d>, <%d, %d>}\r\n",
- x, y,
- win->menux, win->menux+win->width+1,
- win->menuy, win->menuy+HmHEIGHT+1
- );
-#endif
- for (; win != (HmWindow *) NULL; win = win->next) {
- int height = HmHEIGHT;
- if (! (x < win->menux || x > win->menux + win->width + 1 ||
- y < win->menuy || y > win->menuy + height + 1)
- )
- return win;
- }
- return (HmWindow *) NULL;
-}
-
-
-/*
- void HmDrawWin(HmWindow *win)
-
- Draw win->menup on screen. Actually, only characters flagged as
- dirty are drawn.
-*/
-static void
-HmDrawWin(HmWindow *win)
-{
- HmItem *itemp;
- int height;
-
-#if HmDEBUG && 1
- (void) ErLog("HmDrawWin:win{<%d, %d>, <%d, %d>}\r\n",
- win->menux, win->menux+win->width+1,
- win->menuy, win->menuy+HmHEIGHT+1
- ); {
- int i;
- for (i = 0; i <= HmHEIGHT+1; i++)
- (void) ErLog("\tdirty[%d]=0x%x\r\n", i, win->dirty[i]);
- }
-#endif
- HmPutBorder(win, win->menuy, win->menup->prevtop > 0 ? '^' : '+');
- for (itemp = win->menup->item + win->menup->prevtop;
- HmENTRY-win->menup->prevtop < HmMaxVis && itemp->text != (char *) NULL;
- itemp++
- )
- HmPutItem(win, itemp,
- HmENTRY == win->menup->prevhit ? P_ON : P_OFF
- );
- height = HmHEIGHT;
- HmPutBorder(win, win->menuy+height+1, HmENTRY < win->height ? 'v' : '+');
- HmClrmap(win);
- (void) fflush(stdout);
- return;
-}
-
-
-/*
- void HmHelp(HmWindow *win, int entry)
-
- Display help message for item indexed by entry in win->menup
- on line HmYCOMMO. This message will be erased when the user
- strikes a key (or uses the mouse).
-*/
-static void
-HmHelp(HmWindow *win, int entry)
-{
- (void) ScMvCursor(HmLftMenu, HmYCOMMO);
- (void) ScClrEOL();
- (void) ScSetStandout();
- (void) printf("%s", win->menup->item[entry].help);
- (void) ScClrStandout();
- (void) fflush(stdout);
- return;
-}
-
-
-/*
- void HmError(const char *str)
-
- Display str on line HmYCOMMO.
-*/
-void
-HmError(const char *str)
-{
- (void) ScMvCursor(HmLftMenu, HmYCOMMO);
- (void) ScClrEOL();
- (void) ScSetStandout();
- (void) fputs(str, stdout);
- (void) ScClrStandout();
- (void) fflush(stdout);
- return;
-}
-
-
-/*
- void HmLiftWin(HmWindow *win)
-
- Remove win->menup from screen, marking any occluded portions
- of other menus as dirty so that they will be redrawn by HmHit().
-*/
-static void
-HmLiftWin(HmWindow *win)
-{
- int row, col;
- int lastcol = -1, lastrow = -1;
- int endcol = win->menux + win->width + 2;
- int endrow = win->menuy +
- HmHEIGHT + HmHGTBORDER;
-#if HmDEBUG && 1
- (void) ErLog("HmLiftWin:win{<%d, %d>, <%d, %d>}\r\n",
- win->menux, win->menux+win->width+1,
- win->menuy, win->menuy+HmHEIGHT+1
- );
-#endif
- for (row = win->menuy; row < endrow; row++) {
- for (col = win->menux; col < endcol; col++) {
- HmWindow *olwin;
- if ((olwin = HmInWin(col, row, win->next))
- != (HmWindow *) NULL
- ) {
- HmSetbit(olwin, col, row);
- HmDirty = 1;
- } else {
- if (lastcol != col-1 || lastrow != row)
- (void) ScMvCursor(col, row);
- lastcol = col; lastrow = row;
- (void) putchar(' ');
- }
- }
- }
- (void) fflush(stdout);
- return;
-}
-
-
-/*
- void HmPushWin(HmWindow *win)
-
- Add window to top of "windows" stack.
-*/
-static void
-HmPushWin(HmWindow *win)
-{
- win->next = windows;
- windows = win;
- return;
-}
-
-
-/*
- void HmPopWin(HmWindow *win)
-
- Delete window from top of "windows" stack.
-*/
-static void
-HmPopWin(HmWindow *win)
-{
- windows = win->next;
- return;
-}
-
-
-/*
- void HmRefreshWin(HmWindow *win)
-
- Draw any dirty portions of all windows in stack starting at win.
-*/
-static void
-HmRefreshWin(HmWindow *win)
-{
- if (win == (HmWindow *) NULL) {
- HmDirty = 0;
- return;
- }
- HmRefreshWin(win->next);
- HmDrawWin(win);
- return;
-}
-/*
- void HmRedraw(void)
-
- Force a redraw of all active menus.
-*/
-void
-HmRedraw(void)
-{
- HmWindow *win;
- int reset = 0;
-
-#if HmDEBUG && 1
- HmPrntWindows();
-#endif
- (void) ScClrText(); /* clear entire screen */
-
- /* See if we changed the maximum items displayed parameter. */
- if (HmMaxVis != HmLastMaxVis)
- reset = 1;
- for (win = windows; win != (HmWindow *) NULL; win = win->next) {
- if (reset) {
- /* Correct window to reflect new maximum. */
- /* Reset scrolling state-info in each window. */
- if (win->menup->prevhit >= HmMaxVis)
- win->menup->prevtop = win->menup->prevhit -
- HmMaxVis + 1;
- else
- win->menup->prevtop = 0;
- /* Must reallocate "dirty" bit map to fit new size. */
- MmVFree(Min(win->height, HmLastMaxVis)+HmHGTBORDER,
- int, win->dirty);
- if ((win->dirty =
- MmVAllo(HmHEIGHT+HmHGTBORDER, int)
- ) == NULL) {
- return;
- }
- }
- HmSetmap(win); /* force all bits on in "dirty" bitmap */
- }
- HmLastMaxVis = HmMaxVis;
- HmRefreshWin(windows); /* redisplay all windows */
- HmBanner((char *) NULL, 0); /* redraw banner */
- return;
-}
-
-
-/*
- void HmTtySet(void)
-
- Set up terminal handler and MYX-menu options for menu interaction.
-*/
-void
-HmTtySet(void)
-{
-}
-
-/*
- void HmTtyReset(void)
-
- Reset terminal handler and MYX-menu options to user settings.
-*/
-void
-HmTtyReset(void)
-{
-}
-
-/*
- void HmInit(int x, int y, int maxvis)
-
- Initialize position of top-level menu. Specify maximum
- number of menu items visible at once. Place these values
- in global variables. Determine as best we can whether MYX
- is available and place int result in HmMyxflag. Return
- true for success and false for failure to open "/dev/tty".
-*/
-int
-HmInit(int UNUSED(x), int UNUSED(y), int UNUSED(maxvis))
-{
- return 0;
-}
-
-
-/*
- void HmWidHgtMenu(HmWindow *win)
-
- Determine width and height of win->menup, and store in win.
-*/
-static void
-HmWidHgtMenu(HmWindow *win)
-{
- HmItem *itemp;
-
- /* Determine width of menu, allowing for border. */
- for (itemp = win->menup->item; itemp->text != (char *) NULL; itemp++) {
- int len = 0;
- int i;
- for (i = 0; itemp->text[i] != '\0'; i++) {
- if (! (itemp->text[i] & 0200))
- len++;
- }
- win->width = Max(win->width, len);
- }
- win->height = HmENTRY;
- return;
-}
-
-
-/*
- int HmFitMenu(HmWindow *nwin, HmWindow *cwin)
-
- If nwin->menup will fit below cwin->menup on screen, store
- position in nwin, and return 1. Otherwise, return 0.
-*/
-static int
-HmFitMenu(HmWindow *nwin, HmWindow *cwin)
-{
- if (cwin == (HmWindow *) NULL)
- return 0;
- else
- if (HmFitMenu(nwin, cwin->next))
- return 1;
- else
- /* Look for space underneath this menu.
*/
- if (cwin->menux + nwin->width + 1 <= ScCO
- && cwin->menuy + cwin->height + nwin->height + HmHGTBORDER
- < HmMaxVis + HmTopMenu
- ) {
- nwin->menux = cwin->menux;
- nwin->menuy = cwin->menuy + cwin->height + HmHGTBORDER - 1;
- return 1;
- } else {
- return 0;
- }
-}
-
-
-/*
- void HmPosMenu(HmWindow *win)
-
- Find best screen position for win->menup.
-*/
-static void
-HmPosMenu(HmWindow *win)
-{
- /* Determine origin (top-left corner) of menu. */
- if (win->next != (HmWindow *) NULL) {
- win->menux = win->next->menux + win->next->width + 1;
- win->menuy = win->next->menuy;
- if (win->menux + win->width + 2 > ScCO) {
- if (! HmFitMenu(win, win->next)) {
- /* No space, so overlap top-level menu. */
- win->menux = HmLftMenu;
- win->menuy = HmTopMenu;
- }
- }
- } else {
- /* Top-level menu. */
- win->menux = HmLftMenu;
- win->menuy = HmTopMenu;
- }
- return;
-}
-
-
-/*
- void HmMyxMouse(int *x, int *y)
-
- Read and decode screen coordinates from MYX "editor ptr".
- Implicit return in x and y.
-*/
-static void
-HmMyxMouse(int *x, int *y)
-{
- int c;
-
- c = HmGetchar();
- switch (c) {
- case Ctrl('A') :
- *x = HmGetchar() - ' ' + 96;
- break;
- case Ctrl('B') :
- *x = HmGetchar() - ' ' + 192;
- break;
- default :
- *x = c - ' ';
- break;
- }
- c = HmGetchar();
- switch (c) {
- case Ctrl('A') :
- *y = HmGetchar() - ' ' + 96;
- break;
- case Ctrl('B') :
- *y = HmGetchar() - ' ' + 192;
- break;
- default :
- *y = c - ' ';
- break;
- }
- (*x)++;
- (*y)++;
- return;
-}
-
-
-/*
- HmItem *HmHit(HmMenu *menup)
-
- Present menup to the user and return a pointer to the selected
- item, or 0 if there was no selection made. For more details,
- see "Hm.h".
-*/
-HmItem *
-HmHit(HmMenu *menup)
-{
- HmItem *itemp;
- HmItem *retitemp = NULL;
- HmWindow *win;
- int done = 0;
- int dynamic = 0;
- static int HmLevel = 0;
-
-#if HmDEBUG
- ErLog("HmHit(0x%x)\n", menup);
-#endif
- if (HmPkgInit == 0) {
- HmInit(HmLftMenu, HmTopMenu, HmMaxVis);
- HmPkgInit = 1;
- }
- if (++HmLevel == 1)
- HmTtySet();
-
- /* If generator function is provided, dynamically allocate the
- menu items.
- */
- if ((dynamic = (menup->item == (HmItem *) NULL))) {
- int i;
- HmItem *gitemp;
- HmLList llhead, **listp;
- for (i = 0, listp = &llhead.next;
- ;
- i++, listp = &(*listp)->next
- ) {
- if ((*listp = MmAllo(HmLList)) == NULL
- || ((*listp)->itemp = MmAllo(HmItem)) == NULL
- ) {
- goto clean_exit;
- }
- itemp = (*listp)->itemp;
- if ((gitemp = (*menup->generator)(i)) == (HmItem *) NULL) {
- itemp->text = (char *) NULL;
- (*listp)->next = (HmLList *) NULL;
- break;
- }
- if (gitemp->text != (char *) NULL) {
- if ((itemp->text = MmStrDup(gitemp->text))
- == (char *) NULL
- ) {
- goto clean_exit;
- }
- } else
- itemp->text = (char *) NULL;
- if (gitemp->help != (char *) NULL) {
- if ((itemp->help = MmStrDup(gitemp->help))
- == (char *) NULL
- ) {
- goto clean_exit;
- }
- } else
- itemp->help = (char *) NULL;
- itemp->next = gitemp->next;
- itemp->dfn = gitemp->dfn;
- itemp->bfn = gitemp->bfn;
- itemp->hfn = gitemp->hfn;
- itemp->data = gitemp->data;
-#if HmDEBUG && 0
- HmPrntItem(itemp);
-#endif
- }
-#if HmDEBUG && 0
- HmPrntLList(llhead.next);
-#endif
- /* Steal the field that the user isn't using temporarily to
- emulate the static allocation of menu items.
- */
- if (i > 0) {
- int ii;
- HmLList *lp;
- if ((menup->item = MmVAllo(i+1, HmItem)) == NULL) {
- goto clean_exit;
- }
- for (ii = 0, lp = llhead.next;
- lp != (HmLList *) NULL;
- ii++, lp = lp->next
- )
- menup->item[ii] = *lp->itemp;
- }
- HmFreeLList(llhead.next);
- if (i == 0) /* Zero items, so return NULL */
- goto clean_exit;
- }
- if ((win = MmAllo(HmWindow)) == NULL) {
-#if HmDEBUG
- ErLog("HmHit, BUG: memory pool possibly corrupted.\n");
-#endif
- goto clean_exit;
- }
- win->menup = menup;
- win->width = 0;
- HmPushWin(win);
- HmWidHgtMenu(win);
- HmPosMenu(win);
-
- if (menup->prevhit < 0 || menup->prevhit >= win->height)
- menup->prevhit = 0;
- itemp = &menup->item[menup->prevhit];
-
- if ((win->dirty = MmVAllo(HmHEIGHT+HmHGTBORDER, int)) == NULL) {
- goto clean_exit;
- }
- if (HmDirty)
- HmRefreshWin(windows);
- HmSetmap(win);
- HmDrawWin(win);
- while (! done) {
- int c;
- if (HmDirty)
- HmRefreshWin(windows);
- (void) ScMvCursor(HmXPROMPT, HmYPROMPT);
- (void) ScClrEOL();
- (void) ScMvCursor(win->menux+win->width+2,
- win->menuy+(HmENTRY-win->menup->prevtop)+1);
- (void) fflush(stdout);
- c = HmGetchar();
- (void) ScMvCursor(HmLftMenu, HmYCOMMO);
- (void) ScClrEOL();
- switch (c) {
- case M_UP :
- case A_UP :
- if (HmENTRY == 0)
- HmRingbell();
- else {
- HmPutItem(win, itemp, P_OFF | P_FORCE);
- itemp--;
- menup->prevhit = HmENTRY;
- if (HmENTRY < win->menup->prevtop) {
- win->menup->prevtop -=
- HmENTRY > HmMaxVis/2 ?
- HmMaxVis/2+1 : HmENTRY+1;
- HmSetmap(win);
- HmDrawWin(win);
- } else
- HmPutItem(win, itemp, P_ON | P_FORCE);
- }
- break;
- case M_DOWN :
- case A_DOWN :
- if (HmENTRY >= win->height-1)
- HmRingbell();
- else {
- HmPutItem(win, itemp, P_OFF | P_FORCE);
- itemp++;
- menup->prevhit = HmENTRY;
- if (HmENTRY - win->menup->prevtop >= HmMaxVis) {
- win->menup->prevtop +=
- win->height-HmENTRY > HmMaxVis/2 ?
- HmMaxVis/2 : win->height-HmENTRY;
- HmSetmap(win);
- HmDrawWin(win);
- } else
- HmPutItem(win, itemp, P_ON | P_FORCE);
- }
- break;
- case M_MYXMOUSE : {
- static int mousex, mousey;
- HmItem *lastitemp;
- if (HmGetchar() != Ctrl('_') || HmGetchar() != '1')
- goto m_badinput;
- HmMyxMouse(&mousex, &mousey);
- if (HmInWin(mousex, mousey, win) != win) {
- /* Mouse cursor outside of menu. */
- HmRingbell();
- break;
- }
- if (mousey == win->menuy && win->menup->prevtop == 0) {
- /* Top border of menu and can't scroll. */
- goto m_noselect;
- }
- if (mousey == win->menuy + HmHEIGHT + 1
- && win->height <= HmMaxVis + win->menup->prevtop
- ) {
- /* Bottom border of menu and can't scroll. */
- HmRingbell();
- break;
- }
- lastitemp = itemp;
- itemp = win->menup->item +
- win->menup->prevtop +
- (mousey - (win->menuy + 1));
- if (itemp == lastitemp)
- /* User hit item twice in a row, so select it. */
- goto m_select;
- HmPutItem(win, lastitemp, P_OFF | P_FORCE);
- menup->prevhit = HmENTRY;
- if (HmENTRY - win->menup->prevtop >= HmMaxVis) {
- win->menup->prevtop +=
- win->height-HmENTRY > HmMaxVis/2 ?
- HmMaxVis/2 : win->height-HmENTRY;
- HmSetmap(win);
- HmDrawWin(win);
- } else
- if (HmENTRY < win->menup->prevtop) {
- win->menup->prevtop -=
- HmENTRY > HmMaxVis/2 ?
- HmMaxVis/2+1 : HmENTRY+1;
- HmSetmap(win);
- HmDrawWin(win);
- } else {
- HmPutItem(win, itemp, P_ON | P_FORCE);
- }
- break;
- }
- case M_HELP :
- case A_HELP :
- HmHelp(win, HmENTRY);
- break;
- m_select :
- case M_SELECT :
- if (itemp->next != (HmMenu *) NULL) {
- HmItem *subitemp;
- if (itemp->dfn != (void (*)()) NULL) {
- int level = HmLevel;
- HmTtyReset();
- HmLevel = 0;
- (*itemp->dfn)(itemp);
- HmLevel = level;
- HmTtySet();
- }
- subitemp = HmHit(itemp->next);
- if (itemp->bfn != (void (*)()) NULL) {
- int level = HmLevel;
- HmTtyReset();
- HmLevel = 0;
- (*itemp->bfn)(itemp);
- HmLevel = level;
- HmTtySet();
- }
- if (subitemp != (HmItem *) NULL) {
- retitemp = subitemp;
- done = ! menup->sticky;
- }
- } else {
- retitemp = itemp;
- if (itemp->hfn != (void (*)()) NULL) {
- int level = HmLevel;
- HmTtyReset();
- HmLevel = 0;
- (*itemp->hfn)(itemp);
- HmLevel = level;
- HmTtySet();
- }
- done = ! menup->sticky;
- }
- break;
- m_noselect :
- case M_NOSELECT :
- done = 1;
- break;
- case M_REDRAW :
- HmRedraw();
- break;
- case M_DEBUG :
- HmPrntWindows();
- break;
- m_badinput :
- default :
- HmError("Type 'd' down, 'u' up, 'h' help, <space> to
select, 'q' no selection.");
- break;
- }
- (void) fflush(stdout);
- }
- /* Free storage of dynamic menu. */
- if (dynamic) {
- if (retitemp != (HmItem *) NULL) {
- /* Must make copy of item we are returning. */
- static HmItem dynitem;
- dynitem = *retitemp;
- retitemp = &dynitem;
- }
- HmFreeItems(menup->item);
- menup->item = 0;
- }
-
- HmLiftWin(win);
- HmPopWin(win);
- MmVFree(HmHEIGHT+HmHGTBORDER, int, win->dirty);
- MmFree(HmWindow, win);
- clean_exit :
- if (HmLevel-- == 1)
- HmTtyReset();
- return retitemp;
-}
-
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
Deleted: brlcad/trunk/src/burst/HmGetc.c
===================================================================
--- brlcad/trunk/src/burst/HmGetc.c 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/src/burst/HmGetc.c 2020-06-18 17:10:24 UTC (rev 76154)
@@ -1,59 +0,0 @@
-/* H M G E T C . C
- * BRL-CAD
- *
- * Copyright (c) 2004-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- *
- */
-/** @file burst/HmGetc.c
- *
- */
-
-#include "common.h"
-
-#include <stdio.h>
-#include <signal.h>
-
-#include "./burst.h"
-
-int
-HmGetchar(void)
-{
- int c;
-
- while ((c = getc(HmTtyFp)) == EOF)
- ;
-
- return c;
-}
-
-
-int
-HmUngetchar(int c)
-{
- return ungetc(c, HmTtyFp);
-}
-
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
Deleted: brlcad/trunk/src/burst/HmGlob.c
===================================================================
--- brlcad/trunk/src/burst/HmGlob.c 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/src/burst/HmGlob.c 2020-06-18 17:10:24 UTC (rev 76154)
@@ -1,44 +0,0 @@
-/* H M G L O B . C
- * BRL-CAD
- *
- * Copyright (c) 2004-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- *
- */
-/** @file burst/HmGlob.c
- *
- */
-
-#include "common.h"
-
-#include <stdio.h>
-
-FILE *HmTtyFp = NULL; /* read keyboard, not stdin */
-int HmLftMenu = 1; /* default top-level menu position */
-int HmTopMenu = 1;
-int HmMaxVis = 10; /* default maximum menu items displayed */
-int HmLastMaxVis = 10; /* track changes in above parameter */
-int HmTtyFd; /* read keyboard, not stdin */
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
Deleted: brlcad/trunk/src/burst/Mm.h
===================================================================
--- brlcad/trunk/src/burst/Mm.h 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/src/burst/Mm.h 2020-06-18 17:10:24 UTC (rev 76154)
@@ -1,55 +0,0 @@
-/* M M . H
- * BRL-CAD
- *
- * Copyright (c) 2004-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- *
- */
-/** @file burst/Mm.h
- *
- */
-
-#ifndef BURST_MM_H
-#define BURST_MM_H
-
-/* Emulate MUVES Mm package using malloc. */
-
-#include "common.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "bu/malloc.h"
-#include "bu/str.h"
-
-#define MmAllo(typ) (typ *) bu_malloc(sizeof(typ), CPP_FILELINE)
-#define MmFree(typ, ptr) bu_free((char *) ptr, CPP_FILELINE)
-#define MmVAllo(ct, typ) (typ *) bu_malloc((ct)*sizeof(typ),
CPP_FILELINE)
-#define MmVFree(ct, typ, ptr) bu_free((char *) ptr, CPP_FILELINE)
-#define MmStrDup(str) bu_strdup(str)
-#define MmStrFree(str) bu_free(str, CPP_FILELINE)
-
-#endif /* BURST_MM_H */
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
Deleted: brlcad/trunk/src/burst/Sc.c
===================================================================
--- brlcad/trunk/src/burst/Sc.c 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/src/burst/Sc.c 2020-06-18 17:10:24 UTC (rev 76154)
@@ -1,260 +0,0 @@
-/* S C . C
- * BRL-CAD
- *
- * Copyright (c) 2004-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- *
- */
-/** @file burst/Sc.c
- *
- */
-
-#include "common.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_SYS__IOCTL_H
-# include <sys/_ioctl.h>
-#else
-# ifdef HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-# define _winsize winsize /* For compatibility with _ioctl.h. */
-# endif
-#endif
-
-#include "bu/str.h"
-
-#include "./Sc.h"
-
-
-static FILE *out_fp; /* Output stream. */
-static int fd_stdout = 1;
-
-/* This is a global buffer for the terminal capabilities entry. */
-char ScTermcap[ScTCAPSIZ];
-
-/* This is a global buffer for the name of the terminal. */
-char ScTermname[ScTERMSIZ] = "UNKNOWN";
-
-/* Individual terminal control strings (TCS). */
-char *ScBC, /* Backspace character. */
- *ScPC, /* Padding character. */
- *ScUP, /* Cursor up one line. */
- *ScCS, /* Change scrolling region. */
- *ScSO, /* Begin standout mode. */
- *ScSE, /* End standout mode. */
- *ScCE, /* Clear to end of line. */
- *ScCL, /* Clear display and home cursor. */
- *ScHO, /* Home cursor. */
- *ScCM, /* Screen-relative cursor motion. */
- *ScTI, /* Initialize terminal. */
- *ScAL, /* Insert line. */
- *ScDL, /* Delete line. */
- *ScSR, /* Scroll text down. */
- *ScSF; /* Scroll text up. */
-
-/* Individual terminal parameters. */
-int ScLI, /* Number of lines on screen. */
- ScCO; /* Number of columns on screen. */
-
-
-/*
- This function prevents the default "PutChr" from being pulled in
- from the termcap library (-ltermlib). DO NOT change its name or
- STDOUT will be assumed as the output stream for terminal control.
- Some applications might want to open "/dev/tty" so that they can
- use STDOUT for something else.
-*/
-int
-PutChr(int c) {
- return putc((char)c, out_fp);
-}
-
-
-/*
- ScInit() must be invoked before any other function in the Sc package.
- Stream fp must be open for writing and all terminal control sequences
- will be sent to fp, giving the application the option of using STDOUT
- for other things. Besides setting the output stream, ScInit() does
- the following:
-
- Initializes the terminal. Fills terminal name and capabilities
- into external buffers. Gets terminal control strings into external
- variables. Gets individual terminal parameters into external
- variables. Returns "1" for success, "0" for failure and
- prints appropriate diagnostics on STDERR if $TERM is not set or
- there is a problem in retrieving the corresponding termcap entry.
-*/
-int
-ScInit(FILE *fp) {
- char *term; /* Name of terminal from environment. */
- out_fp = fp;
- fd_stdout = fileno(out_fp);
- if ((term = getenv("TERM")) == NULL) {
- (void) fprintf(stderr, "TERM not set or exported!\n");
- return 0;
- }
- bu_strlcpy(ScTermname, term, ScTERMSIZ);
-
- return 1; /* All is well. */
-}
-
-
-/*
- Clear from the cursor to the end of that line.
-*/
-int
-ScClrEOL(void) {
- if (ScCE == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- Reset the scrolling region to the entire screen.
-*/
-int
-ScClrScrlReg(void) {
- if (ScCS == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- End standout mode.
-*/
-int
-ScClrStandout(void) {
- if (ScSE == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- Clear the screen and "home" the cursor.
-*/
-int
-ScClrText(void) {
- if (ScCL == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- Insert a the line under the cursor.
-*/
-int
-ScInsertLn(void) {
- if (ScAL == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- Delete the line under the cursor.
-*/
-int
-ScDeleteLn(void) {
- if (ScDL == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- Scroll backward 1 line.
-*/
-int
-ScDnScroll(void) {
- if (ScSR == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- Move the cursor to the top-left corner of the screen.
-*/
-int
-ScHmCursor(void) {
- if (ScHO == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- Move the cursor to screen coordinates x, y (for column and row,
- respectively).
-*/
-int
-ScMvCursor(int UNUSED(x), int UNUSED(y)) {
- if (ScCM == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- Set the scrolling region to be from "top" line to "btm" line,
- inclusive.
-*/
-int
-ScSetScrlReg(int UNUSED(top), int UNUSED(btm)) {
- if (ScCS == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- Begin standout mode.
-*/
-int
-ScSetStandout(void) {
- if (ScSO == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- Scroll text forward 1 line.
-*/
-int
-ScUpScroll(void) {
- if (ScSF == NULL)
- return 0;
- return 1;
-}
-
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
Deleted: brlcad/trunk/src/burst/Sc.h
===================================================================
--- brlcad/trunk/src/burst/Sc.h 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/src/burst/Sc.h 2020-06-18 17:10:24 UTC (rev 76154)
@@ -1,167 +0,0 @@
-/* S C . H
- * BRL-CAD
- *
- * Copyright (c) 2004-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- *
- */
-/** @file burst/Sc.h
- *
- */
-
-/**
- <Sc.h> -- MUVES "Sc" (Screen manager) package definitions
-**/
-
-#ifndef BURST_SC_H
-#define BURST_SC_H
-#include "./burst.h"
-
-/**
- int ScInit(FILE *fp)
-
- ScInit() must be invoked before any other function in the Sc
- package. Stream fp must be open for writing and all terminal
- control sequences will be sent to fp, giving the application
- the option of using STDOUT for other things. Besides setting
- the output stream, ScInit() does the following:
-
- Initializes the terminal.
-
- Fills terminal name and capabilities into these externals:
-
- char ScTermname[ScTERMSIZ] (terminal name from $TERM)
- char ScTermcap[ScTCAPSIZ] (terminal capabilities entry)
-
- Gets terminal control strings into external variables (here
- are some that don't have individual functions to output them,
- the ones that DO are below):
-
- char *ScBC (backspace character)
- char *ScPC (padding character)
- char *ScUP (move the cursor up one line)
- char *ScTI (initialize the terminal)
-
- Gets individual terminal parameters into these externals:
-
- int ScLI (number of lines on screen)
- int ScCO (number of columns on screen)
-
- Returns "1" for success, "0" for failure and prints
- appropriate diagnostics on STDERR if $TERM is not set or
- there is a problem in retrieving the corresponding termcap
- entry.
-**/
- extern int ScInit(FILE *fp);
-
-/**
-
-Below are functions paired with terminal control strings that
-they output to the stream specified with ScInit(). It is not
-recommended that the control strings be used directly, but it
-may be useful in certain applications to check their value;
-if ScInit() has not been invoked or the corresponding terminal
-capability does not exist, its control string will be NULL,
-AND the function will return "false". Otherwise, they will
-return "true" (assuming that it worked). There is no way to
-be sure of this.
-
-char *ScCE (clear from under the cursor to end of line)
-int ScClrEOL(void)
-
-char *ScCS (change scrolling region)
-int ScClrScrlReg(void)
-
-char *ScSE (end standout mode)
-int ScClrStandout(void)
-
-char *ScCL (clear screen, and home cursor)
-int ScClrText(void)
-
-char *ScAL (insert a line under the cursor)
-int ScInsertLn(void)
-
-char *ScDL (delete the line under the cursor)
-int ScDeleteLn(void)
-
-char *ScSR (scroll text backwards 1 line)
-int ScDnScroll(void)
-
-char *ScHO (move cursor to top-left corner of screen)
-int ScHmCursor(void)
-
-char *ScCM (move cursor to column and row <x, y>)
-int ScMvCursor(x, y)
-
-char *ScCS (set scrolling region from top to btm incl.)
-int ScSetScrlReg(top, btm)
-
-char *ScSO (begin standout mode)
-int ScSetStandout(void)
-
-char *ScSF (scroll text forwards 1 line)
-int ScUpScroll(void)
-
-**/
-extern char *ScBC;
-extern char *ScPC;
-extern char *ScUP;
-extern char *ScCS;
-extern char *ScSO;
-extern char *ScSE;
-extern char *ScCE;
-extern char *ScCL;
-extern char *ScHO;
-extern char *ScCM;
-extern char *ScTI;
-extern char *ScDL;
-extern char *ScSR;
-extern char *ScSF;
-
-extern int ScLI;
-extern int ScCO;
-
-extern int ScClrEOL(void);
-extern int ScClrScrlReg(void);
-extern int ScClrStandout(void);
-extern int ScClrText(void);
-extern int ScDeleteLn(void);
-extern int ScDnScroll(void);
-extern int ScHmCursor(void);
-extern int ScInsertLn(void);
-extern int ScMvCursor(int x, int y);
-extern int ScSetScrlReg(int top, int btm);
-extern int ScSetStandout(void);
-extern int ScUpScroll(void);
-
-#define ScTCAPSIZ 1024
-#define ScTERMSIZ 80
-
-extern char ScTermcap[];
-extern char ScTermname[];
-
-#endif /* BURST_SC_H */
-
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
Deleted: brlcad/trunk/src/burst/ascii.h
===================================================================
--- brlcad/trunk/src/burst/ascii.h 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/src/burst/ascii.h 2020-06-18 17:10:24 UTC (rev 76154)
@@ -1,66 +0,0 @@
-/* A S C I I . H
- * BRL-CAD
- *
- * Copyright (c) 2004-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- *
- */
-/** @file burst/ascii.h
- *
- */
-
-#ifndef BURST_ASCII_H
-#define BURST_ASCII_H
-
-#define NUL '\000'
-#define SOH '\001'
-#define STX '\002'
-#define INTR '\003'
-#define EOT '\004'
-#define ACK '\006'
-#define BEL '\007'
-#define BS '\010'
-#define HT '\011'
-#define LF '\012'
-#define FF '\014'
-#define CRET '\015'
-#define DLE '\020'
-#define DC1 '\021'
-#define DC2 '\022'
-#define DC3 '\023'
-#define DC4 '\024'
-#define KILL '\025'
-#define CAN '\030'
-#define ESC '\033'
-#define GS '\035'
-#define RS '\036'
-#define US '\037'
-#define SP '\040'
-#define DEL '\177'
-
-#define Ctrl(chr) ((int)chr&037)
-
-#endif /* BURST_ASCII_H */
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
Deleted: brlcad/trunk/src/burst/burst.c
===================================================================
--- brlcad/trunk/src/burst/burst.c 2020-06-18 15:37:23 UTC (rev 76153)
+++ brlcad/trunk/src/burst/burst.c 2020-06-18 17:10:24 UTC (rev 76154)
@@ -1,391 +0,0 @@
-/* B U R S T . C
- * BRL-CAD
- *
- * Copyright (c) 2004-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- *
- */
-/** @file burst/burst.c
- *
- */
-
-#include "common.h"
-
-#include <assert.h>
-#include <stdio.h>
-#include <signal.h>
-
-#include "bu/app.h"
-#include "bu/getopt.h"
-#include "bu/file.h"
-#include "bu/opt.h"
-#include "bu/str.h"
-#include "bu/exit.h"
-#include "bu/log.h"
-#include "bu/vls.h"
-
-#include "./burst.h"
-#include "./extern.h"
-#include "./ascii.h"
-
-
-#define DEBUG_BURST 0 /* 1 enables debugging for this module */
-
-/*
- int getCommand(char *name, char *buf, int len, FILE *fp)
-
- Read next command line into buf and stuff the command name into name
- from input stream fp. buf must be at least len bytes long.
-
- RETURN: 1 for success
-
- 0 for end of file
-*/
-static int
-getCommand(char *name, char *buf, int len, FILE *fp)
-{
- assert(name != NULL);
- assert(buf != NULL);
- assert(fp != NULL);
- while (bu_fgets(buf, len, fp) != NULL) {
- if (buf[0] != CHAR_COMMENT) {
- if (sscanf(buf, "%1330s", name) == 1) {
- /* LNBUFSZ */
- buf[strlen(buf)-1] = NUL; /* clobber newline */
- return 1;
- } else /* Skip over blank lines. */
- continue;
- } else {
- /* Generate comment command. */
- bu_strlcpy(name, CMD_COMMENT, LNBUFSZ);
- return 1;
- }
- }
- return 0; /* EOF */
-}
-
-
-/*
- void setupSigs(void)
-
- Initialize all signal handlers.
-*/
-
-static void
-setupSigs(void)
-{
- int i;
- for (i = 0; i < NSIG; i++)
- switch (i) {
- case SIGINT :
- if ((norml_sig = signal(i, SIG_IGN)) == SIG_IGN)
- abort_sig = SIG_IGN;
- else {
- norml_sig = intr_sig;
- abort_sig = abort_RT;
- (void) signal(i, norml_sig);
- }
- break;
-#ifdef SIGPIPE
- case SIGPIPE :
- (void) signal(i, SIG_IGN);
- break;
-#endif
- default:
- break;
- }
- return;
-}
-
-/*
- void readBatchInput(FILE *fp)
-
- Read and execute commands from input stream fp.
-*/
-void
-readBatchInput(FILE *fp)
-{
- assert(fp != (FILE *) NULL);
- batchmode = 1;
- while (getCommand(cmdname, cmdbuf, LNBUFSZ, fp)) {
- Func *cmdfunc;
- if ((cmdfunc = getTrie(cmdname, cmdtrie)) == NULL) {
- int i, len = strlen(cmdname);
- brst_log("ERROR -- command syntax:\n");
- brst_log("\t%s\n", cmdbuf);
- brst_log("\t");
- for (i = 0; i < len; i++)
- brst_log(" ");
- brst_log("^\n");
- } else
- if (BU_STR_EQUAL(cmdname, CMD_COMMENT)) {
- /* special handling for comments */
- cmdptr = cmdbuf;
- cmdbuf[strlen(cmdbuf)-1] = '\0'; /* clobber newline */
- (*cmdfunc)((HmItem *) 0);
- } else {
- /* Advance pointer past nul at end of
- command name. */
- cmdptr = cmdbuf + strlen(cmdname) + 1;
- (*cmdfunc)((HmItem *) 0);
- }
- }
- batchmode = 0;
- return;
-}
-
-static const char usage[] =
- "Usage: burst [-p|-P] [file]\n"
- "\tThe -p/-P options specifies whether to plot points or lines."
-;
-
-/*
- int main(int argc, char *argv[])
-*/
-int
-main(int argc, const char *argv[])
-{
- struct burst_state s;
- const char *bfile = NULL;
- int burst_opt; /* unused, for option compatibility */
- int plot_lines = 0;
- int plot_points = 0;
- int ret_ac;
-
- bu_setprogname(argv[0]);
-
- struct bu_opt_desc d[4];
- struct bu_vls pmsg = BU_VLS_INIT_ZERO;
-
- BU_OPT(d[0], "p", "", "", NULL, &plot_points, "Plot points");
- BU_OPT(d[1], "P", "", "", NULL, &plot_lines, "Plot lines");
- BU_OPT(d[2], "b", "", "", NULL, &burst_opt, "Batch mode");
- BU_OPT_NULL(d[3]);
-
- burst_state_init(&s);
-
-
- /* Interactive mode is gone - until we strip all the leftovers out
- * of the code, let it know we're not in tty mode */
- tty = 0;
-
- bu_setlinebuf(stderr);
-
- /* Skip first arg */
- argv++; argc--;
-
- /* no options imply a request for usage */
- if (argc < 1 || !argv || argv[0] == NULL) {
- (void)fprintf(stderr, "%s\n", usage);
- return EXIT_SUCCESS;
- }
-
- /* Process options */
- ret_ac = bu_opt_parse(&pmsg, argc, argv, d);
- if (ret_ac < 0) {
- (void)fprintf(stderr, "%s\n", bu_vls_cstr(&pmsg));
- bu_vls_free(&pmsg);
- (void)fprintf(stderr, "%s\n", usage);
- return EXIT_FAILURE;
- }
- bu_vls_free(&pmsg);
-
- if (ret_ac) {
- if (!bu_file_exists(argv[0], NULL)) {
- (void)fprintf(stderr, "ERROR: Input file [%s] does not exist!\n",
argv[0]);
- (void)fprintf(stderr, "%s\n", usage);
- return EXIT_FAILURE;
- } else {
- bfile = argv[0];
- }
- }
-
- tmpfp = bu_temp_file(tmpfname, TIMER_LEN);
- if (!tmpfp) {
- bu_exit(EXIT_FAILURE, "ERROR: Unable to create temporary file.\n");
- }
-
- setupSigs();
-
- /* must be called before any output is produced */
- if (!initUi()) {
- fclose(tmpfp);
- return EXIT_FAILURE;
- }
-
-#if DEBUG_BURST
- prntTrie(cmdtrie, 0);
-#endif
- assert(airids.i_next == NULL);
- assert(armorids.i_next == NULL);
- assert(critids.i_next == NULL);
-
- if (bfile) {
- FILE *fp = fopen(bfile, "rb");
- readBatchInput(fp);
- fclose(fp);
- } else {
- readBatchInput(stdin);
- }
-
- fclose(tmpfp);
- return EXIT_SUCCESS;
-}
-
-
-/*
- void exitCleanly(int code)
-
- Should be only exit from program after success of initUi().
-*/
-void
-exitCleanly(int code)
-{
- if (tty)
- closeUi(); /* keep screen straight */
- (void) fclose(tmpfp);
- if (!bu_file_delete(tmpfname))
- locPerror(tmpfname);
- exit(code);
-}
-
-void
-burst_state_init(struct burst_state *s)
-{
- //Colors colorids;
- s->fbiop = NULL;
- s->burstfp = NULL;
- s->gridfp = NULL;
- s->histfp = NULL;
- s->outfp = NULL;
- s->plotfp = NULL;
- s->shotfp = NULL;
- s->shotlnfp = NULL;
- s->tmpfp = NULL;
- s->mainhmenu = NULL;
- //Ids airids;
- //Ids armorids;
- //Ids critids;
- s->pixgrid = NULL;
- VSET(s->pixaxis, 255, 0, 0);
- VSET(s->pixbhit, 200, 255, 200);
- VSET(s->pixbkgr, 150, 100, 255);
- VSET(s->pixblack, 0, 0, 0);
- VSET(s->pixcrit, 255, 200, 200);
- VSET(s->pixghit, 255, 0, 255);
- VSET(s->pixmiss, 200, 200, 200);
- VSET(s->pixtarg, 255, 255, 255);
- s->cmdtrie = NULL;
- s->plotline = 0;
- s->batchmode = 0;
- s->cantwarhead = 0;
- s->deflectcone = DFL_DEFLECT;
- s->dithercells = DFL_DITHER;
- s->fatalerror = 0;
- s->groundburst = 0;
- s->reportoverlaps = DFL_OVERLAPS;
- s->reqburstair = 1;
- s->shotburst = 0;
- s->tty = 1;
- s->userinterrupt = 0;
- memset(s->airfile, 0, LNBUFSZ);
- memset(s->armorfile, 0, LNBUFSZ);
- memset(s->burstfile, 0, LNBUFSZ);
- memset(s->cmdbuf, 0, LNBUFSZ);
- memset(s->cmdname, 0, LNBUFSZ);
- memset(s->colorfile, 0, LNBUFSZ);
- memset(s->critfile, 0, LNBUFSZ);
- memset(s->errfile, 0, LNBUFSZ);
- memset(s->fbfile, 0, LNBUFSZ);
- memset(s->gedfile, 0, LNBUFSZ);
- memset(s->gridfile, 0, LNBUFSZ);
- memset(s->histfile, 0, LNBUFSZ);
- memset(s->objects, 0, LNBUFSZ);
- memset(s->outfile, 0, LNBUFSZ);
- memset(s->plotfile, 0, LNBUFSZ);
- memset(s->scrbuf, 0, LNBUFSZ);
- memset(s->scriptfile, 0, LNBUFSZ);
- memset(s->shotfile, 0, LNBUFSZ);
- memset(s->shotlnfile, 0, LNBUFSZ);
- memset(s->title, 0, TITLE_LEN);
- memset(s->timer, 0, TIMER_LEN);
- memset(s->tmpfname, 0, TIMER_LEN);
- s->cmdptr = NULL;
- s->bdist = DFL_BDIST;
- VSET(s->burstpoint, 0.0, 0.0, 0.0);
- s->cellsz = DFL_CELLSIZE;
- s->conehfangle = DFL_CONEANGLE;
- VSET(s->fire, 0.0, 0.0, 0.0);
- s->griddn = 0.0;
- s->gridlf = 0.0;
- s->gridrt = 0.0;
- s->gridup = 0.0;
- VSET(s->gridhor, 0.0, 0.0, 0.0);
- VSET(s->gridsoff, 0.0, 0.0, 0.0);
- VSET(s->gridver, 0.0, 0.0, 0.0);
- s->grndbk = 0.0;
- s->grndht = 0.0;
- s->grndfr = 0.0;
- s->grndlf = 0.0;
- s->grndrt = 0.0;
- VSET(s->modlcntr, 0.0, 0.0, 0.0);
- s->modldn = 0.0;
- s->modllf = 0.0;
- s->modlrt = 0.0;
- s->modlup = 0.0;
- s->raysolidangle = 0.0;
- s->standoff = 0.0;
- s->unitconv = 1.0;
- s->viewazim = DFL_AZIMUTH;
- s->viewelev = DFL_ELEVATION;
- s->pitch = 0.0;
- s->yaw = 0.0;
- VSET(s->xaxis, 1.0, 0.0, 0.0);
- VSET(s->zaxis, 0.0, 0.0, 1.0);
- VSET(s->negzaxis, 0.0, 0.0, -1.0);
- co = 0;
- devwid = 0;
- devhgt = 0;
- firemode = FM_DFLT;
- gridsz = 512;
- gridxfin = 0;
- gridyfin = 0;
- gridxorg = 0;
- gridyorg = 0;
- gridwidth = 0;
- gridheight = 0;
- li = 0;
- nbarriers = DFL_BARRIERS;
- noverlaps = 0;
- nprocessors = 0;
- nriplevels = DFL_RIPLEVELS;
- s->nspallrays = DFL_NRAYS;
- s->units = DFL_UNITS;
- s->zoom = 1;
- s->rtip = RTI_NULL;
- s->norml_sig = NULL; /* active during interactive operation */
- s->abort_sig = NULL; /* active during ray tracing only */
-}
-
-/*
- * Local Variables:
- * mode: C
- * tab-width: 8
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
Copied: brlcad/trunk/src/burst/burst.cpp (from rev 76153,
brlcad/branches/bioh/src/burst/burst.cpp)
===================================================================
--- brlcad/trunk/src/burst/burst.cpp (rev 0)
+++ brlcad/trunk/src/burst/burst.cpp 2020-06-18 17:10:24 UTC (rev 76154)
@@ -0,0 +1,1891 @@
+/* B U R S T . C P P
+ * BRL-CAD
+ *
+ * Copyright (c) 2004-2020 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file burst/burst.cpp
+ *
+ */
+
+#include "common.h"
+
+#include <cstdio>
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <string>
+
+#include <stdlib.h>
+#include <string.h>
+
+extern "C" {
+#include "linenoise.h"
+}
+
+#include "bu/app.h"
+#include "bu/cmd.h"
+#include "bu/getopt.h"
+#include "bu/file.h"
+#include "bu/opt.h"
+#include "bu/str.h"
+#include "bu/exit.h"
+#include "bu/log.h"
+#include "bu/units.h"
+#include "bu/vls.h"
+
+#include "fb.h"
+#include "raytrace.h"
+
+#include "./burst.h"
+
+#define DEFAULT_BURST_PROMPT "burst> "
+
+/* logging function that takes care of writing output to errfile if it is
defined */
+void
+brst_log(struct burst_state *s, int TYPE, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ if (s->errfile) {
+ vfprintf(s->errfile, fmt, ap);
+ }
+ if (TYPE == MSG_OUT) {
+ vfprintf(stderr, fmt, ap);
+ }
+}
+
+/* Forward declare so we can use this function in a command
+ * called by this function */
+int burst_process_line(struct burst_state *s, const char *line);
+
+#define PURPOSEFLAG "--print-purpose"
+#define HELPFLAG "--print-help"
+static int
+_burst_cmd_msgs(void *UNUSED(bs), int argc, const char **argv, const char *us,
const char *ps)
+{
+ //struct burst_state *s = (struct burst_state *)bs;
+ if (argc == 2 && BU_STR_EQUAL(argv[1], HELPFLAG)) {
+ printf("Usage: %s\n%s\n", us, ps);
+ return 1;
+ }
+ if (argc == 2 && BU_STR_EQUAL(argv[1], PURPOSEFLAG)) {
+ printf("%s\n", ps);
+ return 1;
+ }
+ return 0;
+}
+
+
+void
+burst_state_init(struct burst_state *s)
+{
+ s->quit = 0;
+
+ BU_PTBL_INIT(&s->colorids);
+ s->fbiop = NULL;
+ s->burstfp = NULL;
+ s->gridfp = NULL;
+ s->histfp = NULL;
+ s->outfp = NULL;
+ s->plotfp = NULL;
+ s->shotfp = NULL;
+ s->shotlnfp = NULL;
+ BU_PTBL_INIT(&s->airids);
+ BU_PTBL_INIT(&s->armorids);
+ BU_PTBL_INIT(&s->critids);
+ s->pixgrid = NULL;
+ VSET(s->pixaxis, 255, 0, 0);
+ VSET(s->pixbhit, 200, 255, 200);
+ VSET(s->pixbkgr, 150, 100, 255);
+ VSET(s->pixblack, 0, 0, 0);
+ VSET(s->pixcrit, 255, 200, 200);
+ VSET(s->pixghit, 255, 0, 255);
+ VSET(s->pixmiss, 200, 200, 200);
+ VSET(s->pixtarg, 255, 255, 255);
+ s->plotline = 0;
+ s->batchmode = 0;
+ s->cantwarhead = 0;
+ s->deflectcone = DFL_DEFLECT;
+ s->dithercells = DFL_DITHER;
+ s->fatalerror = 0;
+ s->groundburst = 0;
+ s->reportoverlaps = DFL_OVERLAPS;
+ s->reqburstair = 1;
+ s->shotburst = 0;
+ s->userinterrupt = 0;
+ bu_vls_init(&s->airfile);
+ bu_vls_init(&s->armorfile);
+ bu_vls_init(&s->burstfile);
+ bu_vls_init(&s->cmdbuf);
+ bu_vls_init(&s->cmdname);
+ bu_vls_init(&s->colorfile);
+ bu_vls_init(&s->critfile);
+ s->errfile = NULL;
+ bu_vls_init(&s->fbfile);
+ bu_vls_init(&s->gedfile);
+ bu_vls_init(&s->gridfile);
+ bu_vls_init(&s->histfile);
+ bu_vls_init(&s->objects);
+ bu_vls_init(&s->outfile);
+ bu_vls_init(&s->plotfile);
+ bu_vls_init(&s->shotfile);
+ bu_vls_init(&s->shotlnfile);
+ memset(s->timer, 0, TIMER_LEN);
+ bu_vls_init(&s->cmdhist);
+ s->bdist = DFL_BDIST;
+ VSET(s->burstpoint, 0.0, 0.0, 0.0);
+ s->cellsz = DFL_CELLSIZE;
+ s->conehfangle = DFL_CONEANGLE;
+ VSET(s->fire, 0.0, 0.0, 0.0);
+ s->griddn = 0.0;
+ s->gridlf = 0.0;
+ s->gridrt = 0.0;
+ s->gridup = 0.0;
+ VSET(s->gridhor, 0.0, 0.0, 0.0);
+ VSET(s->gridsoff, 0.0, 0.0, 0.0);
+ VSET(s->gridver, 0.0, 0.0, 0.0);
+ s->grndbk = 0.0;
+ s->grndht = 0.0;
+ s->grndfr = 0.0;
+ s->grndlf = 0.0;
+ s->grndrt = 0.0;
+ VSET(s->modlcntr, 0.0, 0.0, 0.0);
+ s->modldn = 0.0;
+ s->modllf = 0.0;
+ s->modlrt = 0.0;
+ s->modlup = 0.0;
+ s->raysolidangle = 0.0;
+ s->standoff = 0.0;
+ s->unitconv = 1.0;
+ s->viewazim = DFL_AZIMUTH;
+ s->viewelev = DFL_ELEVATION;
+ s->pitch = 0.0;
+ s->yaw = 0.0;
+ VSET(s->xaxis, 1.0, 0.0, 0.0);
+ VSET(s->zaxis, 0.0, 0.0, 1.0);
+ VSET(s->negzaxis, 0.0, 0.0, -1.0);
+ s->co = 0;
+ s->devwid = 0;
+ s->devhgt = 0;
+ s->firemode = FM_DFLT;
+ s->gridsz = 512;
+ s->gridxfin = 0;
+ s->gridyfin = 0;
+ s->gridxorg = 0;
+ s->gridyorg = 0;
+ s->gridwidth = 0;
+ s->gridheight = 0;
+ s->li = 0;
+ s->nbarriers = DFL_BARRIERS;
+ s->noverlaps = 0;
+ s->nprocessors = 0;
+ s->nriplevels = DFL_RIPLEVELS;
+ s->nspallrays = DFL_NRAYS;
+ s->zoom = 1;
+ s->rtip = RTI_NULL;
+ s->norml_sig = NULL; /* active during interactive operation */
+ s->abort_sig = NULL; /* active during ray tracing only */
+ s->cmds = NULL;
+}
+
+
+extern "C" int
+_burst_cmd_attack_direction(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "attack-direction azim_angle elev_angle";
+ const char *purpose_string = "specify azimuth and elevation of attack
relative to target";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+ struct bu_vls msg = BU_VLS_INIT_ZERO;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 3) {
+ printf("Usage: attack-direction az(deg) el(deg)\n");
+ return BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[1], (void *)&s->viewazim) < 0) {
+ brst_log(s, MSG_OUT, "problem reading azimuth: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[2], (void *)&s->viewelev) < 0) {
+ brst_log(s, MSG_OUT, "problem reading elevation: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t%g %g\n", argv[0], s->viewazim, s->viewelev);
+
+ // After echoing, convert to radians for internal use
+ s->viewazim /= RAD2DEG;
+ s->viewelev /= RAD2DEG;
+
+ bu_vls_free(&msg);
+ return ret;
+}
+
+
+extern "C" int
+_burst_cmd_critical_comp_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "critical-comp-file file";
+ const char *purpose_string = "input critical component idents from file";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: critical-comp-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ brst_log(s, MSG_LOG, "Reading critical component idents...\n");
+
+ if (!readIdents(&s->critids, argv[1])) {
+ brst_log(s, MSG_OUT, "failed to open critical component file: %s\n",
argv[1]);
+ return BRLCAD_ERROR;
+ }
+
+ brst_log(s, MSG_LOG, "Reading critical component idents... done.\n");
+
+ bu_vls_sprintf(&s->critfile, "%s", argv[1]);
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t%s\n", argv[0], bu_vls_cstr(&s->critfile));
+
+ return ret;
+}
+
+
+extern "C" int
+_burst_cmd_deflect_spall_cone(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "deflect-spall-cone flag";
+ const char *purpose_string = "deflect axis of spall cone half way towards
exit normal";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: deflect-spall-cone yes|no\n");
+ return BRLCAD_ERROR;
+ }
+
+ int tval = bu_str_true(argv[1]);
+ int fval = bu_str_false(argv[1]);
+
+ if (!tval && !fval) {
+ brst_log(s, MSG_OUT, "Invalid boolean string: %s\n", argv[1]);
+ return BRLCAD_ERROR;
+ }
+
+ s->deflectcone = (fval) ? 0 : tval;
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t%s\n", argv[0], s->deflectcone ? "yes" : "no");
+
+ return BRLCAD_OK;
+}
+
+extern "C" int
+_burst_cmd_dither_cells(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "dither-cells flag";
+ const char *purpose_string = "if yes, randomly offset shotline within grid
cell";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: dither-cells yes|no\n");
+ return BRLCAD_ERROR;
+ }
+
+ int tval = bu_str_true(argv[1]);
+ int fval = bu_str_false(argv[1]);
+
+ if (!tval && !fval) {
+ brst_log(s, MSG_OUT, "Invalid boolean string: %s\n", argv[1]);
+ return BRLCAD_ERROR;
+ }
+
+ s->dithercells = (fval) ? 0 : tval;
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s\n", argv[0], s->dithercells ? "yes" : "no");
+
+ return BRLCAD_OK;
+}
+
+extern "C" int
+_burst_cmd_enclose_target(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "enclose-target";
+ const char *purpose_string = "generate rectangular grid of shotlines for
full target envelope";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ struct burst_state *s = (struct burst_state *)bs;
+ s->firemode = FM_GRID;
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "enclose-target\n");
+
+ return BRLCAD_OK;
+}
+
+extern "C" int
+_burst_cmd_enclose_portion(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "enclose-portion left right bottom top";
+ const char *purpose_string = "generate partial envelope by specifying grid
boundaries";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct bu_vls msg = BU_VLS_INIT_ZERO;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 5) {
+ brst_log(s, MSG_OUT, "Usage: enclose-portion left right bottom top\n");
+ return BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[1], (void *)&s->gridlf) < 0) {
+ brst_log(s, MSG_OUT, "problem reading left border of grid: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[2], (void *)&s->gridrt) < 0) {
+ brst_log(s, MSG_OUT, "problem reading right border of grid: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[3], (void *)&s->griddn) < 0) {
+ brst_log(s, MSG_OUT, "problem reading bottom border of grid: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[4], (void *)&s->gridup) < 0) {
+ brst_log(s, MSG_OUT, "problem reading top border of grid: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%g %g %g %g\n", argv[0], s->gridlf, s->gridrt,
s->griddn, s->gridup);
+
+ // After echoing, convert to mm
+ s->gridlf /= s->unitconv;
+ s->gridrt /= s->unitconv;
+ s->griddn /= s->unitconv;
+ s->gridup /= s->unitconv;
+
+ bu_vls_free(&msg);
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_error_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "error-file file";
+ const char *purpose_string = "divert all diagnostics to file";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: error-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ /* If we had a previous file open, close it */
+ if (s->errfile) {
+ fclose(s->errfile);
+ s->errfile = NULL;
+ }
+
+ /* If we're given a NULL argument, disable the error file */
+ if (BU_STR_EQUAL(argv[1], "NULL") || BU_STR_EQUAL(argv[1], "/dev/NULL")) {
+ return ret;
+ }
+
+ /* Try to open the file - we want to write messages to the file
+ * as they are generated. */
+ s->errfile = fopen(argv[1], "wb");
+ if (!s->errfile) {
+ brst_log(s, MSG_OUT, "failed to open error file: %s\n", argv[1]);
+ ret = BRLCAD_ERROR;
+ }
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s\n", argv[0], argv[1]);
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_execute(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "execute";
+ const char *purpose_string = "initiate a run (no output produced without
this command)";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s) return BRLCAD_ERROR;
+
+ if (!bu_vls_strlen(&s->gedfile)) {
+ brst_log(s, MSG_OUT, "Execute failed: no target file has been
specified\n");
+ return BRLCAD_ERROR;
+ }
+
+ // Echo command
+ brst_log(s, MSG_OUT, "execute\n");
+
+ return execute_run(s);
+}
+
+extern "C" int
+_burst_cmd_grid_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "grid-file file";
+ const char *purpose_string = "save shotline locations (Y' Z') in file";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: grid-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ /* If we had a previous file open, close it */
+ if (s->gridfp) {
+ fclose(s->gridfp);
+ s->gridfp = NULL;
+ }
+
+ /* If we're given a NULL argument, disable the grid file */
+ if (BU_STR_EQUAL(argv[1], "NULL") || BU_STR_EQUAL(argv[1], "/dev/NULL")) {
+ bu_vls_trunc(&s->gridfile, 0);
+ return ret;
+ }
+
+ /* Try to open the file */
+ s->gridfp = fopen(argv[1], "wb");
+ if (!s->gridfp) {
+ brst_log(s, MSG_OUT, "failed to open grid file: %s\n", argv[1]);
+ ret = BRLCAD_ERROR;
+ }
+
+ bu_vls_sprintf(&s->gridfile, "%s", argv[1]);
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s\n", argv[0], bu_vls_cstr(&s->gridfile));
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_ground_plane(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "ground-plane flag [Z +X -X +Y -Y]";
+ const char *purpose_string = "if yes, burst on ground";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct bu_vls msg = BU_VLS_INIT_ZERO;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2 && argc != 7) {
+ brst_log(s, MSG_OUT, "Usage: ground-plane no|yes height xpos xneg ypos
yneg\n");
+ return BRLCAD_ERROR;
+ }
+
+ int tval = bu_str_true(argv[1]);
+ int fval = bu_str_false(argv[1]);
+
+ if (!tval && !fval) {
+ brst_log(s, MSG_OUT, "Invalid boolean string: %s\n", argv[1]);
+ return BRLCAD_ERROR;
+ }
+
+ s->groundburst = (fval) ? 0 : tval;
+
+ if (!s->groundburst) {
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\tno\n", argv[0]);
+ return ret;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[2], (void *)&s->grndht) < 0) {
+ brst_log(s, MSG_OUT, "problem reading distance of target origin above
ground plane: %s\n", bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[3], (void *)&s->grndfr) < 0) {
+ brst_log(s, MSG_OUT, "problem reading distance out positive X-axis of
target to edge: %s\n", bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[4], (void *)&s->grndbk) < 0) {
+ brst_log(s, MSG_OUT, "problem reading distance out negative X-axis of
target to edge: %s\n", bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[5], (void *)&s->grndlf) < 0) {
+ brst_log(s, MSG_OUT, "problem reading distance out positive Y-axis of
target to edge: %s\n", bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[6], (void *)&s->grndrt) < 0) {
+ brst_log(s, MSG_OUT, "problem reading distance out negative Y-axis of
target to edge: %s\n", bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\tyes %g %g %g %g %g\n", argv[0], s->grndht,
s->grndfr, s->grndbk, s->grndlf, s->grndrt);
+
+ /* after printing, convert to mm */
+ s->grndht /= s->unitconv;
+ s->grndfr /= s->unitconv;
+ s->grndbk /= s->unitconv;
+ s->grndlf /= s->unitconv;
+ s->grndrt /= s->unitconv;
+
+ bu_vls_free(&msg);
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_help(void *bs, int argc, const char **argv)
+{
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (argc == 1 || BU_STR_EQUAL(argv[1], "help")) {
+ printf("Available commands:\n");
+ const struct bu_cmdtab *ctp = NULL;
+ int ret;
+ const char *helpflag[2];
+ helpflag[1] = PURPOSEFLAG;
+ size_t maxcmdlen = 0;
+ for (ctp = s->cmds; ctp->ct_name != (char *)NULL; ctp++) {
+ maxcmdlen = (maxcmdlen > strlen(ctp->ct_name)) ? maxcmdlen :
strlen(ctp->ct_name);
+ }
+ for (ctp = s->cmds; ctp->ct_name != (char *)NULL; ctp++) {
+ printf(" %s%*s", ctp->ct_name, (int)(maxcmdlen -
strlen(ctp->ct_name)) + 2, " ");
+ if (!BU_STR_EQUAL(ctp->ct_name, "help")) {
+ helpflag[0] = ctp->ct_name;
+ bu_cmd(s->cmds, 2, helpflag, 0, (void *)s, &ret);
+ } else {
+ printf("print help\n");
+ }
+ }
+ } else {
+ int ret;
+ const char **helpargv = (const char **)bu_calloc(argc+1, sizeof(char
*), "help argv");
+ helpargv[0] = argv[1];
+ helpargv[1] = HELPFLAG;
+ for (int i = 2; i < argc; i++) {
+ helpargv[i+1] = argv[i];
+ }
+ bu_cmd(s->cmds, argc, helpargv, 0, (void *)s, &ret);
+ bu_free(helpargv, "help argv");
+ }
+
+ return BRLCAD_OK;
+}
+
+extern "C" int
+_burst_cmd_burst_air_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "burst-air-file file";
+ const char *purpose_string = "input burst air idents from file";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: burst-air-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ brst_log(s, MSG_LOG, "Reading burst air idents...\n");
+
+ if (!readIdents(&s->airids, argv[1])) {
+ brst_log(s, MSG_OUT, "failed to open burst air idents file: %s\n",
argv[1]);
+ return BRLCAD_ERROR;
+ }
+
+ brst_log(s, MSG_LOG, "Reading burst air idents... done.\n");
+
+ bu_vls_sprintf(&s->airfile, "%s", argv[1]);
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s\n", argv[0], bu_vls_cstr(&s->airfile));
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_histogram_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "histogram-file file";
+ const char *purpose_string = "write hit frequency histogram to file";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: histogram-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ /* If we had a previous file open, close it */
+ if (s->histfp) {
+ fclose(s->histfp);
+ s->histfp = NULL;
+ }
+
+ /* If we're given a NULL argument, disable the grid file */
+ if (BU_STR_EQUAL(argv[1], "NULL") || BU_STR_EQUAL(argv[1], "/dev/NULL")) {
+ bu_vls_trunc(&s->histfile, 0);
+ return ret;
+ }
+
+ /* Try to open the file */
+ s->histfp = fopen(argv[1], "wb");
+ if (!s->histfp) {
+ brst_log(s, MSG_OUT, "failed to open histogram file: %s\n", argv[1]);
+ ret = BRLCAD_ERROR;
+ }
+
+ bu_vls_sprintf(&s->histfile, "%s", argv[1]);
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s\n", argv[0], bu_vls_cstr(&s->histfile));
+
+
+ return BRLCAD_OK;
+}
+
+extern "C" int
+_burst_cmd_image_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "image-file file";
+ const char *purpose_string = "generate frame buffer image on a specified
file or device";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: image-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ bu_vls_sprintf(&s->fbfile, "%s", argv[1]);
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s\n", argv[0], bu_vls_cstr(&s->fbfile));
+
+ return BRLCAD_OK;
+}
+
+extern "C" int
+_burst_cmd_input_2d_shot(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "input-2d-shot Y' Z'";
+ const char *purpose_string = "input single shotline location as grid
offsets";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct bu_vls msg = BU_VLS_INIT_ZERO;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 3) {
+ brst_log(s, MSG_OUT, "Usage: input-2d-shot Y Z\n");
+ return BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[1], (void *)&s->fire[X]) < 0) {
+ brst_log(s, MSG_OUT, "problem reading coordinate: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+ if (bu_opt_fastf_t(&msg, 1, &argv[2], (void *)&s->fire[Y]) < 0) {
+ brst_log(s, MSG_OUT, "problem reading coordinate: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%g %g\n", argv[0], s->fire[X], s->fire[Y]);
+
+ /* after printing, convert to mm */
+ s->fire[X] /= s->unitconv;
+ s->fire[Y] /= s->unitconv;
+
+ s->firemode = FM_SHOT;
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_input_3d_shot(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "input-3d-shot X Y Z";
+ const char *purpose_string = "input single shotline location in target
coordinates";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct bu_vls msg = BU_VLS_INIT_ZERO;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 4) {
+ brst_log(s, MSG_OUT, "Usage: input-3d-shot X Y Z\n");
+ return BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[1], (void *)&s->fire[X]) < 0) {
+ brst_log(s, MSG_OUT, "problem reading coordinate: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[2], (void *)&s->fire[Y]) < 0) {
+ brst_log(s, MSG_OUT, "problem reading coordinate: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ if (bu_opt_fastf_t(&msg, 1, &argv[3], (void *)&s->fire[Z]) < 0) {
+ brst_log(s, MSG_OUT, "problem reading coordinate: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%g %g %g\n", argv[0], s->fire[X], s->fire[Y],
s->fire[Z]);
+
+ /* after printing, convert to mm */
+ s->fire[X] /= s->unitconv;
+ s->fire[Y] /= s->unitconv;
+ s->fire[Z] /= s->unitconv;
+
+ s->firemode = FM_SHOT | FM_3DIM;
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_max_barriers(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "max-barriers count";
+ const char *purpose_string = "specify the maximum number of components to
report along spall ray";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct bu_vls msg = BU_VLS_INIT_ZERO;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: max-barriers #\n");
+ return BRLCAD_ERROR;
+ }
+
+ if (bu_opt_int(&msg, 1, &argv[1], (void *)&s->nbarriers) < 0) {
+ brst_log(s, MSG_OUT, "problem reading spall barriers per ray count:
%s\n", bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%d\n", argv[0], s->nbarriers);
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_max_spall_rays(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "max-spall-rays count";
+ const char *purpose_string = "specify the desired number of spall rays
generated per burst point";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct bu_vls msg = BU_VLS_INIT_ZERO;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: max-spall-rays #\n");
+ return BRLCAD_ERROR;
+ }
+
+ if (bu_opt_int(&msg, 1, &argv[1], (void *)&s->nspallrays) < 0) {
+ brst_log(s, MSG_OUT, "problem reading maximum rays per burst: %s\n",
bu_vls_cstr(&msg));
+ ret = BRLCAD_ERROR;
+ }
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%d\n", argv[0], s->nspallrays);
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_plot_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "plot-file file";
+ const char *purpose_string = "generate plot data in file";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: plot-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ /* Try to open the file - we want to write output to the file
+ * as it is generated. */
+ s->plotfp = fopen(argv[1], "wb");
+ if (!s->plotfp) {
+ brst_log(s, MSG_OUT, "failed to open plot file: %s\n", argv[1]);
+ return BRLCAD_ERROR;
+ }
+
+ bu_vls_sprintf(&s->plotfile, "%s", argv[1]);
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s\n", argv[0], bu_vls_cstr(&s->plotfile));
+
+ return BRLCAD_OK;
+}
+
+extern "C" int
+_burst_cmd_quit(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "quit";
+ const char *purpose_string = "quit the appliation";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ s->quit = 1;
+
+ return BRLCAD_OK;
+}
+
+extern "C" int
+_burst_cmd_read_2d_shot_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "read-2d-shot-file file";
+ const char *purpose_string = "read shot locations from file as grid
offsets (see input-2d-shot)";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: read-2d-shot-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ /* If we had a previous file open, close it */
+ if (s->shotfp) {
+ fclose(s->shotfp);
+ s->shotfp = NULL;
+ }
+
+ /* If we're given a NULL argument, disable the error file */
+ if (BU_STR_EQUAL(argv[1], "NULL") || BU_STR_EQUAL(argv[1], "/dev/NULL")) {
+ s->firemode = 0;
+ bu_vls_trunc(&s->shotfile, 0);
+ return ret;
+ }
+
+ s->shotfp = fopen(argv[1], "rb");
+ if (!s->shotfp) {
+ brst_log(s, MSG_OUT, "failed to open critical component file: %s\n",
argv[1]);
+ ret = BRLCAD_ERROR;
+ }
+
+ bu_vls_sprintf(&s->shotfile, "%s", argv[1]);
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t%s\n", argv[0], bu_vls_cstr(&s->shotfile));
+
+ s->firemode = FM_SHOT | FM_FILE;
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_read_3d_shot_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "read-3d-shot-file file";
+ const char *purpose_string = "read shot locations from file in target
coordinates (see input-3d-shot)";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: read-3d-shot-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ /* If we had a previous file open, close it */
+ if (s->shotfp) {
+ fclose(s->shotfp);
+ s->shotfp = NULL;
+ }
+
+ /* If we're given a NULL argument, disable the error file */
+ if (BU_STR_EQUAL(argv[1], "NULL") || BU_STR_EQUAL(argv[1], "/dev/NULL")) {
+ s->firemode = 0;
+ bu_vls_trunc(&s->shotfile, 0);
+ return ret;
+ }
+
+ s->shotfp = fopen(argv[1], "rb");
+ if (!s->shotfp) {
+ brst_log(s, MSG_OUT, "failed to open critical component file: %s\n",
argv[1]);
+ ret = BRLCAD_ERROR;
+ }
+ bu_vls_sprintf(&s->shotfile, "%s", argv[1]);
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t%s\n", argv[0], bu_vls_cstr(&s->shotfile));
+
+ s->firemode = FM_SHOT | FM_FILE | FM_3DIM;
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_burst_armor_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "burst-armor-file file";
+ const char *purpose_string = "input burst armor idents from file";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: burst-armor-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ brst_log(s, MSG_LOG, "Reading burst armor idents...\n");
+
+ if (!readIdents(&s->armorids, argv[1])) {
+ brst_log(s, MSG_OUT, "failed to open burst air idents file: %s\n",
argv[1]);
+ return BRLCAD_ERROR;
+ }
+
+ brst_log(s, MSG_LOG, "Reading burst armor idents... done.\n");
+
+ bu_vls_sprintf(&s->armorfile, "%s", argv[1]);
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t%s\n", argv[0], bu_vls_cstr(&s->armorfile));
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_read_burst_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "read-burst-file file";
+ const char *purpose_string = "read burst point locations from file (see
burst-coordinates)";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: read-burst-file file\n");
+ return BRLCAD_ERROR;
+ }
+
+ /* If we had a previous file open, close it */
+ if (s->burstfp) {
+ fclose(s->burstfp);
+ s->burstfp= NULL;
+ }
+
+ /* If we're given a NULL argument, disable the error file */
+ if (BU_STR_EQUAL(argv[1], "NULL") || BU_STR_EQUAL(argv[1], "/dev/NULL")) {
+ s->firemode = 0;
+ bu_vls_trunc(&s->burstfile, 0);
+ return ret;
+ }
+
+ s->burstfp = fopen(argv[1], "rb");
+ if (!s->burstfp) {
+ brst_log(s, MSG_OUT, "failed to open 3-D burst input file: %s\n",
argv[1]);
+ ret = BRLCAD_ERROR;
+ }
+
+ bu_vls_sprintf(&s->burstfile, "%s", argv[1]);
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s\n", argv[0], bu_vls_cstr(&s->burstfile));
+
+ s->firemode = FM_BURST | FM_3DIM | FM_FILE;
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_read_input_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "read-input-file file";
+ const char *purpose_string = "read key word commands from file";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ std::ifstream fs;
+ fs.open(argv[1]);
+ if (!fs.is_open()) {
+ brst_log(s, MSG_OUT, "Unable to open command file: %s\n", argv[1]);
+ return BRLCAD_ERROR;
+ }
+ std::string bline;
+ while (std::getline(fs, bline)) {
+ if (burst_process_line(s, bline.c_str()) != BRLCAD_OK) {
+ brst_log(s, MSG_OUT, "Error processing line: %s\n", bline.c_str());
+ fs.close();
+ return BRLCAD_ERROR;
+ }
+ /* build up a command history buffer for write-input-file */
+ bu_vls_printf(&s->cmdhist, "%s\n", bline.c_str());
+ }
+ fs.close();
+
+ return ret;
+}
+
+extern "C" int
+_burst_cmd_report_overlaps(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "report-overlaps file";
+ const char *purpose_string = "if yes, log overlap diagnostics";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: report-overlaps yes|no\n");
+ return BRLCAD_ERROR;
+ }
+
+ int tval = bu_str_true(argv[1]);
+ int fval = bu_str_false(argv[1]);
+
+ if (!tval && !fval) {
+ brst_log(s, MSG_OUT, "Invalid boolean string: %s\n", argv[1]);
+ return BRLCAD_ERROR;
+ }
+
+ s->reportoverlaps = (fval) ? 0 : tval;
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s\n", argv[0], s->reportoverlaps ? "yes" :
"no");
+
+ return BRLCAD_OK;
+}
+
+extern "C" int
+_burst_cmd_shotline_burst(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "shotline-burst flag [flag]";
+ const char *purpose_string = "if yes, generate burst points along
shotlines";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2 && argc != 3) {
+ brst_log(s, MSG_OUT, "Usage: shotline-burst yes|no\n");
+ return BRLCAD_ERROR;
+ }
+
+ int tval = bu_str_true(argv[1]);
+ int fval = bu_str_false(argv[1]);
+
+ if (!tval && !fval) {
+ brst_log(s, MSG_OUT, "Invalid boolean string: %s\n", argv[1]);
+ return BRLCAD_ERROR;
+ }
+
+ s->shotburst = (fval) ? 0 : tval;
+
+ if (s->shotburst) {
+ if (argc == 3) {
+ tval = bu_str_true(argv[2]);
+ fval = bu_str_false(argv[2]);
+
+ if (!tval && !fval) {
+ brst_log(s, MSG_OUT, "Invalid boolean string: %s\n", argv[2]);
+ return BRLCAD_ERROR;
+ }
+ s->reqburstair = (fval) ? 0 : tval;
+ } else {
+ s->reqburstair = s->shotburst;
+ }
+
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s %s\n", argv[0], s->shotburst ? "yes" :
"no", s->reqburstair ? "yes" : "no");
+
+ s->firemode &= ~FM_BURST; /* disable discrete burst points */
+ } else {
+ // Echo command (logCmd in original code)
+ brst_log(s, MSG_OUT, "%s\t\t%s\n", argv[0], s->shotburst ? "yes" :
"no");
+ }
+
+ return BRLCAD_OK;
+}
+
+extern "C" int
+_burst_cmd_shotline_file(void *bs, int argc, const char **argv)
+{
+ const char *usage_string = "shotline-file file";
+ const char *purpose_string = "output shot line data to file";
+ if (_burst_cmd_msgs(bs, argc, argv, usage_string, purpose_string)) {
+ return BRLCAD_OK;
+ }
+
+ int ret = BRLCAD_OK;
+ struct burst_state *s = (struct burst_state *)bs;
+
+ if (!s || !argc || !argv) return BRLCAD_ERROR;
+
+ if (argc != 2) {
+ brst_log(s, MSG_OUT, "Usage: shotline-file file\n");
+ return BRLCAD_ERROR;
+ }
+
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits