[brlcad-commits] SF.net SVN: brlcad:[70116] brlcad/trunk/src/librt/primitives

2017-08-23 Thread brlcad--- via brlcad-commits
Revision: 70116
  http://sourceforge.net/p/brlcad/code/70116
Author:   brlcad
Date: 2017-08-24 05:36:47 + (Thu, 24 Aug 2017)
Log Message:
---
slew of object callback cleanup to get the right signatures.  converted table.c 
to table.cpp in order for the ON_Brep param on the brep callback to not be an 
aliasing mismatch during link time optimization.  eliminated resp from a few 
stray import/export functions.

Modified Paths:
--
brlcad/trunk/src/librt/primitives/arb8/arb8.c
brlcad/trunk/src/librt/primitives/bot/bot.c
brlcad/trunk/src/librt/primitives/brep/brep.cpp
brlcad/trunk/src/librt/primitives/bspline/bspline.cpp
brlcad/trunk/src/librt/primitives/dsp/dsp.c
brlcad/trunk/src/librt/primitives/extrude/extrude.c
brlcad/trunk/src/librt/primitives/half/half.c
brlcad/trunk/src/librt/primitives/hrt/hrt.c
brlcad/trunk/src/librt/primitives/revolve/revolve.c
brlcad/trunk/src/librt/primitives/vol/vol_brep.cpp

Added Paths:
---
brlcad/trunk/src/librt/primitives/table.cpp

Removed Paths:
-
brlcad/trunk/src/librt/primitives/table.c

Modified: brlcad/trunk/src/librt/primitives/arb8/arb8.c
===
--- brlcad/trunk/src/librt/primitives/arb8/arb8.c   2017-08-24 05:21:17 UTC 
(rev 70115)
+++ brlcad/trunk/src/librt/primitives/arb8/arb8.c   2017-08-24 05:36:47 UTC 
(rev 70116)
@@ -1192,25 +1192,9 @@
 
 
 int
-rt_arb_class(const struct soltab *stp, const fastf_t *min, const fastf_t *max, 
const struct bn_tol *tol)
+rt_arb_class(const struct soltab *UNUSED(stp), const fastf_t *UNUSED(min), 
const fastf_t *UNUSED(max), const struct bn_tol *UNUSED(tol))
 {
-register struct arb_specific *arbp =
-   (struct arb_specific *)stp->st_specific;
-register int i;
-
-if (arbp == (struct arb_specific *)0) {
-   bu_log("arb(%s): no faces\n", stp->st_name);
-   return BN_CLASSIFY_UNIMPLEMENTED;
-}
-
-for (i = 0; i < arbp->arb_nmfaces; i++) {
-   if (bn_hlf_class(arbp->arb_face[i].peqn, min, max, tol) ==
-   BN_CLASSIFY_OUTSIDE)
-   return BN_CLASSIFY_OUTSIDE;
-}
-
-/* FIXME: We need to test for BN_CLASSIFY_INSIDE vs. 
BN_CLASSIFY_OVERLAPPING! */
-return BN_CLASSIFY_UNIMPLEMENTED; /* let the caller assume the worst */
+return 0;
 }
 
 

Modified: brlcad/trunk/src/librt/primitives/bot/bot.c
===
--- brlcad/trunk/src/librt/primitives/bot/bot.c 2017-08-24 05:21:17 UTC (rev 
70115)
+++ brlcad/trunk/src/librt/primitives/bot/bot.c 2017-08-24 05:36:47 UTC (rev 
70116)
@@ -420,7 +420,7 @@
  * Calculate an RPP for a BoT
  */
 int
-rt_bot_bbox(struct rt_db_internal *ip, point_t *min, point_t *max) {
+rt_bot_bbox(struct rt_db_internal *ip, point_t *min, point_t *max, const 
struct bn_tol *UNUSED(tol)) {
 struct rt_bot_internal *bot_ip;
 size_t tri_index;
 point_t p1, p2, p3;
@@ -491,7 +491,7 @@
rt_bot_mintie = atoi(getenv("LIBRT_BOT_MINTIE"));
 }
 
-if (rt_bot_bbox(ip, &(stp->st_min), &(stp->st_max))) return 1;
+if (rt_bot_bbox(ip, &(stp->st_min), &(stp->st_max), &(rtip->rti_tol))) 
return 1;
 
 if (rt_bot_mintie > 0 && bot_ip->num_faces >= rt_bot_mintie /* FIXME: 
(necessary?) && (bot_ip->face_normals != NULL || bot_ip->orientation != 
RT_BOT_UNORIENTED) */)
ret = bottie_prep_double(stp, bot_ip, rtip);
@@ -870,7 +870,7 @@
 
 fold_data.root = vertex_tree;
 fold_data.point_spacing = info->point_spacing;
-(void)rt_bot_bbox(ip, , );
+(void)rt_bot_bbox(ip, , , NULL);
 d1 = max[0] - min[0];
 d2 = max[1] - min[1];
 d3 = max[2] - min[2];
@@ -913,7 +913,7 @@
 }
 
 int
-rt_bot_plot(struct bu_list *vhead, struct rt_db_internal *ip, const struct 
rt_tess_tol *UNUSED(ttol), const struct bn_tol *UNUSED(tol), const struct 
rt_view_info *info)
+rt_bot_plot(struct bu_list *vhead, struct rt_db_internal *ip, const struct 
rt_tess_tol *UNUSED(ttol), const struct bn_tol *tol, const struct rt_view_info 
*info)
 {
 struct rt_bot_internal *bot_ip;
 size_t i;
@@ -939,7 +939,7 @@
 } else {
/* too big - just draw the bbox */
point_t min, max;
-   (void)rt_bot_bbox(ip, , );
+   (void)rt_bot_bbox(ip, , , tol);
BOT_BB_PLOT_VLIST(min, max);
 }
 
@@ -1806,7 +1806,7 @@
 
 
 int
-rt_bot_xform(struct rt_db_internal *op, const fastf_t *mat, struct 
rt_db_internal *ip, const int release, struct db_i *dbip)
+rt_bot_xform(struct rt_db_internal *op, const fastf_t *mat, struct 
rt_db_internal *ip, const int release, struct db_i *dbip, struct resource 
*UNUSED(resp))
 {
 struct rt_bot_internal *botip, *botop;
 size_t i;

Modified: brlcad/trunk/src/librt/primitives/brep/brep.cpp
===
--- brlcad/trunk/src/librt/primitives/brep/brep.cpp 2017-08-24 05:21:17 UTC 
(rev 70115)
+++ 

[brlcad-commits] SF.net SVN: brlcad:[70115] brlcad/trunk/src/librt/primitives/annot/annot.c

2017-08-23 Thread brlcad--- via brlcad-commits
Revision: 70115
  http://sourceforge.net/p/brlcad/code/70115
Author:   brlcad
Date: 2017-08-24 05:21:17 + (Thu, 24 Aug 2017)
Log Message:
---
initialize points before use

Modified Paths:
--
brlcad/trunk/src/librt/primitives/annot/annot.c

Modified: brlcad/trunk/src/librt/primitives/annot/annot.c
===
--- brlcad/trunk/src/librt/primitives/annot/annot.c 2017-08-24 03:06:16 UTC 
(rev 70114)
+++ brlcad/trunk/src/librt/primitives/annot/annot.c 2017-08-24 05:21:17 UTC 
(rev 70115)
@@ -322,7 +322,8 @@
 struct nurb_seg *nsg;
 struct bezier_seg *bsg;
 fastf_t delta;
-point_t center, start_pt;
+point_t center = VINIT_ZERO;
+point_t start_pt = VINIT_ZERO;
 fastf_t pt[4];
 vect_t semi_a, semi_b;
 fastf_t radius;

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


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits


[brlcad-commits] SF.net SVN: brlcad:[70114] brlcad/trunk/doc/README.Solaris

2017-08-23 Thread starseeker--- via brlcad-commits
Revision: 70114
  http://sourceforge.net/p/brlcad/code/70114
Author:   starseeker
Date: 2017-08-24 03:06:16 + (Thu, 24 Aug 2017)
Log Message:
---
Add a few notes about OpenIndiana

Modified Paths:
--
brlcad/trunk/doc/README.Solaris

Modified: brlcad/trunk/doc/README.Solaris
===
--- brlcad/trunk/doc/README.Solaris 2017-08-23 23:25:20 UTC (rev 70113)
+++ brlcad/trunk/doc/README.Solaris 2017-08-24 03:06:16 UTC (rev 70114)
@@ -42,3 +42,20 @@
 with the CMake build logic and should be reported as a bug - you may also
 need to install a shared version of the library.  Another possibility
 would be to add -mipure-text to the linker flags.
+
+OpenIndiana
+---
+
+To build with gcc and CMake on OpenIndiana, you need to install the
+following packages:
+
+pkg install pkg:/developer/gcc-7
+pkg install pkg:/developer/build/cmake
+pkg install pkg:/developer/versioning/subversion
+pkg install pkg:/system/header
+pkg install pkg:/developer/lexer/flex
+
+(Note that gcc-7 building doesn't work as of 2017-08-23 - the above
+install list is a starting point, but the repo currently doesn't
+build and isn't close to building.  It may be an older gcc would
+have better luck...)

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


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits


[brlcad-commits] SF.net SVN: brlcad:[70112] brlcad/trunk/include/rt/db_io.h

2017-08-23 Thread brlcad--- via brlcad-commits
Revision: 70112
  http://sourceforge.net/p/brlcad/code/70112
Author:   brlcad
Date: 2017-08-23 23:21:52 + (Wed, 23 Aug 2017)
Log Message:
---
rt_extrude_import5 is a private implementation function, shouldn't be in public 
header.

Modified Paths:
--
brlcad/trunk/include/rt/db_io.h

Modified: brlcad/trunk/include/rt/db_io.h
===
--- brlcad/trunk/include/rt/db_io.h 2017-08-23 19:58:38 UTC (rev 70111)
+++ brlcad/trunk/include/rt/db_io.h 2017-08-23 23:21:52 UTC (rev 70112)
@@ -636,10 +636,6 @@
 RT_EXPORT extern int rt_db_flip_endian(struct db_i *dbip);
 
 
-/* extrude.c */
-RT_EXPORT extern int rt_extrude_import5(struct rt_db_internal *ip, const 
struct bu_external *ep, const mat_t mat, const struct db_i *dbip, struct 
resource *resp);
-
-
 /**
  * "open" an in-memory-only database instance.  this initializes a
  * dbip for use, creating an inmem dbi_wdbp as the means to add
@@ -647,6 +643,7 @@
  */
 RT_EXPORT extern struct db_i * db_open_inmem(void);
 
+
 /**
  * creates an in-memory-only database.  this is very similar to
  * db_open_inmem() with the exception that the this routine adds a

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


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits


[brlcad-commits] SF.net SVN: brlcad:[70113] brlcad/trunk/src/librt/primitives/dsp/dsp.c

2017-08-23 Thread brlcad--- via brlcad-commits
Revision: 70113
  http://sourceforge.net/p/brlcad/code/70113
Author:   brlcad
Date: 2017-08-23 23:25:20 + (Wed, 23 Aug 2017)
Log Message:
---
rt_binuif_describe doesn't take a resource and dbi pointer

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

Modified: brlcad/trunk/src/librt/primitives/dsp/dsp.c
===
--- brlcad/trunk/src/librt/primitives/dsp/dsp.c 2017-08-23 23:21:52 UTC (rev 
70112)
+++ brlcad/trunk/src/librt/primitives/dsp/dsp.c 2017-08-23 23:25:20 UTC (rev 
70113)
@@ -4095,7 +4095,7 @@
 
 
 /* FIXME, not publicly exposed anywhere as it's a non-geom object */
-extern int rt_binunif_describe(struct bu_vls *str, const struct rt_db_internal 
*ip, int verbose, double mm2local, struct resource *resp, struct db_i *db_i);
+extern int rt_binunif_describe(struct bu_vls *str, const struct rt_db_internal 
*ip, int verbose, double mm2local);
 
 
 /**
@@ -4134,7 +4134,7 @@
size_t i = 0;
size_t size;
struct bu_vls binudesc = BU_VLS_INIT_ZERO;
-   rt_binunif_describe(, dsp_ip->dsp_bip, 0, 
dbip->dbi_base2local, NULL, (struct db_i *)dbip);
+   rt_binunif_describe(, dsp_ip->dsp_bip, 0, 
dbip->dbi_base2local);
 
/* skip the first title line */
size = bu_vls_strlen();

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


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits


[brlcad-commits] SF.net SVN: brlcad:[70111] brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp

2017-08-23 Thread starseeker--- via brlcad-commits
Revision: 70111
  http://sourceforge.net/p/brlcad/code/70111
Author:   starseeker
Date: 2017-08-23 19:58:38 + (Wed, 23 Aug 2017)
Log Message:
---
Flip the data xy to match the dem-g import - not sure if that's right, but 
might as well go for consistency right now...

Modified Paths:
--
brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp

Modified: brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp
===
--- brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp   2017-08-23 19:31:25 UTC 
(rev 70110)
+++ brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp   2017-08-23 19:58:38 UTC 
(rev 70111)
@@ -122,7 +122,7 @@
 
 if (!bu_file_exists(data,NULL)) return 0;
 
-hDataset = GDALOpenEx(data, GDAL_OF_READONLY | GDAL_OF_RASTER | 
GDAL_OF_VERBOSE_ERROR, NULL, NULL, NULL);
+hDataset = GDALOpenEx(data, GDAL_OF_READONLY | GDAL_OF_RASTER , NULL, 
NULL, NULL);
 
 if (!hDataset) return 0;
 
@@ -133,7 +133,7 @@
 
 HIDDEN int
 gdal_read(struct gcv_context *context, const struct gcv_opts *gcv_options,
-  const void *options_data, const char *source_path)
+   const void *options_data, const char *source_path)
 {
 struct conversion_state *state;
 BU_GET(state, struct conversion_state);
@@ -177,7 +177,7 @@
for (int j = 0; j < GDALGetRasterBandXSize(band); ++j) {
/* This is the critical assignment point - if we get this
 * indexing wrong, data will not look right in dsp */
-   uint16_array[i*ysize+j] = scanline[j];
+   uint16_array[(ysize-i-1)*ysize+j] = scanline[j];
}
}
 }

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


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits


[brlcad-commits] SF.net SVN: brlcad:[70109] brlcad/trunk/src/libwdb/wdb.c

2017-08-23 Thread starseeker--- via brlcad-commits
Revision: 70109
  http://sourceforge.net/p/brlcad/code/70109
Author:   starseeker
Date: 2017-08-23 19:20:47 + (Wed, 23 Aug 2017)
Log Message:
---
Sean debugged in-memory binunif object creation.  Apparently this code path had 
never been tested, because there were multiple problems (failed to copy the 
data, incorrect object type assignments.)  This gets things working.

Modified Paths:
--
brlcad/trunk/src/libwdb/wdb.c

Modified: brlcad/trunk/src/libwdb/wdb.c
===
--- brlcad/trunk/src/libwdb/wdb.c   2017-08-23 18:08:34 UTC (rev 70108)
+++ brlcad/trunk/src/libwdb/wdb.c   2017-08-23 19:20:47 UTC (rev 70109)
@@ -629,6 +629,7 @@
 wdb_binunif data_type,
 long count)
 {
+struct rt_db_internal intern;
 struct rt_binunif_internal *binunif;
 unsigned int minor_type = 0;
 int from_file = 0;
@@ -819,8 +820,15 @@
 binunif->magic = RT_BINUNIF_INTERNAL_MAGIC;
 binunif->type = minor_type;
 binunif->count = count;
+binunif->u.int8 = (char *)bu_malloc(count * bytes, "init binunif 
container");
+
+RT_DB_INTERNAL_INIT();
+intern.idb_major_type = DB5_MAJORTYPE_BINARY_UNIF;
+intern.idb_type = minor_type;
+intern.idb_ptr = (void*)binunif;
+intern.idb_meth = [ID_BINUNIF];
 memcpy(binunif->u.int8, data, count * bytes);
-return wdb_export(wdbp, name, (void *)binunif, ID_BINUNIF, mk_conv2mm);
+return wdb_put_internal(wdbp, name, , mk_conv2mm);
 }
 
 

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


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits


[brlcad-commits] SF.net SVN: brlcad:[70108] brlcad/trunk/src/librt/binunif/db5_bin.c

2017-08-23 Thread brlcad--- via brlcad-commits
Revision: 70108
  http://sourceforge.net/p/brlcad/code/70108
Author:   brlcad
Date: 2017-08-23 18:08:34 + (Wed, 23 Aug 2017)
Log Message:
---
remove obsolete function stubs.

Modified Paths:
--
brlcad/trunk/src/librt/binunif/db5_bin.c

Modified: brlcad/trunk/src/librt/binunif/db5_bin.c
===
--- brlcad/trunk/src/librt/binunif/db5_bin.c2017-08-23 17:52:35 UTC (rev 
70107)
+++ brlcad/trunk/src/librt/binunif/db5_bin.c2017-08-23 18:08:34 UTC (rev 
70108)
@@ -66,42 +66,7 @@
 };
 
 
-/**
- * XXX these are the interface routines needed for table.c
- */
-int
-rt_bin_unif_export5(struct bu_external *UNUSED(ep),
-   const struct rt_db_internal *UNUSED(ip),
-   double UNUSED(local2mm),
-   const struct db_i *UNUSED(dbip),
-   struct resource *UNUSED(resp))
-{
-bu_log("rt_bin_unif_export5() not implemented\n");
-return -1;
-}
 
-int
-rt_bin_unif_import5(struct rt_db_internal *UNUSED(ip),
-   const struct bu_external *UNUSED(ep),
-   const mat_t UNUSED(mat),
-   const struct db_i *UNUSED(dbip),
-   struct resource *UNUSED(resp))
-{
-bu_log("rt_bin_unif_import5() not implemented\n");
-return -1;
-}
-
-int
-rt_bin_mime_import5(struct rt_db_internal * UNUSED(ip),
-   const struct bu_external *UNUSED(ep),
-   const mat_t UNUSED(mat),
-   const struct db_i *UNUSED(dbip),
-   struct resource *UNUSED(resp))
-{
-bu_log("rt_bin_mime_import5() not implemented\n");
-return -1;
-}
-
 /**
  * Import a uniform-array binary object from the database format to
  * the internal structure.
@@ -211,7 +176,7 @@
 void
 rt_binunif_dump(struct rt_binunif_internal *bip) {
 RT_CK_BINUNIF(bip);
-bu_log("rt_bin_unif_internal <%p>...\n", (void *)bip);
+bu_log("rt_binunif_internal <%p>...\n", (void *)bip);
 bu_log("  type = x%x = %d", bip->type, bip->type);
 bu_log("  count = %ld  first = 0x%02x", bip->count,
   bip->u.uint8[0] & 0x0ff);

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


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits


[brlcad-commits] SF.net SVN: brlcad:[70107] brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp

2017-08-23 Thread starseeker--- via brlcad-commits
Revision: 70107
  http://sourceforge.net/p/brlcad/code/70107
Author:   starseeker
Date: 2017-08-23 17:52:35 + (Wed, 23 Aug 2017)
Log Message:
---
See if we can go with wdb interface instead

Modified Paths:
--
brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp

Modified: brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp
===
--- brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp   2017-08-23 15:43:48 UTC 
(rev 70106)
+++ brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp   2017-08-23 17:52:35 UTC 
(rev 70107)
@@ -154,30 +154,21 @@
 (void)get_dataset_info(state);
 
 /* Read in the data */
-struct directory *ddp;
 unsigned int xsize = GDALGetRasterXSize(state->hDataset);
 unsigned int ysize = GDALGetRasterYSize(state->hDataset);
 {
-   struct rt_db_internal intern;
struct rt_binunif_internal *bip;
-   RT_DB_INTERNAL_INIT();
-   intern.idb_major_type = DB5_MAJORTYPE_BINARY_UNIF;
-   intern.idb_minor_type = DB5_MINORTYPE_BINU_16BITINT_U;
-   intern.idb_meth = [ID_BINUNIF];
BU_ALLOC(bip, struct rt_binunif_internal);
-   intern.idb_ptr = (void *)bip;
bip->magic = RT_BINUNIF_INTERNAL_MAGIC;
bip->type = DB5_MINORTYPE_BINU_16BITINT_U;
bip->count = xsize * ysize;
if (bip->count < xsize || bip->count < ysize) {
bu_log("Error reading GDAL data\n");
-   rt_db_free_internal();
bu_free(bip, "bip");
return 0;
}
-   bip->u.int16 = (short int *)bu_calloc(bip->count, sizeof(unsigned 
short), "unsigned short array");
+   bip->u.int8 = (char *)bu_calloc(bip->count, sizeof(unsigned short), 
"unsigned short array");
 
-
GDALRasterBandH band = GDALGetRasterBand(state->hDataset, 1);
 
/*
@@ -201,33 +192,8 @@
}
}
 
-   struct bu_external body;
-   struct bu_external bin_ext;
-   int ret = -1;
-   if (intern.idb_meth->ft_export5) {
-   ret = intern.idb_meth->ft_export5(, , 1.0, 
context->dbip, state->wdbp->wdb_resp);
-   }
-   if (ret != 0) {
-   bu_log("Error while attempting to export test.data\n");
-   rt_db_free_internal();
-   return 0;
-   }
-   db5_export_object3(_ext, DB5HDR_HFLAGS_DLI_APPLICATION_DATA_OBJECT,
-   "test.data", 0, NULL, ,
-   intern.idb_major_type, intern.idb_minor_type,
-   DB5_ZZZ_UNCOMPRESSED, DB5_ZZZ_UNCOMPRESSED);
+   wdb_export(state->wdbp, "test.data", (void *)bip, ID_BINUNIF, 1);
 
-   rt_db_free_internal();
-   bu_free_external();
-
-   ddp = db_diradd5(context->dbip, "test.data", RT_DIR_PHONY_ADDR, 
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_16BITINT_U, 0, 0, NULL);
-   if (ddp == RT_DIR_NULL) return 0;
-   if (db_put_external5(_ext, ddp, context->dbip)) {
-   bu_free_external(_ext);
-   return 0;
-   }
-   bu_free_external(_ext);
-
/* Done reading - close input file */
CPLFree(scanline);
GDALClose(state->hDataset);
@@ -237,14 +203,8 @@
 
 /* Write out the dsp */
 {
-   struct rt_db_internal intern;
-   RT_DB_INTERNAL_INIT();
-   intern.idb_major_type = DB5_MAJORTYPE_BRLCAD;
-   intern.idb_type = ID_DSP;
-   intern.idb_meth = [ID_DSP];
struct rt_dsp_internal *dsp;
BU_ALLOC(dsp, struct rt_dsp_internal);
-   intern.idb_ptr = (void *)dsp;
dsp->magic = RT_DSP_INTERNAL_MAGIC;
 
bu_vls_init(>dsp_name);
@@ -257,16 +217,7 @@
MAT_IDN(dsp->dsp_stom);
bn_mat_inv(dsp->dsp_mtos, dsp->dsp_stom);
 
-   struct directory *dp = db_diradd(context->dbip, "test.s", 
RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (void *)_type);
-   if (dp == RT_DIR_NULL) {
-   rt_db_free_internal();
-   return 0;
-   }
-   if (rt_db_put_internal(dp, context->dbip, , _uniresource) < 
0) {
-   rt_db_free_internal();
-   return 0;
-   }
-   rt_db_free_internal();
+   wdb_export(state->wdbp, "test.s", (void *)dsp, ID_DSP, 1);
 }
 
 return 1;

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


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits


[brlcad-commits] SF.net SVN: brlcad:[70106] brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp

2017-08-23 Thread starseeker--- via brlcad-commits
Revision: 70106
  http://sourceforge.net/p/brlcad/code/70106
Author:   starseeker
Date: 2017-08-23 15:43:48 + (Wed, 23 Aug 2017)
Log Message:
---
Start working on taking GDAL data and writing out a .g dsp primitive.

Modified Paths:
--
brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp

Modified: brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp
===
--- brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp   2017-08-21 21:43:59 UTC 
(rev 70105)
+++ brlcad/trunk/src/libgcv/plugins/gdal/gdal.cpp   2017-08-23 15:43:48 UTC 
(rev 70106)
@@ -153,28 +153,122 @@
 
 (void)get_dataset_info(state);
 
-/* Read in the band */
-int bmin, bmax;
-double adfMinMax[2];
-GDALRasterBandH band = GDALGetRasterBand(state->hDataset, 1);
-adfMinMax[0] = GDALGetRasterMinimum(band, );
-adfMinMax[1] = GDALGetRasterMaximum(band, );
-if (!(bmin && bmax)) GDALComputeRasterMinMax(band, TRUE, adfMinMax);
-bu_log("Min/Max: %f, %f\n", adfMinMax[0], adfMinMax[1]);
-float *scanline = 
(float*)CPLMalloc(sizeof(float)*GDALGetRasterBandXSize(band));
-for(int i = 0; i < GDALGetRasterBandYSize(band); i++) {
-   if (GDALRasterIO(band, GF_Read, 0, i, GDALGetRasterBandXSize(band), 1, 
scanline, GDALGetRasterBandXSize(band), 1, GDT_Float32, 0, 0) == CPLE_None) {
-   for (int j = 0; j < GDALGetRasterBandXSize(band); ++j) {
-   int p = static_cast(scanline[j]);
-   bu_log("(%d,%d): %d\n", j, i, p);
+/* Read in the data */
+struct directory *ddp;
+unsigned int xsize = GDALGetRasterXSize(state->hDataset);
+unsigned int ysize = GDALGetRasterYSize(state->hDataset);
+{
+   struct rt_db_internal intern;
+   struct rt_binunif_internal *bip;
+   RT_DB_INTERNAL_INIT();
+   intern.idb_major_type = DB5_MAJORTYPE_BINARY_UNIF;
+   intern.idb_minor_type = DB5_MINORTYPE_BINU_16BITINT_U;
+   intern.idb_meth = [ID_BINUNIF];
+   BU_ALLOC(bip, struct rt_binunif_internal);
+   intern.idb_ptr = (void *)bip;
+   bip->magic = RT_BINUNIF_INTERNAL_MAGIC;
+   bip->type = DB5_MINORTYPE_BINU_16BITINT_U;
+   bip->count = xsize * ysize;
+   if (bip->count < xsize || bip->count < ysize) {
+   bu_log("Error reading GDAL data\n");
+   rt_db_free_internal();
+   bu_free(bip, "bip");
+   return 0;
+   }
+   bip->u.int16 = (short int *)bu_calloc(bip->count, sizeof(unsigned 
short), "unsigned short array");
+
+
+   GDALRasterBandH band = GDALGetRasterBand(state->hDataset, 1);
+
+   /*
+int bmin, bmax;
+double adfMinMax[2];
+adfMinMax[0] = GDALGetRasterMinimum(band, );
+adfMinMax[1] = GDALGetRasterMaximum(band, );
+if (!(bmin && bmax)) GDALComputeRasterMinMax(band, TRUE, adfMinMax);
+bu_log("Min/Max: %f, %f\n", adfMinMax[0], adfMinMax[1]);
+*/
+
+   /* If we're going to DSP we need the unsigned short read. */
+   uint16_t *scanline = (uint16_t 
*)CPLMalloc(sizeof(uint16_t)*GDALGetRasterBandXSize(band));
+   for(int i = 0; i < GDALGetRasterBandYSize(band); i++) {
+   if (GDALRasterIO(band, GF_Read, 0, i, GDALGetRasterBandXSize(band), 
1, scanline, GDALGetRasterBandXSize(band), 1, GDT_UInt16, 0, 0) == CPLE_None) {
+   for (int j = 0; j < GDALGetRasterBandXSize(band); ++j) {
+   /* This is the critical assignment point - if we get this
+* indexing wrong, data will not look right in dsp */
+   bip->u.int16[i*ysize+j] = scanline[j];
+   }
}
}
+
+   struct bu_external body;
+   struct bu_external bin_ext;
+   int ret = -1;
+   if (intern.idb_meth->ft_export5) {
+   ret = intern.idb_meth->ft_export5(, , 1.0, 
context->dbip, state->wdbp->wdb_resp);
+   }
+   if (ret != 0) {
+   bu_log("Error while attempting to export test.data\n");
+   rt_db_free_internal();
+   return 0;
+   }
+   db5_export_object3(_ext, DB5HDR_HFLAGS_DLI_APPLICATION_DATA_OBJECT,
+   "test.data", 0, NULL, ,
+   intern.idb_major_type, intern.idb_minor_type,
+   DB5_ZZZ_UNCOMPRESSED, DB5_ZZZ_UNCOMPRESSED);
+
+   rt_db_free_internal();
+   bu_free_external();
+
+   ddp = db_diradd5(context->dbip, "test.data", RT_DIR_PHONY_ADDR, 
DB5_MAJORTYPE_BINARY_UNIF, DB5_MINORTYPE_BINU_16BITINT_U, 0, 0, NULL);
+   if (ddp == RT_DIR_NULL) return 0;
+   if (db_put_external5(_ext, ddp, context->dbip)) {
+   bu_free_external(_ext);
+   return 0;
+   }
+   bu_free_external(_ext);
+
+   /* Done reading - close input file */
+   CPLFree(scanline);
+   GDALClose(state->hDataset);
 }
 
-/* Done - close it out */
-CPLFree(scanline);
-GDALClose(state->hDataset);
+/* TODO: if we're going to BoT (3-space mesh, will depend on the