Revision: 56775
http://sourceforge.net/p/brlcad/code/56775
Author: d_rossberg
Date: 2013-08-13 12:06:43 +0000 (Tue, 13 Aug 2013)
Log Message:
-----------
print the voxel's coordinates rather than its indices
still needs some tests and fine tuning
Modified Paths:
--------------
brlcad/trunk/src/conv/g-voxel.c
Modified: brlcad/trunk/src/conv/g-voxel.c
===================================================================
--- brlcad/trunk/src/conv/g-voxel.c 2013-08-13 11:37:53 UTC (rev 56774)
+++ brlcad/trunk/src/conv/g-voxel.c 2013-08-13 12:06:43 UTC (rev 56775)
@@ -19,19 +19,34 @@
*/
#include "analyze.h"
+
+struct voxelizeData
+{
+ fastf_t voxelSize[3];
+ fastf_t threshold;
+ fastf_t bbMin[3];
+};
+
+
/**
* Function to print values to File
*/
HIDDEN void
printToFile(genptr_t callBackData, int x, int y, int z, const char *a, fastf_t
fill) {
- fastf_t *threshold = (fastf_t *)callBackData;
+ struct voxelizeData *dataValues = (struct voxelizeData *)callBackData;
FILE *fp;
- if (a != NULL) {
+ if ((a != NULL) && (dataValues->threshold <= fill)) {
fp = fopen("voxels1.txt","a");
if (fp != NULL) {
- fprintf(fp, "%f\t(%4d,%4d,%4d)\t%s\t%f\n", *threshold, x, y, z, a,
fill);
+ fastf_t voxel[3];
+
+ voxel[0] = dataValues->bbMin[0] + (x + 0.5) *
dataValues->voxelSize[0];
+ voxel[1] = dataValues->bbMin[1] + (y + 0.5) *
dataValues->voxelSize[1];
+ voxel[2] = dataValues->bbMin[2] + (z + 0.5) *
dataValues->voxelSize[2];
+
+ fprintf(fp, "(%f, %f, %f)\t%s\t%f\n", voxel[0], voxel[1], voxel[2],
a, fill);
fclose(fp);
}
}
@@ -47,10 +62,11 @@
{
static struct rt_i *rtip;
static const char *usage = "[-s \"dx dy dz\"] [-d n] [-t f] model.g
objects...\n";
- fastf_t sizeVoxel[3], threshold;
+ struct voxelizeData dataValues;
int levelOfDetail;
genptr_t callBackData;
int c;
+ int gottree = 0;
char title[1024] = {0};
@@ -62,11 +78,13 @@
}
/* default user parameters */
- sizeVoxel[0] = 1.0;
- sizeVoxel[1] = 1.0;
- sizeVoxel[2] = 1.0;
- threshold = 0.5;
+ dataValues.voxelSize[0] = 1.0;
+ dataValues.voxelSize[1] = 1.0;
+ dataValues.voxelSize[2] = 1.0;
+
+ dataValues.threshold = 0.5;
+
levelOfDetail = 4;
bu_optind = 1;
@@ -82,7 +100,7 @@
bu_exit(1, "Usage: %s %s", argv[0], usage);
} else {
/* convert from double to fastf_t */
- VMOVE(sizeVoxel, scan);
+ VMOVE(dataValues.voxelSize, scan);
}
break;
@@ -93,7 +111,7 @@
break;
case 't':
- if(sscanf(bu_optarg, "%lf", &threshold) != 1) {
+ if(sscanf(bu_optarg, "%lf", &dataValues.threshold) != 1) {
bu_exit(1, "Usage: %s %s", argv[0], usage);
}
break;
@@ -125,14 +143,21 @@
while (argc > 0) {
if (rt_gettree(rtip, argv[0]) < 0)
bu_log("Loading the geometry for [%s] FAILED\n", argv[0]);
+ else
+ gottree = 1;
+
argc--;
argv++;
}
+
+ if (gottree != 0) {
+ VMOVE(dataValues.bbMin, rtip->mdl_min);
- callBackData = (void *)(& threshold);
+ callBackData = (void *)(& dataValues);
- /* voxelize function is called here with rtip(ray trace instance),
userParameters and printToFile/printToScreen options */
- voxelize(rtip, sizeVoxel, levelOfDetail, printToFile, callBackData);
+ /* voxelize function is called here with rtip(ray trace instance),
userParameters and printToFile/printToScreen options */
+ voxelize(rtip, dataValues.voxelSize, levelOfDetail, printToFile,
callBackData);
+ }
rt_free_rti(rtip);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits