Commit 7402d47d authored by Will Schroeder's avatar Will Schroeder
Browse files

*** empty log message ***

parent 90439974
......@@ -14,6 +14,11 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlIndent - control print indentation
// .SECTION Description
// vlIndent is used to control indentation during the chaining print
// process.
#ifndef __vlIndent_h
#define __vlIndent_h
......
......@@ -29,13 +29,9 @@ class vlMatrix4x4 : public vlObject
void operator= (vlMatrix4x4& source);
float *operator[](const unsigned int i) {return &(Element[i][0]);};
// Calculate the inverse of in and
// return it in out.
void Invert (vlMatrix4x4 in,vlMatrix4x4 & out);
void Invert (void) { Invert(*this,*this);};
// Calculate the transpose of in and
// return it in out.
void Transpose (vlMatrix4x4 in,vlMatrix4x4 & out);
void Transpose (void) { Transpose(*this,*this);};
......
......@@ -13,11 +13,11 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlObject - abstract base class for many objects
// .NAME vlObject - abstract base class for visualization library
// .SECTION Description
// vlObject is the base class for many objects in the visualization
// library. vlObject provides methods for reference counting, keeping
// track of modified time, debugging, and printing object.
// library. vlObject provides methods for reference counting, tracking
// modification time, debugging, and printing.
#ifndef __vlObject_hh
#define __vlObject_hh
......@@ -46,17 +46,17 @@ public:
int GetDebug();
// modified time
virtual unsigned long int GetMTime() { return this->MTime.GetMTime(); };
void Modified() {MTime.Modified();};
virtual unsigned long int GetMTime();
void Modified();
// printing
virtual void PrintSelf(ostream& os, vlIndent indent);
void PrintWatchOn();
void PrintWatchOff();
int ShouldIPrint(char *a);
void Print(ostream& os);
virtual void PrintHeader(ostream& os, vlIndent indent);
int ShouldIPrint(char *a) { return this->PrintList.ShouldIPrint(a);};
virtual void PrintTrailer(ostream& os, vlIndent indent);
void PrintWatchOn() {this->PrintList.ActiveOn();};
void PrintWatchOff() {this->PrintList.ActiveOff();};
protected:
int Debug; // Enable debug messages
......@@ -69,5 +69,34 @@ private:
friend ostream& operator<<(ostream& os, vlObject& o);
};
// Description:
// Update the modification time for this object.
inline void vlObject::Modified()
{
this->MTime.Modified();
}
// Description:
// Start printing an object with multiple inheritance.
inline void vlObject::PrintWatchOn()
{
this->PrintList.ActiveOn();
}
// Description:
// Stop printing an object with multiple inheritance.
inline void vlObject::PrintWatchOff()
{
this->PrintList.ActiveOff();
}
// Description:
// Determine whether this object should print.
inline int vlObject::ShouldIPrint(char *a)
{
return this->PrintList.ShouldIPrint(a);
};
#endif
......@@ -15,10 +15,14 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// PointSetToPointSetFilter are filters that take PointSet in and
// generate PointSet as output.
//
// .NAME vlPointSetToPointSetFilter - abstract filter class
// .SECTION Description
// vlPointSetToPointSetFilter is an abstract filter class that take as
// input a vlPointSet (or any subclass of vlPointSet) and generates on
// output a vlPointSet. The concrete subclasses of
// vlPointSetToPointSetFilter (at a minimum) modify their point
// coordinates.
#ifndef __vlPointSetToPointSetFilter_h
#define __vlPointSetToPointSetFilter_h
......@@ -37,8 +41,8 @@ public:
// dataset interface
vlDataSet *MakeObject() {return this->PointSet->MakeObject();};
int GetNumberOfCells() {return this->PointSet->GetNumberOfCells();};
int GetNumberOfPoints() {return this->PointSet->GetNumberOfPoints();};
float *GetPoint(int i) {return this->PointSet->GetPoint(i);};
int GetNumberOfPoints() {return this->Points->GetNumberOfPoints();};
float *GetPoint(int i) {return this->Points->GetPoint(i);};
vlCell *GetCell(int cellId) {return this->PointSet->GetCell(cellId);};
int GetCellType(int cellId) {return this->PointSet->GetCellType(cellId);};
void GetCellPoints(int cellId, vlIdList& ptIds)
......
......@@ -13,27 +13,28 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Macros for setting and getting instance variables. Macros are available
// for built-in types; for character strings; vector arrays of built-in
// types size 2,3,4; and for setting objects (i.e., Registering objects).
// Macros enforce proper use of Debug, Modified time, and Registering objects.
//
// .NAME SetGet Macros - standard macros for setting/getting instance
// variable values
// .SECTION Description
// The SetGet macros are used to interface to instance variables
// in a standard fashion. This includes properly treating modified time,
// registering/unregistering object use, and printing out debug
// information.
//
// Macros are available for built-in types; for character strings;
// vector arrays of built-in types size 2,3,4; and for setting
// objects (i.e., Registering objects).
#ifndef __vlSetGet_hh
#define __vlSetGet_hh
#include <string.h>
//
// For super speedy execution define __vlNoDebug
//
//#define __vlNoDebug
//
// Some constants used throughout code
//
#define LARGE_FLOAT 1.0e29
#define LARGE_INTEGER 2147483646 /* 2**31 - 1 */
#define LARGE_INTEGER 2147483646 // 2^31 - 1
//
// Set built-in type. Creates member Set"name"() (e.g., SetVisibility());
......
......@@ -13,9 +13,17 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Shrinks arbitrary input
//
// .NAME vlShrinkFilter - shrink cells composing an arbitrary data set
// .SECTION Description
// vlShrinkFilter shrinks cells composing an arbitrary data set
// towards their centroid. The centroid of a cell is computed as
// the average position of the cell points. Shrinking results in
// disconencting the cells from one another.
// .SECTION Caveats
// It is possible to turn cells inside out or cause self intersection
// in special cases.
#ifndef __vlShrinkFilter_h
#define __vlShrinkFilter_h
......@@ -24,12 +32,16 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
class vlShrinkFilter : public vlDataSetToUnstructuredGridFilter
{
public:
vlShrinkFilter(const float sf=0.5) {this->ShrinkFactor = sf;};
vlShrinkFilter(float sf=0.5) {this->ShrinkFactor = sf;};
~vlShrinkFilter() {};
char *GetClassName() {return "vlShrinkFilter";};
void PrintSelf(ostream& os, vlIndent indent);
vlSetMacro(ShrinkFactor,float);
// Description:
// Set the fraction of shrink for each cell.
vlSetClampMacro(ShrinkFactor,float,0.0,1.0);
// Description:
// Get the fraction of shrink for each cell.
vlGetMacro(ShrinkFactor,float);
protected:
......
......@@ -13,9 +13,17 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Class to shrink PolyData
//
// .NAME vlShrinkPolyData - shrink cells composing PolyData
// .SECTION Description
// vlShrinkPolyData shrinks cells composing PolyData (e.g., vertices,
// lines, polygons, and triangle strips) towards their centroid. The
// centroid of a cell is computed as the average position of the
// cell points. Shrinking results in disconencting the cells from
// one another.
// .SECTION Caveats
// It is possible to turn cells inside out or cause self intersection
// in special cases.
#ifndef __vlShrinkPolyData_h
#define __vlShrinkPolyData_h
......@@ -24,12 +32,16 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
class vlShrinkPolyData : public vlPolyToPolyFilter
{
public:
vlShrinkPolyData() {this->ShrinkFactor = 0.5;};
vlShrinkPolyData(float sf=0.5) {this->ShrinkFactor = sf;};
~vlShrinkPolyData() {};
char *GetClassName() {return "vlShrinkPolyData";};
void PrintSelf(ostream& os, vlIndent indent);
vlSetMacro(ShrinkFactor,float);
// Description:
// Set the fraction of shrink for each cell.
vlSetClampMacro(ShrinkFactor,float,0.0,1.0);
// Description:
// Get the fraction of shrink for each cell.
vlGetMacro(ShrinkFactor,float);
protected:
......@@ -38,5 +50,3 @@ protected:
};
#endif
......@@ -13,26 +13,28 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Classes that need to keep track of modification / execution time use
// this class.
//
// .NAME vlTimeStamp - record modification and/or execution time
// .SECTION Description
// vlTimeStamp records a unique time when the method Modified() is
// executed. This time is guaranteed to be montonically increasing.
// Subclasses use this object to record modified and/or execution time.
#ifndef __vlTimeStamp_h
#define __vlTimeStamp_h
class vlTimeStamp
{
public:
vlTimeStamp() {this->ModifiedTime = 0;};
vlTimeStamp() : ModifiedTime(0) {};
void Modified() {this->ModifiedTime = ++vlTime;};
unsigned long int GetMTime() {return ModifiedTime;};
// Using >= and <= in the operators below handles special cases when
// modified times are equal. Only occurs for recently instantiated objects.
int operator>(vlTimeStamp& ts)
{return (this->ModifiedTime > ts.ModifiedTime);};
int operator<(vlTimeStamp& ts)
{return (this->ModifiedTime < ts.ModifiedTime);};
operator unsigned long int() {return this->ModifiedTime;};
private:
unsigned long ModifiedTime;
static unsigned long vlTime;
......
......@@ -15,9 +15,21 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Class to transform points
//
// .NAME vlTransformFilter - transform points and associated normals and vectors
// .SECTION Description
// vlTransformFilter is a filter to transform point coordinates and
// associated point normals and vectors. Other point data is passed
// through the filter.
//
// An alternative method of transformation is to use vlActors methods
// to scale, rotate, and translate objects. The difference between the
// two methods is that vlActor's transformation simply effects where
// objects are rendered (via the graphics pipeline), whereas
// vlTransformFilter actually modifies point coordinates in the
// visualization pipeline. This is necessary for some objects
// (e.g., vlProbeFilter) that require point coordinates as input.
// .EXAMPLE XFormSph.cc
#ifndef __vlTransformFilter_h
#define __vlTransformFilter_h
......
......@@ -13,9 +13,14 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Class for performing common math operations (e.g., dot, cross products)
//
// .NAME vlMath - performs common math operations
// .SECTION Description
// vlMath is provides methods to perform common math operations. These
// include providing constants such as Pi, conversion from degrees to
// radians, vector operations such as dot and cross products and vector
// norm, matrix determinates for 2x2, 3x3, and 4x4 matrices, and random
// number generation.
#ifndef __vlMath_hh
#define __vlMath_hh
......@@ -25,45 +30,113 @@ class vlMath
{
public:
vlMath() {};
~vlMath() {};
float Pi() {return 3.14159265358979;};
float DegreesToRadians() {return 0.017453292;};
float Dot(float x[3], float y[3])
{return x[0]*y[0] + x[1]*y[1] + x[2]*y[2];};
void Cross(float x[3], float y[3], float z[3])
{z[0] = x[1]*y[2] - x[2]*y[1];
z[1] = x[2]*y[0] - x[0]*y[2];
z[2] = x[0]*y[1] - x[1]*y[0];};
float Norm(float x[3])
{return sqrt(x[0]*x[0] + x[1]*x[1] + x[2]*x[2]);};
void Normalize(float x[3])
{float den; int i;
if ( (den = this->Norm(x)) != 0.0 )
for (i=0; i < 3; i++) x[i] /= den;
}
float Determinate3x3(float *c1, float *c2, float *c3)
{return c1[0]*c2[1]*c3[2] + c2[0]*c3[1]*c1[2] + c3[0]*c1[1]*c2[2] -
c1[0]*c3[1]*c2[2] - c2[0]*c1[1]*c3[2] - c3[0]*c2[1]*c1[2];};
float Dot(float x[3], float y[3]);
void Cross(float x[3], float y[3], float z[3]);
float Norm(float x[3]);
void Normalize(float x[3]);
float Determinate2x2(float *c1, float *c2)
{return c1[0]*c2[1] - c2[0]*c1[1];};
float Distance2BetweenPoints(float *x, float *y)
{return (x[0]-y[0])*(x[0]-y[0]) + (x[1]-y[1])*(x[1]-y[1]) +
(x[2]-y[2])*(x[2]-y[2]);};
float Determinate2x2(float *c1, float *c2);
double Determinate2x2(double a, double b, double c, double d);
float Determinate3x3(float *c1, float *c2, float *c3);
double Determinate3x3(double a1, double a2, double a3,
double b1, double b2, double b3,
double c1, double c2, double c3);
float Distance2BetweenPoints(float *x, float *y);
void RandomSeed(long s);
float Random();
float Random(float min, float max) {return min+Random()*(max-min);};
float Random(float min, float max);
protected:
static long Seed;
};
// Description:
// Dot product of two 3-vectors.
inline float vlMath::Dot(float x[3], float y[3])
{
return x[0]*y[0] + x[1]*y[1] + x[2]*y[2];
}
// Description:
// Cross product of two 3-vectors. Result vector in z[3].
inline void vlMath::Cross(float x[3], float y[3], float z[3])
{
z[0] = x[1]*y[2] - x[2]*y[1];
z[1] = x[2]*y[0] - x[0]*y[2];
z[2] = x[0]*y[1] - x[1]*y[0];
}
// Description:
// Compute the norm of 3-vector.
inline float vlMath::Norm(float x[3])
{
return sqrt(x[0]*x[0] + x[1]*x[1] + x[2]*x[2]);
}
// Description:
// Normalize (in place) a 3-vector.
inline void vlMath::Normalize(float x[3])
{
float den;
if ( (den = this->Norm(x)) != 0.0 ) for (int i=0; i < 3; i++) x[i] /= den;
}
// Description:
// Compute determinate of 2x2 matrix. Two columns of matrix are input.
inline float vlMath::Determinate2x2(float *c1, float *c2)
{
return c1[0]*c2[1] - c2[0]*c1[1];
}
// Description:
// Calculate the determinent of a 2x2 matrix: | a b |
// | c d |
inline double vlMath::Determinate2x2(double a, double b, double c, double d)
{
return (a * d - b * c);
}
// Description:
// Compute determinate of 3x3 matrix. Three columns of matrix are input.
inline float vlMath::Determinate3x3(float *c1, float *c2, float *c3)
{
return c1[0]*c2[1]*c3[2] + c2[0]*c3[1]*c1[2] + c3[0]*c1[1]*c2[2] -
c1[0]*c3[1]*c2[2] - c2[0]*c1[1]*c3[2] - c3[0]*c2[1]*c1[2];
}
// Description:
// Calculate the determinent of a 3x3 matrix in the form:
// | a1, b1, c1 |
// | a2, b2, c2 |
// | a3, b3, c3 |
inline double vlMath::Determinate3x3(double a1, double a2, double a3,
double b1, double b2, double b3,
double c1, double c2, double c3)
{
return a1 * this->Determinate2x2( b2, b3, c2, c3 )
- b1 * this->Determinate2x2( a2, a3, c2, c3 )
+ c1 * this->Determinate2x2( a2, a3, b2, b3 );
}
// Description:
// Compute distance squared between two points.
inline float vlMath::Distance2BetweenPoints(float *x, float *y)
{
return (x[0]-y[0])*(x[0]-y[0]) + (x[1]-y[1])*(x[1]-y[1]) +
(x[2]-y[2])*(x[2]-y[2]);
}
// Description:
// Generate random number between (min,max)
inline float vlMath::Random(float min, float max)
{
return min + this->Random()*(max-min);
}
#endif
......@@ -19,6 +19,8 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
static char blanks[NumberOfBlanks+1]=" ";
// Description:
// Determine the next indentation level.
vlIndent vlIndent::GetNextIndent()
{
int indent = this->Indent + vlStdIndent;
......@@ -26,6 +28,8 @@ vlIndent vlIndent::GetNextIndent()
return indent;
}
// Description:
// Print out the indentation.
ostream& operator<<(ostream& os, vlIndent& ind)
{
os << blanks + (NumberOfBlanks-ind.Indent) ;
......
......@@ -17,7 +17,10 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include <math.h>
#include "Mat4x4.hh"
#include "vlMath.hh"
// Description:
// Construct identity matrix.
vlMatrix4x4::vlMatrix4x4 ()
{
int i,j;
......@@ -45,6 +48,8 @@ vlMatrix4x4::vlMatrix4x4(const vlMatrix4x4& m)
}
}
// Description:
// Set all elements of matrix to input value.
void vlMatrix4x4::operator= (float element)
{
int i,j;
......@@ -59,6 +64,8 @@ void vlMatrix4x4::operator= (float element)
this->Modified ();
}
// Description:
// Multiply a point (in homogeneous coordinates) by matrix.
void vlMatrix4x4::PointMultiply(float in[4],float result[4])
{
int i;
......@@ -78,11 +85,11 @@ void vlMatrix4x4::PointMultiply(float in[4],float result[4])
}
// Description:
// Matrix Inversion (by Richard Carling from "Graphics Gems",
// Academic Press, 1990).
void vlMatrix4x4::Invert (vlMatrix4x4 in,vlMatrix4x4 & out)
{
// Matrix Inversion
// by Richard Carling
// from "Graphics Gems", Academic Press, 1990
#define SMALL_NUMBER 1.e-9
......@@ -118,48 +125,12 @@ void vlMatrix4x4::Invert (vlMatrix4x4 in,vlMatrix4x4 & out)
for(j=0; j<4; j++)
out.Element[i][j] = out.Element[i][j] / det;
}
/*
* double = det2x2( double a, double b, double c, double d )
*
* calculate the determinent of a 2x2 matrix.
*/
static double det2x2( double a, double b, double c, double d)
{
double ans;
ans = a * d - b * c;
return ans;
}
/*
* double = det3x3( a1, a2, a3, b1, b2, b3, c1, c2, c3 )
*
* calculate the determinent of a 3x3 matrix
* in the form
*
* | a1, b1, c1 |
* | a2, b2, c2 |
* | a3, b3, c3 |
*/
static double det3x3( double a1, double a2, double a3, double b1, double b2, double b3, double c1, double c2, double c3 )
{
double ans;
ans = a1 * det2x2( b2, b3, c2, c3 )
- b1 * det2x2( a2, a3, c2, c3 )
+ c1 * det2x2( a2, a3, b2, b3 );
return ans;
}
// Description:
// Compute the determinate of the matrix.
float vlMatrix4x4::Determinant (vlMatrix4x4 & in)
/*
* double = det4x4( matrix )
*
* calculate the determinent of a 4x4 matrix.
*/
{
double ans;
vlMath math;
double a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3, d4;
// assign to individual variable names to aid selecting
......@@ -177,13 +148,14 @@ float vlMatrix4x4::Determinant (vlMatrix4x4 & in)
a4 = in.Element[3][0]; b4 = in.Element[3][1];
c4 = in.Element[3][2]; d4 = in.Element[3][3];
ans = a1 * det3x3( b2, b3, b4, c2, c3, c4, d2, d3, d4)
- b1 * det3x3( a2, a3, a4, c2, c3, c4, d2, d3, d4)
+ c1 * det3x3( a2, a3, a4, b2, b3, b4, d2, d3, d4)
- d1 * det3x3( a2, a3, a4, b2, b3, b4, c2, c3, c4);
return ans;
return a1 * math.Determinate3x3( b2, b3, b4, c2, c3, c4, d2, d3, d4)
- b1 * math.Determinate3x3( a2, a3, a4, c2, c3, c4, d2, d3, d4)
+ c1 * math.Determinate3x3( a2, a3, a4, b2, b3, b4, d2, d3, d4)
- d1 * math.Determinate3x3( a2, a3, a4, b2, b3, b4, c2, c3, c4);
}
// Description:
// Compute adjoint of matrix.
void vlMatrix4x4::Adjoint (vlMatrix4x4 & in,vlMatrix4x4 & out)
{
//
......@@ -202,8 +174,8 @@ void vlMatrix4x4::Adjoint (vlMatrix4x4 & in,vlMatrix4x4 & out)
//
// The matrix B = (b ) is the adjoint of A
// ij
///
//
vlMath m;
double a1, a2, a3, a4, b1, b2, b3, b4;
double c1, c2, c3, c4, d1, d2, d3, d4;
......@@ -225,25 +197,25 @@ void vlMatrix4x4::Adjoint (vlMatrix4x4 & in,vlMatrix4x4 & out)