Revision: 45935
          http://brlcad.svn.sourceforge.net/brlcad/?rev=45935&view=rev
Author:   bhinesley
Date:     2011-08-12 03:12:02 +0000 (Fri, 12 Aug 2011)

Log Message:
-----------
Relative and absolute translations of single objects is now working, as is 
using a default of the bounding box center of objects or option -k to set 
keypoints. Objects and numbers are now working for all arguments, as well. 
Using the apparent coordinates of objects (i.e. translate -k 
a/very/specific/instance/of/shp.s -a 0 17 2.3 shp2.s) is working somewhat, but 
is off a bit in many cases. Specifiying coordinates/objects with -x/-y/-z is 
not working at the moment. Using the batch operator when translating a single 
object already works (i.e. translate -k 4 -a . obj), and accepting the batch 
operator and multiple objects to translate is close to working.

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

Modified: brlcad/trunk/src/libged/edit.c
===================================================================
--- brlcad/trunk/src/libged/edit.c      2011-08-12 02:14:36 UTC (rev 45934)
+++ brlcad/trunk/src/libged/edit.c      2011-08-12 03:12:02 UTC (rev 45935)
@@ -681,7 +681,7 @@
 };
 
 /*
- * edit_arg coordinate flags
+ * edit_arg coordinate flags (careful: used in bitshift)
  */
 
 /* edit_arg flags of coordinates that will be used */
@@ -918,11 +918,11 @@
     if (arg->object) {
        db_free_full_path(arg->object);
        bu_free((genptr_t)arg->object, "db_string_to_path");
-       arg->object = NULL;
+       arg->object = (struct db_full_path*)NULL;
     }
     if (arg->vector) {
        bu_free(arg->vector, "vect_t");
-       arg->vector = NULL;
+       arg->vector = (vect_t *)NULL;
     }
 }
 
@@ -949,7 +949,7 @@
            break;
        last_arg = arg;
     } while ((arg = arg->next));
-    last_arg->next = NULL;
+    last_arg->next = (struct edit_arg *)NULL;
     edit_arg_free(arg);
 }
 
@@ -983,7 +983,7 @@
 edit_arg_to_apparent_coord(struct ged *gedp, const struct edit_arg *const arg,
                           vect_t *const coord)
 {
-    const struct db_full_path *path = arg->object;
+    const struct db_full_path *const path = arg->object;
     struct rt_db_internal intern;
     struct directory *d;
     struct directory *d_next;
@@ -1215,10 +1215,10 @@
 }
 
 /**
- * Sets any skipped vector elements in to those of the target object,
- * and sets EDIT_COORDS_ALL on vector arguments. Expects all
- * arguments except target objects to have vector set. Only looks
- * at the first set of args.
+ * Sets any skipped vector elements to those of the target object,
+ * sets EDIT_COORDS_ALL on vector arguments, and converts relative
+ * offsets to absolute positions. Expects all arguments except target
+ * objects to have vector set. Only looks at the first set of args.
  *
  * XXX: This intentionally only looks at the first set of args. At
  * some point, it may be desirable to have the subcommand functions
@@ -1232,19 +1232,36 @@
     vect_t src_v = VINIT_ZERO;
     int i = 0;
 
-    /* draw source vector from of target object */
+    /* draw source vector from target object */
     arg_head = *(subcmd->cmd->get_arg_head(subcmd, i++));
     if (edit_arg_to_apparent_coord(gedp, arg_head, &src_v) == GED_ERROR)
        return GED_ERROR;
 
     while ((arg_head = *(subcmd->cmd->get_arg_head(subcmd, i++))) != 
           subcmd->common.objects) {
-       if (!(arg_head->coords_used & EDIT_COORD_X))
-           *arg_head->vector[0] = src_v[0];
-       if (!(arg_head->coords_used & EDIT_COORD_Y))
-           *arg_head->vector[1] = src_v[1];
-       if (!(arg_head->coords_used & EDIT_COORD_Z))
-           *arg_head->vector[2] = src_v[2];
+       if (arg_head->type & EDIT_REL_DIST) {
+           /* convert to absolute position */
+           arg_head->type &= ~EDIT_REL_DIST;
+           if (arg_head->coords_used & EDIT_COORD_X)
+               (*arg_head->vector)[0] += src_v[0];
+           else 
+               (*arg_head->vector)[0] = src_v[0];
+           if (arg_head->coords_used & EDIT_COORD_Y)
+               (*arg_head->vector)[1] += src_v[1];
+           else
+               (*arg_head->vector)[1] = src_v[1];
+           if (arg_head->coords_used & EDIT_COORD_Z)
+               (*arg_head->vector)[2] += src_v[2];
+           else
+               (*arg_head->vector)[2] = src_v[2];
+       } else {
+           if (!(arg_head->coords_used & EDIT_COORD_X))
+               (*arg_head->vector)[0] = src_v[0];
+           if (!(arg_head->coords_used & EDIT_COORD_Y))
+               (*arg_head->vector)[1] = src_v[1];
+           if (!(arg_head->coords_used & EDIT_COORD_Z))
+               (*arg_head->vector)[2] = src_v[2];
+       }
        arg_head->coords_used |= EDIT_COORDS_ALL;
     }
     return GED_OK;
@@ -1598,11 +1615,11 @@
     const int noisy = (flags & GED_ERROR); /* side with verbosity */
     struct edit_arg *cur_arg = cmd->cmd_line.args;
 
-    BU_ASSERT_PTR(cur_arg, !=, NULL);
+    BU_ASSERT_PTR(cur_arg, !=, (struct edit_arg *)NULL);
 
     if (cur_arg->type & EDIT_FROM) {
        /* if there isn't an EDIT_TO, this func shouldn't be called */
-       BU_ASSERT_PTR(cur_arg->next, !=, NULL); 
+       BU_ASSERT_PTR(cur_arg->next, !=, (struct edit_arg *)NULL); 
 
        /* a 'from' position is set; only flags that were possible
         * when this function was last updated should be handled
@@ -1624,7 +1641,7 @@
        /* if there isn't an EDIT_TARGET_OBJECT, this func shouldn't
         * be called
         */
-       BU_ASSERT_PTR(cur_arg->next, !=, NULL);
+       BU_ASSERT_PTR(cur_arg->next, !=, (struct edit_arg *)NULL);
 
        /* a 'TO' position is set; only flags that were possible when
         * this function was last updated should be handled
@@ -2091,20 +2108,13 @@
        ++(*argv);
     }
 
-    /* disable unsupplied optional coords */
+    /* disable unsupplied optional coords and */
     if (((arg->coords_used & EDIT_COORDS_ALL) == EDIT_COORDS_ALL) &&
-       (arg->coords_used & ~EDIT_COORDS_ALL)) {
-
+       (arg->coords_used & ~EDIT_COORDS_ALL))
        /* All EDIT_COORDS_ALL are set, and at least one other flag,
         * implying that the coords were in the '[x [y [z]]]" format.
         */
-       if (!(arg->coords_used & EDIT_COORD_IS_SET_X))
-           arg->coords_used ^= EDIT_COORD_X;
-       if (!(arg->coords_used ^ EDIT_COORD_IS_SET_Y))
-           arg->coords_used ^= EDIT_COORD_Y;
-       if (!(arg->coords_used ^ EDIT_COORD_IS_SET_Z))
-           arg->coords_used ^= EDIT_COORD_Z;
-    }
+       arg->coords_used = arg->coords_used >> 3;
 
     /* these flags are only for internal use */
     /* FIXME: exactly why they should be internalized, and not


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

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to