Revision: 46340
          http://brlcad.svn.sourceforge.net/brlcad/?rev=46340&view=rev
Author:   abhi2011
Date:     2011-08-23 16:10:06 +0000 (Tue, 23 Aug 2011)
Log Message:
-----------
stub for 2 files moved to simulate dir

Modified Paths:
--------------
    brlcad/trunk/src/libged/CMakeLists.txt

Added Paths:
-----------
    brlcad/trunk/src/libged/simulate/simphysics.cpp
    brlcad/trunk/src/libged/simulate/simulate.c

Removed Paths:
-------------
    brlcad/trunk/src/libged/simphysics.cpp
    brlcad/trunk/src/libged/simulate.c

Modified: brlcad/trunk/src/libged/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libged/CMakeLists.txt      2011-08-23 16:03:54 UTC (rev 
46339)
+++ brlcad/trunk/src/libged/CMakeLists.txt      2011-08-23 16:10:06 UTC (rev 
46340)
@@ -212,8 +212,8 @@
     shells.c
     showmats.c
     size.c
-    simulate.c
-    simphysics.cpp
+    simulate/simulate.c
+    simulate/simphysics.cpp
     slew.c
     solids_on_ray.c
     sphgroup.c

Deleted: brlcad/trunk/src/libged/simphysics.cpp
===================================================================
--- brlcad/trunk/src/libged/simphysics.cpp      2011-08-23 16:03:54 UTC (rev 
46339)
+++ brlcad/trunk/src/libged/simphysics.cpp      2011-08-23 16:10:06 UTC (rev 
46340)
@@ -1,55 +0,0 @@
-/*                          S I M P H Y S I C S . C P P
- * BRL-CAD
- *
- * Copyright (c) 2008-2011 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- */
-/** @file libged/simphysics.cpp
- *
- *
- * Routines related to performing a single step of physics on passed objects
- *
- * 
- * 
- */
-
-#include <iostream>
-
-#include "common.h"
-#include "db.h"
-
-/**
- * C++ wrapper for doing physics using bullet : Doesn't have any significant 
physics code yet
- * 
- */
-extern "C" int
-single_step_sim(struct bu_vls *result_str, int argc, const char *argv[])
-{
-        bu_vls_printf(result_str, "%s: In physics\n", argv[0]);
-        
-        
-        return 0;
-}
-
-/*
- * Local Variables:
- * tab-width: 8
- * mode: C++
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */

Copied: brlcad/trunk/src/libged/simulate/simphysics.cpp (from rev 46326, 
brlcad/trunk/src/libged/simphysics.cpp)
===================================================================
--- brlcad/trunk/src/libged/simulate/simphysics.cpp                             
(rev 0)
+++ brlcad/trunk/src/libged/simulate/simphysics.cpp     2011-08-23 16:10:06 UTC 
(rev 46340)
@@ -0,0 +1,55 @@
+/*                          S I M P H Y S I C S . C P P
+ * BRL-CAD
+ *
+ * Copyright (c) 2008-2011 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file libged/simphysics.cpp
+ *
+ *
+ * Routines related to performing a single step of physics on passed objects
+ *
+ * 
+ * 
+ */
+
+#include <iostream>
+
+#include "common.h"
+#include "db.h"
+
+/**
+ * C++ wrapper for doing physics using bullet : Doesn't have any significant 
physics code yet
+ * 
+ */
+extern "C" int
+single_step_sim(struct bu_vls *result_str, int argc, const char *argv[])
+{
+        bu_vls_printf(result_str, "%s: In physics\n", argv[0]);
+        
+        
+        return 0;
+}
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C++
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */

Copied: brlcad/trunk/src/libged/simulate/simulate.c (from rev 46326, 
brlcad/trunk/src/libged/simulate.c)
===================================================================
--- brlcad/trunk/src/libged/simulate/simulate.c                         (rev 0)
+++ brlcad/trunk/src/libged/simulate/simulate.c 2011-08-23 16:10:06 UTC (rev 
46340)
@@ -0,0 +1,178 @@
+/*                         S I M U L A T E . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2008-2011 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file libged/simulate.c
+ *
+ * The simulate command.
+ *
+ * Routines related to performing physics on passed objects only
+ *
+ * TODO:
+ *   Insert Bullet code in the simphysics.cpp file and link to libs
+ *   Add time option, frequency etc
+ *
+ * 
+ */
+
+#include "common.h"
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <math.h>
+#include <string.h>
+#include "bio.h"
+
+#include "vmath.h"
+#include "db.h"
+#include "raytrace.h"
+#include "./ged_private.h"
+
+
+extern int single_step_sim(struct bu_vls *result_str, int argc, const char 
*argv[]);
+
+
+/**
+ * How to use simulate.Blissfully simple interface, more options will be added 
soon
+ */
+static void
+print_usage(struct bu_vls *str)
+{
+    bu_vls_printf(str, "Usage: simulate [-nft] <object>\n\n");
+    bu_vls_printf(str, "-n <n> <x> <y> <z>\t- Specifies number of steps.\n");
+    bu_vls_printf(str, "-f <n> <x> <y> <z>\t- Specifies frequency of update(eg 
1/60 Hz)\n");
+    bu_vls_printf(str, "-t <x> <y> <z>\t\t  - Specifies time for which to 
run(alternative to -n).\n");
+    bu_vls_printf(str, "-v\t\t\t- Prints version info.\n");
+    return;
+}
+
+
+/**
+ * The physics simulation function
+ */
+int
+ged_simulate(struct ged *gedp, int argc, const char *argv[])
+{
+    struct directory *ndp;
+    int i, rv;
+    struct rt_db_internal intern;
+    static const char *transf_shape_name = "Transformed_Shape";
+    static const char *usage = "object(s)";
+    char *cmd_args[5], result_str[100];
+    mat_t t;
+
+    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);
+
+    /* Must be wanting help */
+    if (argc == 1) {
+       print_usage(gedp->ged_result_str);
+       return GED_HELP;
+    }
+
+    if (argc < 2) {
+       bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
+       return GED_ERROR;
+    }
+    
+    /* First duplicate the passed shape, so the original is untouched */
+    /* Check if the duplicate exists, and kill it if so */
+    if (db_lookup(gedp->ged_wdbp->dbip, transf_shape_name, LOOKUP_QUIET) != 
RT_DIR_NULL) {
+       cmd_args[0] = "sim_kill";
+        cmd_args[1] = (char *)transf_shape_name;
+        cmd_args[2] = (char *)0;
+        if(ged_kill(gedp, 2, (const char **)cmd_args) != GED_OK){
+            bu_vls_printf(gedp->ged_result_str, "%s: could not delete existing 
%s", argv[0], transf_shape_name);
+           return GED_ERROR;
+       }
+       bu_vls_printf(gedp->ged_result_str, "%s: %s already exists, deleting 
it",  argv[0], transf_shape_name); 
+    }
+   
+    /* Copy the shape, clone is required for combinations(full tree copy) : 
TODO */
+    cmd_args[0] = "sim_copy";
+    cmd_args[1] = (char *)argv[1];             
+    cmd_args[2] = (char *)transf_shape_name;
+    cmd_args[3] = (char *)0;
+    rv = ged_copy(gedp, 3, (const char **)cmd_args);
+    if (rv != GED_OK)
+       bu_vls_printf(gedp->ged_result_str, "%s: WARNING: Failure cloning 
\"%s\" to \"%s\"\n", argv[0],
+       argv[1], transf_shape_name);    
+       
+    
+    /* Setup translation matrix of 1m in X for testing */
+    t[0]  = 1; t[1]  = 0; t[2]  = 0; t[3]  = 1000;
+    t[4]  = 0; t[5]  = 1; t[6]  = 0; t[7]  = 0;
+    t[8]  = 0; t[9]  = 0; t[10] = 1; t[11] = 0;
+    t[12] = 0; t[13] = 0; t[14] = 0; t[15] = 1;
+    
+    /* Loop not correct as of now, only 1 primitive can be transformed, but no 
error as argc=2 */
+    for (i = 1; i < argc; i++) {
+       if ((ndp = db_lookup(gedp->ged_wdbp->dbip,  transf_shape_name, 
LOOKUP_NOISY)) == RT_DIR_NULL){
+            bu_vls_printf(gedp->ged_result_str, "%s: Error db_lookup(%s) 
failed ! \n", argv[0], 
+            transf_shape_name);
+            return GED_ERROR;
+        }
+        
+        /* Get the internal representation of the object passed by the user */
+        GED_DB_GET_INTERNAL(gedp, &intern, ndp, bn_mat_identity, 
&rt_uniresource, GED_ERROR);
+       
+        bu_vls_printf(gedp->ged_result_str, "%s: Moving primitive : %s\n", 
argv[0], argv[i]);
+       
+        /* This is the cpp function with Bullet code, will be modified later 
to pass transformation 
+           matrices to and fro */  
+        rv = single_step_sim(gedp->ged_result_str, argc, argv);
+        bu_vls_printf(gedp->ged_result_str, "%s: Single step : \n%s\n", 
argv[0], result_str);
+          
+        /* Do the matrix transform which will be output from single_step_sim() 
*/
+        if (rt_matrix_transform(&intern, t, &intern, 0, gedp->ged_wdbp->dbip, 
&rt_uniresource) < 0){ 
+           bu_vls_printf(gedp->ged_result_str, "%s: ERROR rt_matrix_transform 
failed !\n", argv[0]);
+           return GED_ERROR;
+        }
+        
+        /* Write the modified solid to the db so it can be redrawn at the new 
position & orientation by Mged */        
+        if (rt_db_put_internal(ndp, gedp->ged_wdbp->dbip, &intern, 
&rt_uniresource) < 0) {
+            bu_vls_printf(gedp->ged_result_str, "%s: Database write error, 
aborting\n", argv[0]);
+            return GED_ERROR;
+        }
+        
+        bu_vls_printf(gedp->ged_result_str, "%s: Simulation result is in  
primitive : %s\n", 
+                                                                    argv[0], 
transf_shape_name); 
+                                                     
+        /* Draw the result : inserting it in argv[1] will cause it to be 
automatically drawn in cmd_wrapper */
+       argv[1] = (char *)transf_shape_name;
+       argv[2] = (char *)0;
+       
+    }
+   
+
+    return GED_OK;
+}
+
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */

Deleted: brlcad/trunk/src/libged/simulate.c
===================================================================
--- brlcad/trunk/src/libged/simulate.c  2011-08-23 16:03:54 UTC (rev 46339)
+++ brlcad/trunk/src/libged/simulate.c  2011-08-23 16:10:06 UTC (rev 46340)
@@ -1,178 +0,0 @@
-/*                         S I M U L A T E . C
- * BRL-CAD
- *
- * Copyright (c) 2008-2011 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- */
-/** @file libged/simulate.c
- *
- * The simulate command.
- *
- * Routines related to performing physics on passed objects only
- *
- * TODO:
- *   Insert Bullet code in the simphysics.cpp file and link to libs
- *   Add time option, frequency etc
- *
- * 
- */
-
-#include "common.h"
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <math.h>
-#include <string.h>
-#include "bio.h"
-
-#include "vmath.h"
-#include "db.h"
-#include "raytrace.h"
-#include "./ged_private.h"
-
-
-extern int single_step_sim(struct bu_vls *result_str, int argc, const char 
*argv[]);
-
-
-/**
- * How to use simulate.Blissfully simple interface, more options will be added 
soon
- */
-static void
-print_usage(struct bu_vls *str)
-{
-    bu_vls_printf(str, "Usage: simulate [-nft] <object>\n\n");
-    bu_vls_printf(str, "-n <n> <x> <y> <z>\t- Specifies number of steps.\n");
-    bu_vls_printf(str, "-f <n> <x> <y> <z>\t- Specifies frequency of update(eg 
1/60 Hz)\n");
-    bu_vls_printf(str, "-t <x> <y> <z>\t\t  - Specifies time for which to 
run(alternative to -n).\n");
-    bu_vls_printf(str, "-v\t\t\t- Prints version info.\n");
-    return;
-}
-
-
-/**
- * The physics simulation function
- */
-int
-ged_simulate(struct ged *gedp, int argc, const char *argv[])
-{
-    struct directory *ndp;
-    int i, rv;
-    struct rt_db_internal intern;
-    static const char *transf_shape_name = "Transformed_Shape";
-    static const char *usage = "object(s)";
-    char *cmd_args[5], result_str[100];
-    mat_t t;
-
-    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);
-
-    /* Must be wanting help */
-    if (argc == 1) {
-       print_usage(gedp->ged_result_str);
-       return GED_HELP;
-    }
-
-    if (argc < 2) {
-       bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
-       return GED_ERROR;
-    }
-    
-    /* First duplicate the passed shape, so the original is untouched */
-    /* Check if the duplicate exists, and kill it if so */
-    if (db_lookup(gedp->ged_wdbp->dbip, transf_shape_name, LOOKUP_QUIET) != 
RT_DIR_NULL) {
-       cmd_args[0] = "sim_kill";
-        cmd_args[1] = (char *)transf_shape_name;
-        cmd_args[2] = (char *)0;
-        if(ged_kill(gedp, 2, (const char **)cmd_args) != GED_OK){
-            bu_vls_printf(gedp->ged_result_str, "%s: could not delete existing 
%s", argv[0], transf_shape_name);
-           return GED_ERROR;
-       }
-       bu_vls_printf(gedp->ged_result_str, "%s: %s already exists, deleting 
it",  argv[0], transf_shape_name); 
-    }
-   
-    /* Copy the shape, clone is required for combinations(full tree copy) : 
TODO */
-    cmd_args[0] = "sim_copy";
-    cmd_args[1] = (char *)argv[1];             
-    cmd_args[2] = (char *)transf_shape_name;
-    cmd_args[3] = (char *)0;
-    rv = ged_copy(gedp, 3, (const char **)cmd_args);
-    if (rv != GED_OK)
-       bu_vls_printf(gedp->ged_result_str, "%s: WARNING: Failure cloning 
\"%s\" to \"%s\"\n", argv[0],
-       argv[1], transf_shape_name);    
-       
-    
-    /* Setup translation matrix of 1m in X for testing */
-    t[0]  = 1; t[1]  = 0; t[2]  = 0; t[3]  = 1000;
-    t[4]  = 0; t[5]  = 1; t[6]  = 0; t[7]  = 0;
-    t[8]  = 0; t[9]  = 0; t[10] = 1; t[11] = 0;
-    t[12] = 0; t[13] = 0; t[14] = 0; t[15] = 1;
-    
-    /* Loop not correct as of now, only 1 primitive can be transformed, but no 
error as argc=2 */
-    for (i = 1; i < argc; i++) {
-       if ((ndp = db_lookup(gedp->ged_wdbp->dbip,  transf_shape_name, 
LOOKUP_NOISY)) == RT_DIR_NULL){
-            bu_vls_printf(gedp->ged_result_str, "%s: Error db_lookup(%s) 
failed ! \n", argv[0], 
-            transf_shape_name);
-            return GED_ERROR;
-        }
-        
-        /* Get the internal representation of the object passed by the user */
-        GED_DB_GET_INTERNAL(gedp, &intern, ndp, bn_mat_identity, 
&rt_uniresource, GED_ERROR);
-       
-        bu_vls_printf(gedp->ged_result_str, "%s: Moving primitive : %s\n", 
argv[0], argv[i]);
-       
-        /* This is the cpp function with Bullet code, will be modified later 
to pass transformation 
-           matrices to and fro */  
-        rv = single_step_sim(gedp->ged_result_str, argc, argv);
-        bu_vls_printf(gedp->ged_result_str, "%s: Single step : \n%s\n", 
argv[0], result_str);
-          
-        /* Do the matrix transform which will be output from single_step_sim() 
*/
-        if (rt_matrix_transform(&intern, t, &intern, 0, gedp->ged_wdbp->dbip, 
&rt_uniresource) < 0){ 
-           bu_vls_printf(gedp->ged_result_str, "%s: ERROR rt_matrix_transform 
failed !\n", argv[0]);
-           return GED_ERROR;
-        }
-        
-        /* Write the modified solid to the db so it can be redrawn at the new 
position & orientation by Mged */        
-        if (rt_db_put_internal(ndp, gedp->ged_wdbp->dbip, &intern, 
&rt_uniresource) < 0) {
-            bu_vls_printf(gedp->ged_result_str, "%s: Database write error, 
aborting\n", argv[0]);
-            return GED_ERROR;
-        }
-        
-        bu_vls_printf(gedp->ged_result_str, "%s: Simulation result is in  
primitive : %s\n", 
-                                                                    argv[0], 
transf_shape_name); 
-                                                     
-        /* Draw the result : inserting it in argv[1] will cause it to be 
automatically drawn in cmd_wrapper */
-       argv[1] = (char *)transf_shape_name;
-       argv[2] = (char *)0;
-       
-    }
-   
-
-    return GED_OK;
-}
-
-
-/*
- * Local Variables:
- * tab-width: 8
- * mode: C
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */

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-d2d-2
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to