Revision: 76103
          http://sourceforge.net/p/brlcad/code/76103
Author:   starseeker
Date:     2020-06-10 19:12:38 +0000 (Wed, 10 Jun 2020)
Log Message:
-----------
Working on parsing logic - add a color example to the ktank test file

Modified Paths:
--------------
    brlcad/branches/bioh/regress/burst/CMakeLists.txt
    brlcad/branches/bioh/regress/burst/ktank.b
    brlcad/branches/bioh/src/burst2/burst.cpp
    brlcad/branches/bioh/src/burst2/idents.cpp

Added Paths:
-----------
    brlcad/branches/bioh/regress/burst/ktank_colors.ids

Modified: brlcad/branches/bioh/regress/burst/CMakeLists.txt
===================================================================
--- brlcad/branches/bioh/regress/burst/CMakeLists.txt   2020-06-10 17:40:33 UTC 
(rev 76102)
+++ brlcad/branches/bioh/regress/burst/CMakeLists.txt   2020-06-10 19:12:38 UTC 
(rev 76103)
@@ -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)

Modified: brlcad/branches/bioh/regress/burst/ktank.b
===================================================================
--- brlcad/branches/bioh/regress/burst/ktank.b  2020-06-10 17:40:33 UTC (rev 
76102)
+++ brlcad/branches/bioh/regress/burst/ktank.b  2020-06-10 19:12:38 UTC (rev 
76103)
@@ -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

Added: brlcad/branches/bioh/regress/burst/ktank_colors.ids
===================================================================
--- brlcad/branches/bioh/regress/burst/ktank_colors.ids                         
(rev 0)
+++ brlcad/branches/bioh/regress/burst/ktank_colors.ids 2020-06-10 19:12:38 UTC 
(rev 76103)
@@ -0,0 +1 @@
+100 120 0 252 0


Property changes on: brlcad/branches/bioh/regress/burst/ktank_colors.ids
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: brlcad/branches/bioh/src/burst2/burst.cpp
===================================================================
--- brlcad/branches/bioh/src/burst2/burst.cpp   2020-06-10 17:40:33 UTC (rev 
76102)
+++ brlcad/branches/bioh/src/burst2/burst.cpp   2020-06-10 19:12:38 UTC (rev 
76103)
@@ -1109,8 +1109,8 @@
 
     if (!s || !argc || !argv) return BRLCAD_ERROR;
 
-    if (argc < 2 || argc > 3) {
-       printf("Usage: shotline-burst no|yes no|yes\n");
+    if (argc != 2) {
+       printf("Usage: shotline-burst yes|no\n");
        return BRLCAD_ERROR;
     }
 
@@ -1125,22 +1125,7 @@
     s->shotburst = (fval) ? 0 : tval;
 
     if (s->shotburst) {
-
-       if (argc != 3) {
-           printf("Usage: shotline-burst no|yes no|yes\n");
-           return BRLCAD_ERROR;
-       }
-
-       tval = bu_str_true(argv[2]);
-       fval = bu_str_false(argv[2]);
-
-       if (!tval && !fval) {
-           printf("Invalid boolean string: %s\n", argv[2]);
-           return BRLCAD_ERROR;
-       }
-
-       s->reqburstair = (fval) ? 0 : tval;
-
+       s->reqburstair = s->shotburst;
        s->firemode &= ~FM_BURST; /* disable discrete burst points */
     }
 
@@ -1185,7 +1170,6 @@
        ret = BRLCAD_ERROR;
     }
 
-    bu_log("shotline-file\n");
     return ret;
 }
 

Modified: brlcad/branches/bioh/src/burst2/idents.cpp
===================================================================
--- brlcad/branches/bioh/src/burst2/idents.cpp  2020-06-10 17:40:33 UTC (rev 
76102)
+++ brlcad/branches/bioh/src/burst2/idents.cpp  2020-06-10 19:12:38 UTC (rev 
76103)
@@ -98,16 +98,26 @@
 
     freeIdents(idlist); /* free old list if it exists */
 
+    std::regex num_regex("^\\s*([0-9]+)");
+    std::regex range_regex("\\s*([0-9]+)[-]*([0-9]+)");
     std::string iline;
     while (std::getline(fs, iline)) {
-       std::regex ident_regex("\\s+([0-9]+)-*([0-9]+).*");
-       std::smatch parsevar;
-       if (!std::regex_search(iline, parsevar, ident_regex)) {
+       if (!iline.length()) continue;
+       int lower;
+       int upper;
+       std::smatch nvar;
+       if (!std::regex_search(iline, nvar, num_regex)) {
            bu_log("Invalid ident line: %s\n", iline.c_str());
            continue;
        }
-       int lower = std::stoi(parsevar[2]);
-       int upper = (parsevar.size() > 1) ? std::stoi(parsevar[3]) : lower;
+       std::smatch rvar;
+       if (std::regex_search(iline, rvar, range_regex)) {
+           lower = std::stoi(rvar[1]);
+           upper = std::stoi(rvar[2]);
+       } else {
+           lower = std::stoi(nvar[1]);
+           upper = lower;
+       }
        struct ids *idp;
        BU_GET(idp, struct ids);
        idp->i_lower = lower;
@@ -144,8 +154,8 @@
     freeColors(idlist); /* free old list if it exists */
 
     std::string iline;
+    std::regex 
color_regex("([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+).*");
     while (std::getline(fs, iline)) {
-       std::regex 
color_regex("([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+).*");
        std::smatch parsevar;
        if (!std::regex_search(iline, parsevar, color_regex)) {
            bu_log("Invalid colors line: %s\n", iline.c_str());
@@ -158,11 +168,11 @@
 
        struct colors *cdp;
        BU_GET(cdp, struct colors);
-       cdp->c_lower = std::stoi(parsevar[2]);
-       cdp->c_upper = std::stoi(parsevar[3]);
-       cdp->c_rgb[0] = std::stoi(parsevar[4]);
-       cdp->c_rgb[1] = std::stoi(parsevar[5]);
-       cdp->c_rgb[2] = std::stoi(parsevar[6]);
+       cdp->c_lower = std::stoi(parsevar[1]);
+       cdp->c_upper = std::stoi(parsevar[2]);
+       cdp->c_rgb[0] = std::stoi(parsevar[3]);
+       cdp->c_rgb[1] = std::stoi(parsevar[4]);
+       cdp->c_rgb[2] = std::stoi(parsevar[5]);
        bu_ptbl_ins(idlist, (long *)cdp);
     }
 

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

Reply via email to