Revision: 33630
          http://brlcad.svn.sourceforge.net/brlcad/?rev=33630&view=rev
Author:   erikgreenwald
Date:     2009-01-30 19:59:33 +0000 (Fri, 30 Jan 2009)

Log Message:
-----------
added a rough cut at an "evolutionary" capability to g_diff. This attempts to 
guess if a change to a region was a natural evolution or if the region was 
"reworked" in some significant fashion. Requested by lbutler.

Modified Paths:
--------------
    brlcad/trunk/NEWS
    brlcad/trunk/src/gtools/g_diff.1
    brlcad/trunk/src/gtools/g_diff.c

Modified: brlcad/trunk/NEWS
===================================================================
--- brlcad/trunk/NEWS   2009-01-30 18:54:23 UTC (rev 33629)
+++ brlcad/trunk/NEWS   2009-01-30 19:59:33 UTC (rev 33630)
@@ -32,6 +32,7 @@
 * new initial manual page for bot_dump - Sean Morrison
 * added editing support for hyperboloid primitive to mged - Cliff Yapp
 * new 'lens' procedural tool for making optical lenses - Cliff Yapp
+* g_tool now guesses if a change was evolutionary - Erik Greenwald
 
 
 ----------------------------------------------------------------------

Modified: brlcad/trunk/src/gtools/g_diff.1
===================================================================
--- brlcad/trunk/src/gtools/g_diff.1    2009-01-30 18:54:23 UTC (rev 33629)
+++ brlcad/trunk/src/gtools/g_diff.1    2009-01-30 19:59:33 UTC (rev 33630)
@@ -46,7 +46,7 @@
 .SH NAME
 g_diff \- a BRL-CAD differential geometry comparator
 .SH SYNOPSIS
-.BR "g_diff " "[-m] [-f] [-v] model1.g model2.g"
+.BR "g_diff " "[-e][-m] [-f] [-v] model1.g model2.g"
 .SH DESCRIPTION
 .I G_diff
 compares the two BRL-CAD models specified on the comand line. The results of 
this comparison
@@ -62,6 +62,10 @@
 commands in mged(1). A few solid types are not supported by these commands, 
and changes involving these
 solids are merely noted (the script will not actually be capable of performing 
all the changes in this case).
 The
+.I -e
+option selections evolutionary mode, which attempts to guess if a change in a 
region is due to an evolutionary change or a reworking.
+The output is similar to -m, but it is NOT mged readable.
+The
 .I -f
 option requests that all floating point numerical comparisons be done in 
single precision rather
 than the default double precision. This may be useful when comparing different 
format databases.

Modified: brlcad/trunk/src/gtools/g_diff.c
===================================================================
--- brlcad/trunk/src/gtools/g_diff.c    2009-01-30 18:54:23 UTC (rev 33629)
+++ brlcad/trunk/src/gtools/g_diff.c    2009-01-30 19:59:33 UTC (rev 33630)
@@ -63,6 +63,7 @@
 #define        ATTRS   2
 
 static int mode=HUMAN;
+static int evolutionary = 1;
 static Tcl_Interp *interp = NULL;
 static int pre_5_vers=0;
 static int use_floats=0;       /* flag to use floats for comparisons */
@@ -74,7 +75,7 @@
 void
 Usage(char *str)
 {
-    fprintf(stderr, "Usage: %s [-m] file1.g file2.g\n", str);
+    fprintf(stderr, "Usage: %s [-emfv] file1.g file2.g\n", str);
 }
 
 
@@ -297,7 +298,7 @@
            }
        } else {
            if (strcmp(str1, str2)) {
-               return 1;
+               return strstr(str2, str1)?2:1;
            }
        }
     }
@@ -313,6 +314,7 @@
     int i, j;
     int start_index;
     int found_diffs=0;
+    int ev = 0;
 
     if (Tcl_ListObjLength(interp, obj1, &len1) == TCL_ERROR) {
        fprintf(stderr, "Error getting length of TCL object!!!\n");
@@ -356,6 +358,7 @@
                bu_exit (1, NULL);
            }
            if (!strcmp(Tcl_GetStringFromObj(key1, &junk), 
Tcl_GetStringFromObj(key2, &junk))) {
+
                found = 1;
                if (Tcl_ListObjIndex(interp, obj2, j+1, &val2) == TCL_ERROR) {
                    fprintf(stderr, "Error getting word #%d in TCL object!!! 
(%s)\n", j+1, Tcl_GetStringFromObj(obj2, &junk));
@@ -364,7 +367,8 @@
                }
 
                /* check if this value has changed */
-               if (compare_values(type, val1, val2)) {
+               ev = compare_values(type, val1, val2);
+               if ( ev ) {
                    if (!found_diffs++) {
                        if (mode == HUMAN) {
                            printf("%s has changed:\n", obj_name);
@@ -508,11 +512,14 @@
            bu_vls_strcat(vls, Tcl_GetStringFromObj(val2, &junk));
            if (val_len > 1)
                bu_vls_putc(vls, '}');
-
            if (type == ATTRS)
                bu_vls_putc(vls, '\n');
        }
     }
+
+    if (evolutionary && found_diffs)
+       bu_vls_strcat(vls, ev == 2 ? " (Evolutionary)" : " (Reworked)");
+
     return found_diffs;
 }
 
@@ -916,8 +923,11 @@
 
     invoked_as = argv[0];
 
-    while ((c = bu_getopt(argc, argv, "mfv")) != EOF) {
+    while ((c = bu_getopt(argc, argv, "emfv")) != EOF) {
        switch (c) {
+           case 'e':
+               evolutionary = 1;
+               /* no break, evolutionary mode assumes mged readable */
            case 'm':   /* mged readable */
                mode = MGED;
                break;


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

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to