Revision: 51764
          http://brlcad.svn.sourceforge.net/brlcad/?rev=51764&view=rev
Author:   cprecup
Date:     2012-08-05 03:19:33 +0000 (Sun, 05 Aug 2012)
Log Message:
-----------
Changed the definition of the *ged_graph_objects_positions* routine; integrated 
it as a command. Made sure that the commands *graph_objects_positions*, and 
*graph_structure* always exist so that the user is not misinformed that they 
are invalid commands, provided that the Adaptagrams library isn't available.

Modified Paths:
--------------
    brlcad/trunk/include/ged.h
    brlcad/trunk/src/libged/dag.cpp
    brlcad/trunk/src/libtclcad/tclcad_obj.c
    brlcad/trunk/src/mged/setup.c
    brlcad/trunk/src/tclscripts/lib/Ged.tcl
    brlcad/trunk/src/tclscripts/lib/tclIndex

Modified: brlcad/trunk/include/ged.h
===================================================================
--- brlcad/trunk/include/ged.h  2012-08-04 07:02:52 UTC (rev 51763)
+++ brlcad/trunk/include/ged.h  2012-08-05 03:19:33 UTC (rev 51764)
@@ -1910,6 +1910,11 @@
 GED_EXPORT extern int ged_voxelize(struct ged *gedp, int argc, const char 
*argv[]);
 
 /**
+ * Get the names and positions in a graph of objects from a database.
+ */
+GED_EXPORT extern int ged_graph_objects_positions(struct ged *gedp, int argc, 
const char *argv[]);
+
+/**
  * Query or manipulate properties of a graph.
  */
 GED_EXPORT extern int ged_graph_structure(struct ged *gedp, int argc, const 
char *argv[]);

Modified: brlcad/trunk/src/libged/dag.cpp
===================================================================
--- brlcad/trunk/src/libged/dag.cpp     2012-08-04 07:02:52 UTC (rev 51763)
+++ brlcad/trunk/src/libged/dag.cpp     2012-08-05 03:19:33 UTC (rev 51764)
@@ -418,9 +418,6 @@
 
     bu_log("Added %d objects.\n", dag->object_nr);
 
-    //ged_close(gedp);
-
-
     /* Free memory. */
     bu_vls_free(&dp_name_vls);
     free_hash_values(objects);
@@ -434,17 +431,44 @@
  * This routine returns a vector of vectors of points.
  * A vector of points defines a polygon shape that corresponds to an object in 
the database.
  */
-std::vector<std::vector<Avoid::Point> >
-ged_graph_objects_positions(struct _ged_dag_data *dag) {
-    std::vector<std::vector<Avoid::Point> > positions;
-    ObstacleList::const_iterator finish = dag->router->m_obstacles.end();
-    positions.reserve(dag->object_nr);
+int
+ged_graph_objects_positions(struct ged *gedp, int argc, const char *argv[])
+{
+    struct _ged_dag_data *dag;
+    const char *cmd = argv[0];
 
-    for (ObstacleList::const_iterator it = dag->router->m_obstacles.begin(); 
it != finish; ++it) {
-        positions[(*it)->id()] = (*it)->polygon().ps;
+    /* The bounding positions of the rectangle corresponding to one object. */
+    double minX;
+    double minY;
+    double maxX;
+    double maxY;
+
+    GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+    GED_CHECK_READ_ONLY(gedp, GED_ERROR);
+    GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+    /* initialize result */
+    bu_vls_trunc(gedp->ged_result_str, 0);
+
+    if (argc > 1 || argc == 0) {
+            bu_vls_printf(gedp->ged_result_str, "Usage: %s", cmd);
+            return GED_ERROR;
     }
 
-    return positions;
+    if(argc == 1) {
+        dag = (struct _ged_dag_data *) bu_malloc(sizeof(_ged_dag_data), "DAG 
structure");
+        dag->router = new Avoid::Router(Avoid::PolyLineRouting);
+        add_objects(gedp, dag);
+
+        ObstacleList::const_iterator finish = dag->router->m_obstacles.end();
+        for (ObstacleList::const_iterator it = 
dag->router->m_obstacles.begin(); it != finish; ++it) {
+            (*it)->polygon().getBoundingRect(&minX, &minY, &maxX, &maxY);
+            bu_vls_printf(gedp->ged_result_str, "%f %f %f %f\n", minX, minY, 
maxX, maxY);
+        }
+
+        bu_free(dag, "free DAG");
+    }
+
+    return GED_OK;
 }
 
 
@@ -466,32 +490,32 @@
     GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
 
     /* initialize result */
-        bu_vls_trunc(gedp->ged_result_str, 0);
+    bu_vls_trunc(gedp->ged_result_str, 0);
 
     /* must be wanting help */
     if (argc < 2) {
             bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", cmd, usage);
             return GED_ERROR;
     }
-if(argc >= 2) {
-    /* determine subcommand */
-    sub = argv[1];
-    len = strlen(sub);
+    if(argc >= 2) {
+        /* determine subcommand */
+        sub = argv[1];
+        len = strlen(sub);
 
-    if(bu_strncmp(sub, "view", len) == 0) {
-        dag = (struct _ged_dag_data *) bu_malloc(sizeof(_ged_dag_data), "DAG 
structure");
-        dag->router = new Avoid::Router(Avoid::PolyLineRouting);
-        add_objects(gedp, dag);
+        if(bu_strncmp(sub, "view", len) == 0) {
+            dag = (struct _ged_dag_data *) bu_malloc(sizeof(_ged_dag_data), 
"DAG structure");
+            dag->router = new Avoid::Router(Avoid::PolyLineRouting);
+            add_objects(gedp, dag);
 
-        dag->router->outputInstanceToSVG("dag2");
-        dag->router->outputDiagramSVG("dag3");
+            dag->router->outputInstanceToSVG("dag2");
+            dag->router->outputDiagramSVG("dag3");
 
-        bu_free(dag, "free DAG");
-    } else {
-        bu_vls_printf(gedp->ged_result_str, "%s: %s is not a known 
subcommand!", cmd, sub);
-        return GED_ERROR;
+            bu_free(dag, "free DAG");
+        } else {
+            bu_vls_printf(gedp->ged_result_str, "%s: %s is not a known 
subcommand!", cmd, sub);
+            return GED_ERROR;
+        }
     }
-}
     return GED_OK;
 }
 
@@ -499,6 +523,44 @@
 #define PARALLEL BRLCAD_PARALLEL
 #undef BRLCAD_PARALLEL
 
+
+#else
+
+#include "ged_private.h"
+
+/**
+ * Dummy graph functions in case no Adaptagrams library found
+ */
+int
+ged_graph_structure(struct ged *gedp, int argc, const char *argv[])
+{
+    GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+    GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+
+    /* Initialize result */
+    bu_vls_trunc(gedp->ged_result_str, 0);
+
+    bu_vls_printf(gedp->ged_result_str, "%s : ERROR This command is disabled 
due to the absence of Adaptagrams library",
+          argv[0]);
+    return GED_ERROR;
+}
+
+
+int
+ged_graph_objects_positions(struct ged *gedp, int argc, const char *argv[])
+{
+    GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+    GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+
+    /* Initialize result */
+    bu_vls_trunc(gedp->ged_result_str, 0);
+
+    bu_vls_printf(gedp->ged_result_str, "%s : ERROR This command is disabled 
due to the absence of Adaptagrams library",
+          argv[0]);
+    return GED_ERROR;
+}
+
+
 #endif
 
 

Modified: brlcad/trunk/src/libtclcad/tclcad_obj.c
===================================================================
--- brlcad/trunk/src/libtclcad/tclcad_obj.c     2012-08-04 07:02:52 UTC (rev 
51763)
+++ brlcad/trunk/src/libtclcad/tclcad_obj.c     2012-08-05 03:19:33 UTC (rev 
51764)
@@ -918,9 +918,8 @@
     {"get_type",       (char *)0, TO_UNLIMITED, to_pass_through_func, 
ged_get_type},
     {"glob",   (char *)0, TO_UNLIMITED, to_pass_through_func, ged_glob},
     {"gqa",    (char *)0, TO_UNLIMITED, to_pass_through_func, ged_gqa},
-#ifdef HAVE_ADAPTAGRAMS
-    {"graph",  (char *)0, TO_UNLIMITED, to_pass_through_func, 
ged_graph_structure},
-#endif
+    {"graph_objects_positions",        (char *)0, TO_UNLIMITED, 
to_pass_through_func, ged_graph_objects_positions},
+    {"graph_structure",        (char *)0, TO_UNLIMITED, to_pass_through_func, 
ged_graph_structure},
     {"grid",   "args", 6, to_view_func, ged_grid},
     {"handle_expose",  "vname count", TO_UNLIMITED, to_handle_expose, 
GED_FUNC_PTR_NULL},
     {"hide",   (char *)0, TO_UNLIMITED, to_pass_through_func, ged_hide},

Modified: brlcad/trunk/src/mged/setup.c
===================================================================
--- brlcad/trunk/src/mged/setup.c       2012-08-04 07:02:52 UTC (rev 51763)
+++ brlcad/trunk/src/mged/setup.c       2012-08-05 03:19:33 UTC (rev 51764)
@@ -170,9 +170,8 @@
     {"get_sed", f_get_sedit, GED_FUNC_PTR_NULL},
     {"get_sed_menus", f_get_sedit_menus, GED_FUNC_PTR_NULL},
     {"get_solid_keypoint", f_get_solid_keypoint, GED_FUNC_PTR_NULL},
-#ifdef HAVE_ADAPTAGRAMS
+    {"graph_objects_positions", cmd_ged_plain_wrapper, 
ged_graph_objects_positions},
     {"graph_structure", cmd_ged_plain_wrapper, ged_graph_structure},
-#endif
     {"gqa", cmd_ged_gqa, ged_gqa},
     {"grid2model_lu", cmd_ged_plain_wrapper, ged_grid2model_lu},
     {"grid2view_lu", cmd_ged_plain_wrapper, ged_grid2view_lu},

Modified: brlcad/trunk/src/tclscripts/lib/Ged.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/lib/Ged.tcl     2012-08-04 07:02:52 UTC (rev 
51763)
+++ brlcad/trunk/src/tclscripts/lib/Ged.tcl     2012-08-05 03:19:33 UTC (rev 
51764)
@@ -202,6 +202,7 @@
        method get_type {args}
        method glob {args}
        method gqa {args}
+        method graph_objects_positions{args}
        method grid {args}
        method handle_expose {args}
        method hide {args}
@@ -1460,6 +1461,10 @@
     eval $mGed gqa $args
 }
 
+::itcl::body cadwidgets::Ged::graph_objects_positions {args} {
+    eval $mGed graph_objects_positions $args
+}
+
 ::itcl::body cadwidgets::Ged::grid {args} {
     foreach dm {ur ul ll lr} {
        eval $mGed grid $itk_component($dm) $args
@@ -4859,6 +4864,7 @@
     $help add get_type         {{object} {returns the object type}}
     $help add glob             {{expression} {returns a list of objects 
specified by expression}}
     $help add gqa              {{options object(s)} {perform quantitative 
analysis checks on geometry}}
+    $help add graph_objects_positions {{} {returns a string with the name of 
the objects and the positions of the shapes that represent them in the graph}}
     $help add grid             {{color|draw|help|mrh|mrv|rh|rv|snap|vars|vsnap 
[args]} {get/set grid attributes}}
     $help add help             {{cmd} {returns a help string for cmd}}
     $help add hide             {{[objects]} {set the "hidden" flag for the 
specified objects so they do not appear in a "t" or "ls" command output}}

Modified: brlcad/trunk/src/tclscripts/lib/tclIndex
===================================================================
--- brlcad/trunk/src/tclscripts/lib/tclIndex    2012-08-04 07:02:52 UTC (rev 
51763)
+++ brlcad/trunk/src/tclscripts/lib/tclIndex    2012-08-05 03:19:33 UTC (rev 
51764)
@@ -1123,6 +1123,7 @@
 set auto_index(::cadwidgets::Ged::get_vdraw_color) [list source [file join 
$dir Ged.tcl]]
 set auto_index(::cadwidgets::Ged::glob) [list source [file join $dir Ged.tcl]]
 set auto_index(::cadwidgets::Ged::gqa) [list source [file join $dir Ged.tcl]]
+set auto_index(::cadwidgets::Ged::graph_objects_positions) [list source [file 
join $dir Ged.tcl]]
 set auto_index(::cadwidgets::Ged::grid) [list source [file join $dir Ged.tcl]]
 set auto_index(::cadwidgets::Ged::gridEnable) [list source [file join $dir 
Ged.tcl]]
 set auto_index(::cadwidgets::Ged::gridSnap) [list source [file join $dir 
Ged.tcl]]

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


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to