Commit 5c03e72e authored by Will Schroeder's avatar Will Schroeder
Browse files

*** empty log message ***

parent a7ee1dd7
......@@ -15,9 +15,12 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Uses user-specified implicit function f(x,y,z)=0 to cut datasets.
//
// .NAME vlCutter - Cut vlDataSets with user-specified implicit function
// .SECTION Description
// vlCutter is a filter to cut any subclass of vlImplicitFunction to
// cut arbitrary vlDataSets. That is, a polygonal surface is created
// corresponding to the implicit function F(x,y,z) = 0.
#ifndef __vlCutter_h
#define __vlCutter_h
......@@ -27,10 +30,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
class vlCutter : public vlDataSetToPolyFilter
{
public:
vlCutter(vlImplicitFunction *cf=0);
vlCutter(vlImplicitFunction *cf=NULL);
~vlCutter();
char *GetClassName() {return "vlCutter";};
unsigned long int GetMTime();
vlSetObjectMacro(CutFunction,vlImplicitFunction);
vlGetObjectMacro(CutFunction,vlImplicitFunction);
......
......@@ -15,9 +15,10 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Abstract interface for implicit functions
//
// .NAME vlImplicitFunction - abstract interface for implicit functions
// .SECTION Description
// vlImplicitFunction specifies an abstract interface for implicit
// functions. Implicit functions are of the form F(x,y,z) = 0.
#ifndef __vlImplicitFunction_h
#define __vlImplicitFunction_h
......@@ -29,6 +30,7 @@ public:
char *GetClassName() {return "vlImplicitFunction";};
virtual float Evaluate(float x, float y, float z) = 0;
virtual void EvaluateNormal(float x, float y, float z, float n[3]) = 0;
};
#endif
......
......@@ -15,10 +15,12 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlPlane - perform various plane computations
// .SECTION Description
// vlPlane provides methods for various plane computations. These include
// projecting points onto a plane, evaluating the plane equation, and
// returning plane normal.
//
// Object for computation on plane
//
#ifndef __vlPlane_h
#define __vlPlane_h
......@@ -39,6 +41,7 @@ public:
// ImplicitFunction interface
float Evaluate(float x, float y, float z);
void EvaluateNormal(float x, float y, float z, float n[3]);
vlSetVector3Macro(Normal,float);
vlGetVectorMacro(Normal,float);
......
......@@ -15,9 +15,10 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Quadric function a0*x^2 + a1*y^2 + a2*z^2 + a3*x*y + a4*y*z + a5*x*z +
// a6*x + a7*y + a8*z + a9
// .NAME - vlQuadric - evaluate implicit quadric function
// .SECTION Description
// vlQuadric evaluates the quadric function a0*x^2 + a1*y^2 + a2*z^2 +
// a3*x*y + a4*y*z + a5*x*z + a6*x + a7*y + a8*z + a9 = 0.
//
#ifndef __vlQuadric_h
#define __vlQuadric_h
......@@ -32,6 +33,7 @@ public:
// ImplicitFunction interface
float Evaluate(float x, float y, float z);
void EvaluateNormal(float x, float y, float z, float n[3]);
void SetCoefficients(float a[10]);
void SetCoefficients(float a0, float a1, float a2, float a3, float a4,
......
......@@ -15,9 +15,10 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Object for computation on sphere
//
// .NAME vlSphere - implicit function of a sphere
// .SECTION Description
// vlSphere computes the implicit function and surface normal for a sphere.
#ifndef __vlSphere_h
#define __vlSphere_h
......@@ -31,6 +32,7 @@ public:
// ImplicitFunction interface
float Evaluate(float x, float y, float z);
void EvaluateNormal(float x, float y, float z, float n[3]);
vlSetMacro(Radius,float);
vlGetMacro(Radius,float);
......
......@@ -17,6 +17,8 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include "Cutter.hh"
// Description:
// Construct with user-specified implicit function.
vlCutter::vlCutter(vlImplicitFunction *cf)
{
this->CutFunction = cf;
......@@ -28,6 +30,20 @@ vlCutter::~vlCutter()
if ( this->CutFunction ) this->CutFunction->UnRegister(this);
}
unsigned long vlCutter::GetMTime()
{
unsigned long mTime=this->MTime.GetMTime();
unsigned long cutFuncMTime;
if ( this->CutFunction != NULL )
{
cutFuncMTime = this->CutFunction->GetMTime();
mTime = ( cutFuncMTime > mTime ? cutFuncMTime : mTime );
}
return mTime;
}
//
// Cut through data generating surface. Point values can be determined using
// ProbeFilter.
......
......@@ -18,6 +18,8 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "Plane.hh"
#include "vlMath.hh"
// Description
// Construct plane passing through origin and normal to z-axis.
vlPlane::vlPlane()
{
this->Normal[0] = 0.0;
......@@ -29,7 +31,10 @@ vlPlane::vlPlane()
this->Origin[2] = 0.0;
}
// NOTE : normal assumed to have magnitude 1
// Description
// Project a point x onto plane defined by origin and normal. The
// projected point is returned in xproj. NOTE : normal assumed to
// have magnitude 1.
void vlPlane::ProjectPoint(float x[3], float origin[3], float normal[3], float xproj[3])
{
int i;
......@@ -41,9 +46,19 @@ void vlPlane::ProjectPoint(float x[3], float origin[3], float normal[3], float x
for (i=0; i<3; i++) xproj[i] = x[i] - t * normal[i];
}
// Description
// Evaluate plane equation for point (x,y,z).
float vlPlane::Evaluate(float x, float y, float z)
{
return ( this->Normal[0]*(x-this->Origin[0]) +
this->Normal[1]*(y-this->Origin[1]) +
this->Normal[2]*(z-this->Origin[2]) );
}
// Description
// Evaluate plane normal at point (x,y,z).
void vlPlane::EvaluateNormal(float x, float y, float z, float n[3])
{
for (int i=0; i<3; i++) n[i] = this->Normal[i];
}
......@@ -19,6 +19,8 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include <math.h>
#include "Quadric.hh"
// Description
// Construct quadric with all coefficients = 1.
vlQuadric::vlQuadric()
{
this->Coefficients[0] = 1.0;
......@@ -33,6 +35,8 @@ vlQuadric::vlQuadric()
this->Coefficients[9] = 1.0;
}
// Description
// Evaluate quadric equation.
float vlQuadric::Evaluate(float x, float y, float z)
{
float *a = this->Coefficients;
......@@ -41,6 +45,8 @@ float vlQuadric::Evaluate(float x, float y, float z)
a[6]*x + a[7]*y + a[8]*z + a[9] );
}
// Description
// Set the 10 coefficients of the quadric equation.
void vlQuadric::SetCoefficients(float a[10])
{
int i;
......@@ -57,6 +63,20 @@ void vlQuadric::SetCoefficients(float a[10])
}
}
// Description
// Evaluate the normal to the quadric equation.
void vlQuadric::EvaluateNormal(float x, float y, float z, float n[3])
{
float *a=this->Coefficients;
n[0] = 2.0*a[0]*x + a[3]*y + a[5]*z + a[6];
n[1] = 2.0*a[1]*y + a[3]*x + a[4]*z + a[7];
n[2] = 2.0*a[2]*z + a[4]*y + a[5]*x + a[8];
}
// Description
// Set the 10 coefficients of the quadric equation.
void vlQuadric::SetCoefficients(float a0,float a1,float a2,float a3, float a4,
float a5,float a6,float a7,float a8, float a9)
{
......
......@@ -18,6 +18,8 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include <math.h>
#include "Sphere.hh"
// Description
// Construct sphere with center at (0,0,0) and radius=1.0.
vlSphere::vlSphere()
{
this->Radius = 1.0;
......@@ -27,6 +29,8 @@ vlSphere::vlSphere()
this->Origin[2] = 0.0;
}
// Description
// Evaluate sphere equation (x-x0)^2 + (y-y0)^2 + (z-z0)^2 - R^2 = 0.
float vlSphere::Evaluate(float x, float y, float z)
{
return ( sqrt ( this->Radius*this->Radius -
......@@ -34,3 +38,12 @@ float vlSphere::Evaluate(float x, float y, float z)
(y - this->Origin[1]) * (y - this->Origin[1]) +
(z - this->Origin[2]) * (z - this->Origin[2])) ) );
}
// Description
// Evaluate sphere normal.
void vlSphere::EvaluateNormal(float x, float y, float z, float n[3])
{
n[0] = 2.0 * (x - this->Origin[0]);
n[1] = 2.0 * (y - this->Origin[1]);
n[2] = 2.0 * (z - this->Origin[2]);
}
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