Revision: 57133
          http://sourceforge.net/p/brlcad/code/57133
Author:   phoenixyjll
Date:     2013-08-26 06:48:44 +0000 (Mon, 26 Aug 2013)
Log Message:
-----------
Tweak the brep command to support the other two operations (intersect and diff).

Modified Paths:
--------------
    brlcad/trunk/src/libged/brep.c
    brlcad/trunk/src/librt/primitives/brep/brep.cpp

Modified: brlcad/trunk/src/libged/brep.c
===================================================================
--- brlcad/trunk/src/libged/brep.c      2013-08-26 06:33:28 UTC (rev 57132)
+++ brlcad/trunk/src/libged/brep.c      2013-08-26 06:48:44 UTC (rev 57133)
@@ -51,7 +51,7 @@
 RT_EXPORT extern int brep_intersect_curve_curve(struct rt_db_internal 
*intern1, struct rt_db_internal *intern2, int i, int j);
 RT_EXPORT extern int brep_intersect_curve_surface(struct rt_db_internal 
*intern1, struct rt_db_internal *intern2, int i, int j);
 RT_EXPORT extern int brep_intersect_surface_surface(struct rt_db_internal 
*intern1, struct rt_db_internal *intern2, int i, int j, struct bn_vlblock *vbp);
-RT_EXPORT extern int rt_brep_boolean(struct rt_db_internal *out, const struct 
rt_db_internal *ip1, const struct rt_db_internal *ip2, const enum op_type 
operation);
+RT_EXPORT extern int rt_brep_boolean(struct rt_db_internal *out, const struct 
rt_db_internal *ip1, const struct rt_db_internal *ip2, const char* operation);
 
 
 int
@@ -176,13 +176,17 @@
        return GED_OK;
     }
 
-    if (BU_STR_EQUAL(argv[2], "u")) {
-       /* test booleans on brep, just union here */
+    if (BU_STR_EQUAL(argv[2], "u") || BU_STR_EQUAL(argv[2], "i") || 
BU_STR_EQUAL(argv[2], "-")) {
+       /* test booleans on brep.
+        * u: union, i: intersect, -: diff
+        */
        struct rt_db_internal intern2, intern_res;
        struct rt_brep_internal *bip;
 
-       if (argc != 5)
+       if (argc != 5) {
+           bu_vls_printf(gedp->ged_result_str, "Error: There should be exactly 
5 params.\n");
            return GED_ERROR;
+       }
 
        /* get the other solid */
        if ((ndp = db_lookup(gedp->ged_wdbp->dbip,  argv[3], LOOKUP_NOISY)) == 
RT_DIR_NULL) {
@@ -200,7 +204,7 @@
 
        GED_DB_GET_INTERNAL(gedp, &intern2, ndp, bn_mat_identity, 
&rt_uniresource, GED_ERROR);
 
-       rt_brep_boolean(&intern_res, &intern, &intern2, 0);
+       rt_brep_boolean(&intern_res, &intern, &intern2, argv[2]);
        bip = (struct rt_brep_internal*)intern_res.idb_ptr;
        mk_brep(gedp->ged_wdbp, argv[4], bip->brep);
        rt_db_free_internal(&intern);

Modified: brlcad/trunk/src/librt/primitives/brep/brep.cpp
===================================================================
--- brlcad/trunk/src/librt/primitives/brep/brep.cpp     2013-08-26 06:33:28 UTC 
(rev 57132)
+++ brlcad/trunk/src/librt/primitives/brep/brep.cpp     2013-08-26 06:48:44 UTC 
(rev 57133)
@@ -91,7 +91,7 @@
     int rt_brep_tclget(Tcl_Interp *interp, const struct rt_db_internal 
*intern, const char *attr);
     int rt_brep_tcladjust(Tcl_Interp *interp, struct rt_db_internal *intern, 
int argc, const char **argv);
     int rt_brep_params(struct pc_pc_set *, const struct rt_db_internal *ip);
-    RT_EXPORT extern int rt_brep_boolean(struct rt_db_internal *out, const 
struct rt_db_internal *ip1, const struct rt_db_internal *ip2, const enum 
op_type operation);
+    RT_EXPORT extern int rt_brep_boolean(struct rt_db_internal *out, const 
struct rt_db_internal *ip1, const struct rt_db_internal *ip2, const char* 
operation);
 #ifdef __cplusplus
 }
 #endif
@@ -4065,7 +4065,7 @@
 
 
 int
-rt_brep_boolean(struct rt_db_internal *out, const struct rt_db_internal *ip1, 
const struct rt_db_internal *ip2, const enum op_type operation)
+rt_brep_boolean(struct rt_db_internal *out, const struct rt_db_internal *ip1, 
const struct rt_db_internal *ip2, const char* operation)
 {
     RT_CK_DB_INTERNAL(ip1);
     RT_CK_DB_INTERNAL(ip2);
@@ -4081,7 +4081,17 @@
     brep_out = ON_Brep::New();
 
     int ret;
-    if ((ret = ON_Boolean(brep_out, brep1, brep2, operation)) < 0)
+    op_type operation_type;
+    if (BU_STR_EQUAL(operation, "u"))
+       operation_type = BOOLEAN_UNION;
+    else if (BU_STR_EQUAL(operation, "i"))
+       operation_type = BOOLEAN_INTERSECT;
+    else if (BU_STR_EQUAL(operation, "-"))
+       operation_type = BOOLEAN_DIFF;
+    else
+       return -1;
+
+    if ((ret = ON_Boolean(brep_out, brep1, brep2, operation_type)) < 0)
        return ret;
 
     // make the final rt_db_internal

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


------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to