Revision: 53409
          http://brlcad.svn.sourceforge.net/brlcad/?rev=53409&view=rev
Author:   bob1961
Date:     2012-11-01 11:18:43 +0000 (Thu, 01 Nov 2012)
Log Message:
-----------
Added _ged_select_botpts() for selecting the bot points within a rectangle or 
circle.

Modified Paths:
--------------
    brlcad/trunk/src/libged/edbot.c
    brlcad/trunk/src/libged/ged_private.h

Modified: brlcad/trunk/src/libged/edbot.c
===================================================================
--- brlcad/trunk/src/libged/edbot.c     2012-10-31 20:22:24 UTC (rev 53408)
+++ brlcad/trunk/src/libged/edbot.c     2012-11-01 11:18:43 UTC (rev 53409)
@@ -299,7 +299,6 @@
     struct rt_db_internal intern;
     struct rt_bot_internal *botip;
     mat_t mat;
-    char *last;
     vect_t view;
     int vi1, vi2;
 
@@ -321,16 +320,6 @@
        return GED_ERROR;
     }
 
-    if ((last = strrchr(argv[1], '/')) == NULL)
-       last = (char *)argv[1];
-    else
-       ++last;
-
-    if (last[0] == '\0') {
-       bu_vls_printf(gedp->ged_result_str, "%s: illegal input - %s", argv[0], 
argv[1]);
-       return GED_ERROR;
-    }
-
     if (bu_sscanf(argv[2], "%lf %lf %lf", &view[X], &view[Y], &view[Z]) != 3) {
        bu_vls_printf(gedp->ged_result_str, "%s: bad view location - %s", 
argv[0], argv[2]);
        return GED_ERROR;
@@ -365,7 +354,6 @@
     struct rt_db_internal intern;
     struct rt_bot_internal *botip;
     mat_t mat;
-    char *last;
     vect_t view;
     int nearest_pt;
 
@@ -387,16 +375,6 @@
        return GED_ERROR;
     }
 
-    if ((last = strrchr(argv[1], '/')) == NULL)
-       last = (char *)argv[1];
-    else
-       ++last;
-
-    if (last[0] == '\0') {
-       bu_vls_printf(gedp->ged_result_str, "%s: illegal input - %s", argv[0], 
argv[1]);
-       return GED_ERROR;
-    }
-
     if (bu_sscanf(argv[2], "%lf %lf %lf", &view[X], &view[Y], &view[Z]) != 3) {
        bu_vls_printf(gedp->ged_result_str, "%s: bad view location - %s", 
argv[0], argv[2]);
        return GED_ERROR;
@@ -695,7 +673,82 @@
 }
 
 
+int
+_ged_select_botpts(struct ged *gedp, struct rt_bot_internal *botip, double vx, 
double vy, double vwidth, double vheight, double vminz, int rflag)
+{
+    size_t i;
+    fastf_t vr = 0.0;
+    fastf_t vmin_x = 0.0;
+    fastf_t vmin_y = 0.0;
+    fastf_t vmax_x = 0.0;
+    fastf_t vmax_y = 0.0;
 
+    GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+    GED_CHECK_VIEW(gedp, GED_ERROR);
+
+    if (rflag) {
+       vr = vwidth;
+    } else {
+       vmin_x = vx;
+       vmin_y = vy;
+
+       if (vwidth > 0)
+           vmax_x = vx + vwidth;
+       else {
+           vmin_x = vx + vwidth;
+           vmax_x = vx;
+       }
+
+       if (vheight > 0)
+           vmax_y = vy + vheight;
+       else {
+           vmin_y = vy + vheight;
+           vmax_y = vy;
+       }
+    }
+
+    if (rflag) {
+       for (i = 0; i < botip->num_vertices; i++) {
+           point_t vloc;
+           point_t vpt;
+           vect_t diff;
+           fastf_t mag;
+
+           MAT4X3PNT(vpt, gedp->ged_gvp->gv_model2view, &botip->vertices[i*3]);
+
+           if (vpt[Z] < vminz)
+               continue;
+
+           VSET(vloc, vx, vy, vpt[Z]);
+           VSUB2(diff, vpt, vloc);
+           mag = MAGNITUDE(diff);
+
+           if (mag > vr)
+               continue;
+
+           bu_vls_printf(gedp->ged_result_str, "%zu ", i);
+       }
+    } else {
+       for (i = 0; i < botip->num_vertices; i++) {
+           point_t vpt;
+
+           MAT4X3PNT(vpt, gedp->ged_gvp->gv_model2view, &botip->vertices[i*3]);
+
+           if (vpt[Z] < vminz)
+               continue;
+
+           if (vmin_x <= vpt[X] && vpt[X] <= vmax_x &&
+               vmin_y <= vpt[Y] && vpt[Y] <= vmax_y) {
+               bu_vls_printf(gedp->ged_result_str, "%zu ", i);
+           }
+       }
+    }
+
+    return GED_OK;
+}
+
+
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/trunk/src/libged/ged_private.h
===================================================================
--- brlcad/trunk/src/libged/ged_private.h       2012-10-31 20:22:24 UTC (rev 
53408)
+++ brlcad/trunk/src/libged/ged_private.h       2012-11-01 11:18:43 UTC (rev 
53409)
@@ -163,6 +163,17 @@
                             struct solid *existing_sp,
                             struct _ged_client_data *dgcdp);
 
+/* defined in edbot.c */
+extern int _ged_select_botpts(struct ged *gedp,
+                             struct rt_bot_internal *botip,
+                             double vx,
+                             double vy,
+                             double vwidth,
+                             double vheight,
+                             double vminz,
+                             int rflag);
+
+
 /* defined in editit.c */
 extern int _ged_editit(const char *editstring,
                       const char *file);

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


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to