Commit e36145bc authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Compute gradients not normals (since not normalized).

parent 05a01e2b
......@@ -47,7 +47,7 @@ public:
// ImplicitFunction interface
float Evaluate(float x, float y, float z);
void EvaluateNormal(float x, float y, float z, float n[3]);
void EvaluateGradient(float x, float y, float z, float g[3]);
// Override modified time retrieval because of object dependencies.
unsigned long int GetMTime();
......
......@@ -33,8 +33,8 @@ public:
virtual float Evaluate(float x, float y, float z) = 0;
// Description:
// Evaluate function normal at position x-y-z and pass back vector.
virtual void EvaluateNormal(float x, float y, float z, float n[3]) = 0;
// Evaluate function gradient at position x-y-z and pass back vector.
virtual void EvaluateGradient(float x, float y, float z, float g[3]) = 0;
};
......
......@@ -39,7 +39,7 @@ public:
// ImplicitFunction interface
float Evaluate(float x, float y, float z);
float Evaluate(float normal[3], float origin[3], float x[3]);
void EvaluateNormal(float x, float y, float z, float n[3]);
void EvaluateGradient(float x, float y, float z, float g[3]);
vlSetVector3Macro(Normal,float);
vlGetVectorMacro(Normal,float,3);
......
......@@ -15,7 +15,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlSphere - implicit function for a sphere
// .SECTION Description
// vlSphere computes the implicit function and surface normal for a sphere.
// vlSphere computes the implicit function and/or gradient for a sphere.
// vlSphere is a concrete implementation of vlImplicitFunction.
#ifndef __vlSphere_h
......@@ -32,7 +32,7 @@ public:
// ImplicitFunction interface
float Evaluate(float x, float y, float z);
void EvaluateNormal(float x, float y, float z, float n[3]);
void EvaluateGradient(float x, float y, float z, float n[3]);
vlSetMacro(Radius,float);
vlGetMacro(Radius,float);
......
......@@ -108,8 +108,8 @@ float vlImplicitBoolean::Evaluate(float x, float y, float z)
}
// Description
// Evaluate sphere normal.
void vlImplicitBoolean::EvaluateNormal(float x, float y, float z, float n[3])
// Evaluate gradient of boolean combination.
void vlImplicitBoolean::EvaluateGradient(float x, float y, float z, float g[3])
{
float value, v;
vlImplicitFunction *f;
......@@ -122,7 +122,7 @@ void vlImplicitBoolean::EvaluateNormal(float x, float y, float z, float n[3])
if ( (v=f->Evaluate(x,y,z)) < value )
{
value = v;
f->EvaluateNormal(x,y,z,n);
f->EvaluateGradient(x,y,z,g);
}
}
}
......@@ -135,21 +135,21 @@ void vlImplicitBoolean::EvaluateNormal(float x, float y, float z, float n[3])
if ( (v=f->Evaluate(x,y,z)) > value )
{
value = v;
f->EvaluateNormal(x,y,z,n);
f->EvaluateGradient(x,y,z,g);
}
}
}
else //difference
{
float nTemp[3];
float gTemp[3];
vlImplicitFunction *firstF;
this->FunctionList.InitTraversal();
if ( (firstF = this->FunctionList.GetNextItem()) != NULL )
{
value = firstF->Evaluate(x,y,z);
firstF->EvaluateNormal(x,y,z,nTemp);
n[0] = -1.0*nTemp[0]; n[1] = -1.0*nTemp[1]; n[2] = -1.0*nTemp[2];
firstF->EvaluateGradient(x,y,z,gTemp);
g[0] = -1.0*gTemp[0]; g[1] = -1.0*gTemp[1]; g[2] = -1.0*gTemp[2];
}
for (this->FunctionList.InitTraversal();
......@@ -160,8 +160,8 @@ void vlImplicitBoolean::EvaluateNormal(float x, float y, float z, float n[3])
if ( (v=(-1.0)*f->Evaluate(x,y,z)) > value )
{
value = v;
f->EvaluateNormal(x,y,z,nTemp);
n[0] = -1.0*nTemp[0]; n[1] = -1.0*nTemp[1]; n[2] = -1.0*nTemp[2];
f->EvaluateGradient(x,y,z,gTemp);
g[0] = -1.0*gTemp[0]; g[1] = -1.0*gTemp[1]; g[2] = -1.0*gTemp[2];
}
}
}
......
......@@ -55,8 +55,8 @@ float vlPlane::Evaluate(float x, float y, float z)
}
// Description
// Evaluate plane normal at point (x,y,z).
void vlPlane::EvaluateNormal(float x, float y, float z, float n[3])
// Evaluate function gradient at point (x,y,z).
void vlPlane::EvaluateGradient(float x, float y, float z, float n[3])
{
for (int i=0; i<3; i++) n[i] = this->Normal[i];
}
......
......@@ -37,8 +37,8 @@ float vlSphere::Evaluate(float x, float y, float z)
}
// Description
// Evaluate sphere normal.
void vlSphere::EvaluateNormal(float x, float y, float z, float n[3])
// Evaluate sphere gradient.
void vlSphere::EvaluateGradient(float x, float y, float z, float n[3])
{
n[0] = 2.0 * (x - this->Center[0]);
n[1] = 2.0 * (y - this->Center[1]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment