Revision: 45840
          http://brlcad.svn.sourceforge.net/brlcad/?rev=45840&view=rev
Author:   brlcad
Date:     2011-08-09 16:31:56 +0000 (Tue, 09 Aug 2011)

Log Message:
-----------
help prevent crashing if the data file cannot be found, validate before trying 
to use the mapped file.  this should be using dsp_get_data() instead of 
replicating logic.

Modified Paths:
--------------
    brlcad/trunk/src/librt/primitives/dsp/dsp_brep.cpp

Modified: brlcad/trunk/src/librt/primitives/dsp/dsp_brep.cpp
===================================================================
--- brlcad/trunk/src/librt/primitives/dsp/dsp_brep.cpp  2011-08-09 16:12:03 UTC 
(rev 45839)
+++ brlcad/trunk/src/librt/primitives/dsp/dsp_brep.cpp  2011-08-09 16:31:56 UTC 
(rev 45840)
@@ -37,26 +37,19 @@
 rt_dsp_brep(ON_Brep **b, const struct rt_db_internal *ip, const struct bn_tol 
*)
 {
     struct rt_dsp_internal *dsp_ip;
-    struct bu_mapped_file *mf;
 
+    if (!b)
+       return;
+
     RT_CK_DB_INTERNAL(ip);
     dsp_ip = (struct rt_dsp_internal *)ip->idb_ptr;
     RT_DSP_CK_MAGIC(dsp_ip);
+    *b = NULL;
 
-    int in_cookie = bu_cv_cookie("nus");
-    int out_cookie = bu_cv_cookie("hus");
-    mf = dsp_ip->dsp_mp = bu_open_mapped_file(bu_vls_addr(&dsp_ip->dsp_name), 
"dsp");
-    int count = dsp_ip->dsp_xcnt * dsp_ip->dsp_ycnt;
-    mf->apbuflen = count * sizeof(unsigned short);
-    mf->apbuf = bu_malloc(mf->apbuflen, "apbuf");
-    bu_cv_w_cookie(mf->apbuf, out_cookie, mf->apbuflen, mf->buf, in_cookie, 
count);
-    dsp_ip->dsp_buf = (short unsigned int*)mf->apbuf;
-
-    *b = ON_Brep::New();
-
     switch (dsp_ip->dsp_datasrc) {
        case RT_DSP_SRC_V4_FILE:
        case RT_DSP_SRC_FILE:
+           dsp_ip->dsp_mp = 
bu_open_mapped_file(bu_vls_addr(&dsp_ip->dsp_name), "dsp");
            if (!dsp_ip->dsp_mp) {
                bu_log("WARNING: Cannot find data file for displacement map 
(DSP)\n");
                if (bu_vls_addr(&dsp_ip->dsp_name)) {
@@ -83,6 +76,7 @@
            break;
     }
 
+    *b = ON_Brep::New();
 
     // dsp.c defines utility functions for pulling dsp data - this seems like 
a good plan.
 # define DSP(_p, _x, _y) (\


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

------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  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