Revision: 56214
          http://sourceforge.net/p/brlcad/code/56214
Author:   starseeker
Date:     2013-07-25 15:06:51 +0000 (Thu, 25 Jul 2013)
Log Message:
-----------
Man page says comb command supports -c and -r options, so go ahead and add them.

Modified Paths:
--------------
    brlcad/trunk/src/libged/comb.c

Modified: brlcad/trunk/src/libged/comb.c
===================================================================
--- brlcad/trunk/src/libged/comb.c      2013-07-25 15:02:17 UTC (rev 56213)
+++ brlcad/trunk/src/libged/comb.c      2013-07-25 15:06:51 UTC (rev 56214)
@@ -37,10 +37,13 @@
 ged_comb(struct ged *gedp, int argc, const char *argv[])
 {
     struct directory *dp;
+    const char *prog_name;
     char *comb_name;
-    int i;
+    int i,c;
     char oper;
-    static const char *usage = "comb_name <operation solid>";
+    int set_region = 0;
+    static const char *usage = "[-c/-r] comb_name [<operation object>]";
+    struct bu_attribute_value_set avs;
 
     GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
     GED_CHECK_READ_ONLY(gedp, GED_ERROR);
@@ -49,17 +52,40 @@
     /* initialize result */
     bu_vls_trunc(gedp->ged_result_str, 0);
 
+    prog_name = argv[0];
+
     /* must be wanting help */
     if (argc == 1) {
        bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
        return GED_HELP;
     }
 
-    if (argc < 4) {
+    if (argc < 3) {
        bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
        return GED_ERROR;
     }
 
+    /* First, handle options, if any */
+
+    bu_optind = 1;
+    /* Grab any arguments off of the argv list */
+    while ((c = bu_getopt(argc, (char **)argv, "cr")) != -1) {
+        switch (c) {
+            case 'c' :
+                set_region = 0;
+                break;
+            case 'r' :
+                set_region = 1;
+                break;
+            default :
+                break;
+        }
+    }
+
+    argc -= bu_optind - 1;
+    argv += bu_optind - 1;
+
+    /* Now, we're ready to process operation/object pairs, if any */
     /* Check for odd number of arguments */
     if (argc & 01) {
        bu_vls_printf(gedp->ged_result_str, "error in number of args!");
@@ -107,6 +133,36 @@
        }
     }
 
+    /* Make sure the region flag is set appropriately */
+    dp=db_lookup(gedp->ged_wdbp->dbip, comb_name, LOOKUP_QUIET);
+    bu_avs_init_empty(&avs);
+    if (db5_get_attributes(gedp->ged_wdbp->dbip, &avs, dp)) {
+       bu_vls_printf(gedp->ged_result_str, "Cannot get attributes for object 
%s\n", dp->d_namep);
+       return GED_ERROR;
+    }
+    db5_standardize_avs(&avs);
+    if (set_region) {
+       dp->d_flags |= RT_DIR_REGION;
+       (void)bu_avs_add(&avs, "region", "R");
+       if (db5_update_attributes(dp, &avs, gedp->ged_wdbp->dbip)) {
+           bu_vls_printf(gedp->ged_result_str,
+                   "Error: failed to update attributes\n");
+           bu_avs_free(&avs);
+           return GED_ERROR;
+       }
+    } else {
+       dp->d_flags = dp->d_flags & ~(RT_DIR_REGION);
+       (void)bu_avs_remove(&avs, "region");
+       if (db5_replace_attributes(dp, &avs, gedp->ged_wdbp->dbip)) {
+           bu_vls_printf(gedp->ged_result_str,
+                   "Error: failed to update attributes\n");
+           bu_avs_free(&avs);
+           return GED_ERROR;
+       }
+    }
+    
+    /* avs is freed by either db5_update_attributes() or 
db5_replace_attributes() */
+
     return GED_OK;
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to