Text archives Help
- From: knolla@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1083 - in trunk: Model/Primitives scenes
- Date: Tue, 23 May 2006 19:46:47 -0600 (MDT)
Author: knolla
Date: Tue May 23 19:46:44 2006
New Revision: 1083
Modified:
trunk/Model/Primitives/IsosurfaceGridVolume.cc
trunk/Model/Primitives/IsosurfaceOctreeVolume.cc
trunk/Model/Primitives/IsosurfaceOctreeVolume.h
trunk/Model/Primitives/OctreeVolume.cc
trunk/scenes/gridisovol.cc
Log:
found and fixed bug in octree isosurface code : 0 isovalue
Modified: trunk/Model/Primitives/IsosurfaceGridVolume.cc
==============================================================================
--- trunk/Model/Primitives/IsosurfaceGridVolume.cc (original)
+++ trunk/Model/Primitives/IsosurfaceGridVolume.cc Tue May 23 19:46:44
2006
@@ -319,7 +319,7 @@
Vector cellsize(cx,cy,cz);
Vector cellcorner((orig-min)*ihierdiag*cellsize);
Vector celldir(dir*ihierdiag*cellsize);
-
+
isect(rays, which_one, orig, dir, inv_dir,
start_depth, tenter, dtdx, dtdy, dtdz, next_x, next_y, next_z,
ix, iy, iz, dix_dx, diy_dy, diz_dz,
Modified: trunk/Model/Primitives/IsosurfaceOctreeVolume.cc
==============================================================================
--- trunk/Model/Primitives/IsosurfaceOctreeVolume.cc (original)
+++ trunk/Model/Primitives/IsosurfaceOctreeVolume.cc Tue May 23 19:46:44
2006
@@ -84,20 +84,25 @@
#pragma unroll(2)
for(int axis=1; axis<3; axis++)
{
+ float ft0, ft1, ft0p, ft1p;
if (dir.data[axis] > 0.f)
{
- tenter = MAX(tenter, t0.data[axis]);
- tenter_padded = MAX(tenter_padded, t0.data[axis]);
- texit = MIN(texit, t1.data[axis]);
- texit_padded = MIN(texit_padded, t1p.data[axis]);
+ ft0 = ft0p = t0.data[axis];
+ ft1 = t1.data[axis];
+ ft1p = t1p.data[axis];
}
else
{
- tenter = MAX(tenter, t1.data[axis]);
- tenter_padded = MAX(tenter_padded, t1p.data[axis]);
- texit = MIN(texit, t0.data[axis]);
- texit_padded = MIN(texit_padded, t0.data[axis]);
+ ft0p = t1p.data[axis];
+ ft0 = t1.data[axis];
+ ft1 = ft1p = t0.data[axis];
}
+
+ tenter = MAX(tenter, ft0);
+ texit = MIN(texit, ft1);
+ tenter_padded = MAX(tenter_padded, ft0p);
+ texit_padded = MIN(texit_padded, ft1p);
+
if (tenter > texit)
return;
}
@@ -117,10 +122,6 @@
rays.setNormal(which_one, Vector(-1,0,0));
return;
}
- else
- {
- bool breakhere = true;
- }
#else
single_traverse_node(rays, which_one, orig, dir, inv_dir, 0,
0, 0, index_trace, cell, tenter_padded,
texit_padded);
@@ -135,6 +136,7 @@
{
OctNode& node = octdata->get_node(depth, node_index);
+ //cerr << "single_traverse_node, depth=" << depth << ", node_index=" <<
node_index << ", cell=" << cell[0] << "," << cell[1] << "," << cell[2] <<
endl;
index_trace[depth] = node_index;
int child_bit = octdata->get_child_bit_depth(depth);
@@ -458,7 +460,7 @@
#endif
if (octdata->get_isovalue() >= min_rho &&
octdata->get_isovalue() <= max_rho)
{
- #if 0
+ #if 1
if (rays.hit(which_one, child_tenter,
PrimitiveCommon::getMaterial(), this, 0))
{
rays.setNormal(which_one, Vector(-1,0,0));
@@ -516,6 +518,8 @@
int depth, unsigned int cap_index, unsigned int
index_trace[], Vec3i& cell,
const float tenter, const float texit) const
{
+ //cerr << "single_traverse_cap, depth=" << depth << ", cap_index=" <<
cap_index << ", cell=" << cell[0] << "," << cell[1] << "," << cell[2] <<
endl;
+
OctCap& cap = octdata->get_cap(cap_index);
index_trace[depth] = cap_index;
Modified: trunk/Model/Primitives/IsosurfaceOctreeVolume.h
==============================================================================
--- trunk/Model/Primitives/IsosurfaceOctreeVolume.h (original)
+++ trunk/Model/Primitives/IsosurfaceOctreeVolume.h Tue May 23 19:46:44
2006
@@ -44,8 +44,6 @@
const Vector& orig, const Vector& dir, const
Vector& inv_dir, int res,
int depth, unsigned int cap_index, unsigned int
index_trace[], Vec3i& cell, const float tenter,
const float texit) const;
-
- //lookup returning 0 if out of bounds. Only
works for scalar datatypes.
};
};
Modified: trunk/Model/Primitives/OctreeVolume.cc
==============================================================================
--- trunk/Model/Primitives/OctreeVolume.cc (original)
+++ trunk/Model/Primitives/OctreeVolume.cc Tue May 23 19:46:44 2006
@@ -47,6 +47,7 @@
OctreeVolume::OctreeVolume(char* filebase)
{
+ isoval = 22;
read_file(filebase);
}
@@ -268,7 +269,7 @@
int dim_extents = 1 << (max_depth - d - r - 1);
//cout << "dim_extents = " << dim_extents << endl;
- for(int i=0; i<nodes_dim; i++) {
+ for(int i=0; i<nodes_dim; i++)
for(int j=0; j<nodes_dim; j++)
for(int k=0; k<nodes_dim; k++)
{
@@ -299,132 +300,131 @@
bnode.values[4*pi | 2*pj |
pk] = buildnodes[d+1](2*i+pi, 2*j+pj, 2*k+pk).expected_value;
}
}
- }
+ }
+
+ if (d == max_depth-1-r) //finest-level data
are automatically caps, *if* they are kept
+ {
+
+ double expectedValue = 0.0;
+ for(int v=0; v<8; v++)
+ expectedValue +=
static_cast<double>(bnode.values[v]);
+ expectedValue *= 0.125;
- if (d == max_depth-1-r)
//finest-level data are automatically caps, *if* they are kept
+ double variances[8];
+ bnode.keepMe = false;
+ bnode.isLeaf = true;
+ for(int v=0; v<8; v++)
{
+ double diff =
static_cast<double>(bnode.values[v]) - expectedValue;
+ variances[v] = diff * diff * 0.125;
- double expectedValue = 0.0;
- for(int v=0; v<8; v++)
- expectedValue +=
static_cast<double>(bnode.values[v]);
- expectedValue *= 0.125;
-
- double variances[8];
- bnode.keepMe = false;
- bnode.isLeaf = true;
- for(int v=0; v<8; v++)
+ if (variances[v] >= variance_threshold)
{
- double diff =
static_cast<double>(bnode.values[v]) - expectedValue;
- variances[v] = diff * diff * 0.125;
-
- if (variances[v] >=
variance_threshold)
- {
- bnode.keepMe = true;
- break;
- }
+ bnode.keepMe = true;
+ break;
}
- bnode.expected_value = (ST)expectedValue;
-
- //find min, max using a specified kernel
width
- // 0 = ignore this step
- // 1 = this node only
- // 2 = this node + 1 forward (forward
differences)
- // 3 = this node, 1 forward, 1 backward
(central differences)
- // 4 = this, 2 forward, 1 backward.
- // etc.
- Vec3i kmin;
- kmin.data[0] = 2*i;
- kmin.data[1] = 2*j;
- kmin.data[2] = 2*k;
- Vec3i kmax = kmin;
+ }
+ bnode.expected_value = (ST)expectedValue;
+
+ //find min, max using a specified kernel
width
+ // 0 = ignore this step
+ // 1 = this node only
+ // 2 = this node + 1 forward (forward
differences)
+ // 3 = this node, 1 forward, 1 backward
(central differences)
+ // 4 = this, 2 forward, 1 backward.
+ // etc.
+ Vec3i kmin;
+ kmin.data[0] = 2*i;
+ kmin.data[1] = 2*j;
+ kmin.data[2] = 2*k;
+ Vec3i kmax = kmin;
+
+ kmin.data[0] -= (kernel_width-1)/2;
+ kmin.data[1] -= (kernel_width-1)/2;
+ kmin.data[2] -= (kernel_width-1)/2;
+ kmax.data[0] += (kernel_width/2)+1;
+ kmax.data[1] += (kernel_width/2)+1;
+ kmax.data[2] += (kernel_width/2)+1;
+ bnode.min = bnode.max = bnode.values[0];
+ if (r==0)
+ {
+ for(int pi=kmin.data[0];
pi<=kmax.data[0]; pi++)
+ for(int pj=kmin.data[1];
pj<=kmax.data[1]; pj++)
+ for(int pk=kmin.data[2];
pk<=kmax.data[2]; pk++)
+ {
+ ST val =
lookup_safe(originalData, pi, pj, pk);
+ narrow_range(val, isomin,
isomax);
+ bnode.min = MIN(bnode.min,
val);
+ bnode.max = MAX(bnode.max,
val);
+ }
+ }
+ else
+ {
+ int maxbound = (1<<d+1) - 1;
+ Array3<BuildNode>& children_bnodes =
buildnodes[d+1];
+ kmin = Min(kmin, Vec3i(0,0,0));
+ kmax = Max(kmax,
Vec3i(maxbound,maxbound,maxbound));
+ for(int pi=kmin.data[0];
pi<=kmax.data[0]; pi++)
+ for(int pj=kmin.data[1];
pj<=kmax.data[1]; pj++)
+ for(int pk=kmin.data[2];
pk<=kmax.data[2]; pk++)
+ {
+ ST val = children_bnodes(pi,
pj, pk).expected_value;
+ bnode.min = MIN(bnode.min,
val);
+ bnode.max = MAX(bnode.max,
val);
+ }
+ }
- kmin.data[0] -= (kernel_width-1)/2;
- kmin.data[1] -= (kernel_width-1)/2;
- kmin.data[2] -= (kernel_width-1)/2;
- kmax.data[0] += (kernel_width/2)+1;
- kmax.data[1] += (kernel_width/2)+1;
- kmax.data[2] += (kernel_width/2)+1;
- bnode.min = bnode.max = bnode.values[0];
- if (r==0)
- {
- for(int pi=kmin.data[0];
pi<=kmax.data[0]; pi++)
- for(int pj=kmin.data[1];
pj<=kmax.data[1]; pj++)
- for(int pk=kmin.data[2];
pk<=kmax.data[2]; pk++)
- {
- ST val =
lookup_safe(originalData, pi, pj, pk);
- narrow_range(val,
isomin, isomax);
- bnode.min =
MIN(bnode.min, val);
- bnode.max =
MAX(bnode.max, val);
- }
- }
- else
- {
- int maxbound = (1<<d+1) - 1;
- Array3<BuildNode>&
children_bnodes = buildnodes[d+1];
- kmin = Min(kmin, Vec3i(0,0,0));
- kmax = Max(kmax,
Vec3i(maxbound,maxbound,maxbound));
- for(int pi=kmin.data[0];
pi<=kmax.data[0]; pi++)
- for(int pj=kmin.data[1];
pj<=kmax.data[1]; pj++)
- for(int pk=kmin.data[2];
pk<=kmax.data[2]; pk++)
- {
- ST val =
children_bnodes(pi, pj, pk).expected_value;
- bnode.min =
MIN(bnode.min, val);
- bnode.max =
MAX(bnode.max, val);
- }
- }
-
- ncaps += bnode.keepMe;
- }
- else //if we're not at
finest-level depth
+ ncaps += bnode.keepMe;
+ }
+ else //if we're not at finest-level depth
+ {
+ //fill in the children
+ Array3<BuildNode>& children_bnodes =
buildnodes[d+1];
+ bnode.isLeaf = false;
+ bnode.keepMe = true;
+ bnode.scalar_leaf = 0;
+
+ bnode.myIndex = 0;
+ bnode.min = children_bnodes(2*i, 2*j,
2*k).min;
+ bnode.max = children_bnodes(2*i, 2*j,
2*k).max;
+ for(int pi=0; pi<2; pi++)
+ for(int pj=0; pj<2; pj++)
+ for(int pk=0; pk<2; pk++)
{
- //fill in the children
- Array3<BuildNode>&
children_bnodes = buildnodes[d+1];
- bnode.isLeaf = false;
- bnode.keepMe = true;
- bnode.scalar_leaf = 0;
+ int cidx = 4*pi+2*pj+pk;
+ BuildNode& child_bnode =
children_bnodes(2*i+pi, 2*j+pj, 2*k+pk);
- bnode.myIndex = 0;
- bnode.min = children_bnodes(2*i,
2*j, 2*k).min;
- bnode.max = children_bnodes(2*i,
2*j, 2*k).max;
- for(int pi=0; pi<2; pi++)
- for(int pj=0; pj<2; pj++)
- for(int pk=0; pk<2; pk++)
- {
- int cidx =
4*pi+2*pj+pk;
- BuildNode&
child_bnode = children_bnodes(2*i+pi, 2*j+pj, 2*k+pk);
-
- //find min, max
using children
- bnode.min =
MIN(bnode.min, child_bnode.min);
- bnode.max =
MAX(bnode.max, child_bnode.max);
-
- if
(child_bnode.keepMe == false) //make it a scalar leaf
- {
-
bnode.scalar_leaf |= (1 << cidx);
-
bnode.children[cidx].scalar = child_bnode.expected_value;
- }
- else
- {
- //update the
pointer to this child index
-
bnode.children_start = child_bnode.myStart;
-
bnode.children[cidx].offset = child_bnode.myIndex;
- }
- }
-
- double expectedValue
= 0.0;
- for(int v=0; v<8; v++)
- expectedValue +=
static_cast<double>(bnode.values[v]);
- expectedValue *= 0.125;
- bnode.expected_value =
(ST)expectedValue;
+ //find min, max using children
+ bnode.min = MIN(bnode.min,
child_bnode.min);
+ bnode.max = MAX(bnode.max,
child_bnode.max);
- //if all children are scalar
leaves
- if (bnode.scalar_leaf & 255)
+ if (child_bnode.keepMe == false)
//make it a scalar leaf
+ {
+ bnode.scalar_leaf |= (1 <<
cidx);
+ bnode.children[cidx].scalar
= child_bnode.expected_value;
+ }
+ else
{
- bnode.keepMe = ((bnode.max -
bnode.min) >= variance_threshold);
+ //update the pointer to this
child index
+ bnode.children_start =
child_bnode.myStart;
+ bnode.children[cidx].offset
= child_bnode.myIndex;
}
- nnodes += bnode.keepMe;
}
+
+ double expectedValue = 0.0;
+ for(int v=0; v<8; v++)
+ expectedValue +=
static_cast<double>(bnode.values[v]);
+ expectedValue *= 0.125;
+ bnode.expected_value = (ST)expectedValue;
+
+ //if all children are scalar leaves
+ if (bnode.scalar_leaf & 255)
+ {
+ bnode.keepMe = ((bnode.max - bnode.min)
>
= variance_threshold);
+ }
+ nnodes += bnode.keepMe;
+ }
}
- }
//this is just for stats...
unsigned int maxnodesthisdepth = (1 << d);
Modified: trunk/scenes/gridisovol.cc
==============================================================================
--- trunk/scenes/gridisovol.cc (original)
+++ trunk/scenes/gridisovol.cc Tue May 23 19:46:44 2006
@@ -56,13 +56,13 @@
}
else if (args[i] == "-macrocells") {
if (!getIntArg(i, args, macrocells))
- throw IllegalArgument("octisovol -mres_levels
<mres_levels>", i, args);
+ throw IllegalArgument("octisovol -macrocells
<#macrocells>", i, args);
}
else {
cerr << "Read built grid volume:" << endl;
cerr << "-file <filename>" << endl;
cerr << "-macrocells <#macrocells>" << endl;
- throw IllegalArgument( "octisovol", i, args );
+ throw IllegalArgument( "gridisovol", i, args );
}
}
@@ -96,13 +96,14 @@
//scene->setCamera(camera);
LightSet *lights = new LightSet();
- lights->add( new PointLight(Vector(eye + 25.f*(up + Cross(eye-lookat,
up))), Color(RGBColor(.6,.1,.1))) );
- lights->setAmbientLight( new ConstantAmbient(
Color(RGBColor(0.91,0.9,0.9) ) ));
+ lights->add( new PointLight(Vector(eye + 25.f*(up + Cross(eye-lookat,
up))), Color(RGBColor(1,1,1))) );
+ lights->setAmbientLight( new ConstantAmbient(
Color(RGBColor(0.4,0.5,0.5) ) ));
scene->setLights(lights);
// Background.
- scene->setBackground( new ConstantBackground( Color(RGB(0.8, 0.8,
0.8)) ) );
+ scene->setBackground( new ConstantBackground( Color(RGB(0.0, 0.0, 0.0))
) );
+ //scene->setBackground( new ConstantBackground( Color(RGB(0.99, 0.98,
0.98)) ) );
return scene;
}
- [MANTA] r1083 - in trunk: Model/Primitives scenes, knolla, 05/23/2006
Archive powered by MHonArc 2.6.16.