Revision: 56349
http://sourceforge.net/p/brlcad/code/56349
Author: starseeker
Date: 2013-07-30 18:27:39 +0000 (Tue, 30 Jul 2013)
Log Message:
-----------
Add -S option to comb for 'safe' operation (i.e. not changing an existing
combination) - allows comb to emulate a current behavior of 'c' command.
Modified Paths:
--------------
brlcad/trunk/src/libged/comb.c
Modified: brlcad/trunk/src/libged/comb.c
===================================================================
--- brlcad/trunk/src/libged/comb.c 2013-07-30 18:11:13 UTC (rev 56348)
+++ brlcad/trunk/src/libged/comb.c 2013-07-30 18:27:39 UTC (rev 56349)
@@ -189,7 +189,40 @@
return GED_OK;
}
+
+/* Approach - define a search string that searches for all solid objects
+ * in the tree, and returns the bu_ptbl list of unique solids. Do the
+ * same for combs.
+ *
+ * Need to make sure that all objects in the tree are unioned in -
+ * it's not clear what it would mean to at the moment "flatten" a
+ * tree with intersections or subtractions.
+ * Once boolean evaluations are ready, we could probably
+ * evaluate such objects to get a single representation that can be unioned
+ * into a flat tree...
+ *
+ * Clear the tree of the comb, and add all the solids in the bu_ptbl.
+ *
+ * Because it's a hard flatten, kill all the comb trees in the comb
+ * list. For a "soft" kill, a third search is needed for all objects
+ * outside the comb tree - hopefully, that bu_ptbl can then be searched
+ * for the candidate deletion pointers and only those *not* found will
+ * be deleted - i.e only delete objects uniquely in this comb tree.
+ *
+ * bu_ptbl_locate is how to check for a given pointer in the table - -1
returned if not found
+ */
+/*
int
+_ged_flatten_comb(struct ged *gedp, struct directory *dp) {
+}
+
+int
+_ged_hard_flatten_comb(struct ged *gedp, struct directory *dp) {
+
+}
+*/
+
+int
ged_comb(struct ged *gedp, int argc, const char *argv[])
{
struct directory *dp;
@@ -201,7 +234,9 @@
int set_comb = 0;
int standard_comb_build = 1;
int wrap_comb = 0;
- static const char *usage = "[-c/-r] [-w] comb_name [<operation object>]";
+ int flatten_comb = 0;
+ int alter_existing = 1;
+ static const char *usage = "[-c/-r] [-w/-f] [-S] comb_name [<operation
object>]";
GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
GED_CHECK_READ_ONLY(gedp, GED_ERROR);
@@ -227,7 +262,7 @@
bu_optind = 1;
/* Grab any arguments off of the argv list */
- while ((c = bu_getopt(argc, (char **)argv, "crw")) != -1) {
+ while ((c = bu_getopt(argc, (char **)argv, "crwfS")) != -1) {
switch (c) {
case 'c' :
set_comb = 1;
@@ -239,6 +274,13 @@
wrap_comb = 1;
standard_comb_build = 0;
break;
+ case 'f' :
+ flatten_comb = 1;
+ standard_comb_build = 0;
+ break;
+ case 'S' :
+ alter_existing = 0;
+ break;
default :
break;
}
@@ -252,7 +294,7 @@
return GED_ERROR;
}
- if (wrap_comb && argc != 2) {
+ if ((wrap_comb || flatten_comb) && argc != 2) {
bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
return GED_ERROR;
}
@@ -264,6 +306,9 @@
bu_vls_printf(gedp->ged_result_str, "ERROR: %s is not a
combination", comb_name);
return GED_ERROR;
}
+ if ((dp != RT_DIR_NULL) && !alter_existing) {
+ bu_vls_printf(gedp->ged_result_str, "ERROR: %s already exists.",
comb_name);
+ }
}
/* If we aren't performing one of the option operations,
@@ -310,6 +355,7 @@
}
}
+ /* Handle the -w option for "wrapping" the contents of the comb */
if (wrap_comb) {
if (!dp || dp == RT_DIR_NULL) {
bu_vls_printf(gedp->ged_result_str, "Combination '%s does not
exist.\n", comb_name);
@@ -324,6 +370,23 @@
}
}
}
+
+ if (flatten_comb) {
+ if (!dp || dp == RT_DIR_NULL) {
+ bu_vls_printf(gedp->ged_result_str, "Combination '%s does not
exist.\n", comb_name);
+ return GED_ERROR;
+ }
+/* if (_ged_hard_flatten_comb(gedp, dp) == GED_ERROR) {
+ return GED_ERROR;
+ } else {
+ if ((dp=db_lookup(gedp->ged_wdbp->dbip, comb_name, LOOKUP_QUIET))
== RT_DIR_NULL) {
+ bu_vls_printf(gedp->ged_result_str, "ERROR: flattening of %s
failed", comb_name);
+ return GED_ERROR;
+ }
+ }
+*/
+ }
+
/* Make sure the region flag is set appropriately */
if (set_comb || set_region) {
if ((dp = db_lookup(gedp->ged_wdbp->dbip, comb_name, LOOKUP_NOISY)) !=
RT_DIR_NULL) {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits