Commit 06e86810 authored by Will Schroeder's avatar Will Schroeder
Browse files

ERR: Misc bug fixes

parent 1d468e2e
......@@ -78,6 +78,9 @@ public:
// return pointer to this dataset's point data
vlPointData *GetPointData() {return &this->PointData;};
// reclaim memory
virtual void Squeeze();
protected:
vlPointData PointData; // Scalars, vectors, etc. associated w/ each point
vlTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
......
......@@ -52,6 +52,9 @@ public:
// compute bounds of data
void ComputeBounds();
// reclaim memory
void Squeeze();
vlSetObjectMacro(Points,vlPoints);
vlGetObjectMacro(Points,vlPoints);
......
......@@ -34,6 +34,8 @@ public:
virtual float *GetPoint(int i) = 0;
virtual void SetPoint(int i,float x[3]) = 0; // fast insert
virtual void InsertPoint(int i, float x[3]) = 0; // allocates memory as necessary
virtual void Squeeze() = 0; // reclaim memory
void GetPoints(vlIdList& ptId, vlFloatPoints& fp);
char *GetClassName() {return "vlPoints";};
void PrintSelf(ostream& os, vlIndent indent);
......
......@@ -66,6 +66,8 @@ public:
// create verts, lines, polys, tmeshes from cell object
void InsertNextCell(int type, int npts, int pts[MAX_CELL_SIZE]);
// Use this method to reclaim memory when using InsertNextCell()
void Squeeze();
// special operations on cell
void ReverseCell(int cellId);
......
......@@ -28,7 +28,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
class vlPointData : public vlObject
{
public:
vlPointData() : Scalars(NULL), Vectors(NULL), Normals(NULL), TCoords(NULL) {};
vlPointData();
void Initialize();
~vlPointData();
char *GetClassName() {return "vlPointData";};
......
......@@ -48,10 +48,13 @@ public:
void GetCellPoints(int cellId, vlIdList& ptIds);
void GetPointCells(int ptId, vlIdList& cellIds);
// specific object methods
void SetDimensions(int i, int j, int k);
void SetDimensions(int dim[3]);
vlGetVectorMacro(Dimensions,int);
int GetDataDimension();
void BlankingOn();
void BlankingOff();
int GetBlanking() {return this->Blanking;};
......
......@@ -41,6 +41,7 @@ public:
int& subId, float pcoords[3]);
int GetCellType(int cellId);
// specific object methods
vlSetVector3Macro(AspectRatio,float);
vlGetVectorMacro(AspectRatio,float);
......
......@@ -18,6 +18,9 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "Object.hh"
#include "Mat4x4.hh"
#include "Points.hh"
#include "Normals.hh"
#include "Vectors.hh"
// .NAME vlTransform - a general matrix transformation class
// .LIBRARY common
......@@ -28,13 +31,6 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
class vlTransform : public vlObject
{
private:
int PreMultiplyFlag;
int StackSize;
vlMatrix4x4 ** Stack;
vlMatrix4x4 ** StackBottom;
float Vector[4];
float Orientation[3];
public:
vlTransform ();
vlTransform (const vlTransform& t);
......@@ -63,10 +59,22 @@ class vlTransform : public vlObject
void PrintSelf (ostream& os, vlIndent indent);
void Concatenate (vlMatrix4x4 & matrix);
void Multiply4x4 ( vlMatrix4x4 & a, vlMatrix4x4 & b, vlMatrix4x4 & c);
void VectorMultiply (float in[4],float out[4])
{this->Stack[0]->VectorMultiply(in,out);};
vlSetVector4Macro(Vector,float);
float *GetVector();
void PointMultiply (float in[4],float out[4])
{this->Stack[0]->PointMultiply(in,out);};
void MultiplyPoints(vlPoints *inPts, vlPoints *outPts);
void MultiplyVectors(vlVectors *inVectors, vlVectors *outVectors);
void MultiplyNormals(vlNormals *inNormals, vlNormals *outNormals);
vlSetVector4Macro(Point,float);
float *GetPoint();
private:
int PreMultiplyFlag;
int StackSize;
vlMatrix4x4 ** Stack;
vlMatrix4x4 ** StackBottom;
float Point[4];
float Orientation[3];
};
#endif
......@@ -42,7 +42,6 @@ public:
int InsertNextCell(int type, int npts, int pts[MAX_CELL_SIZE]);
void InsertCells(int numCells, int width, int* data);
void InsertCells(int numCells, int* data);
void Squeeze();
// dataset interface
vlDataSet *MakeObject() {return new vlUnstructuredGrid(*this);};
......@@ -52,6 +51,7 @@ public:
void GetCellPoints(int cellId, vlIdList& ptIds);
void GetPointCells(int ptId, vlIdList& cellIds);
int GetCellType(int cellId);
void Squeeze();
protected:
// points inherited
......
......@@ -134,3 +134,20 @@ float *vlCell::GetBounds ()
}
return bounds;
}
float vlCell::GetLength2 ()
{
float diff, l=0.0;
float *bounds;
int i;
bounds = this->GetBounds();
for (i=0; i<3; i++)
{
diff = bounds[2*i+1] - bounds[2*i];
l += diff * diff;
}
return l;
}
......@@ -136,3 +136,8 @@ void vlDataSet::GetCellNeighbors(int cellId, vlIdList &ptIds,
}
}
}
void vlDataSet::Squeeze()
{
this->PointData.Squeeze();
}
......@@ -134,3 +134,9 @@ int vlPointSet::FindCell(float x[3], vlCell *cell, float tol2, int& subId,
}
return closestCell;
}
void vlPointSet::Squeeze()
{
if ( this->Points ) this->Points->Squeeze();
vlDataSet::Squeeze();
}
......@@ -418,21 +418,38 @@ void vlPolyData::GetPointCells(int ptId, vlIdList& cellIds)
void vlPolyData::InsertNextCell(int type, int npts, int pts[MAX_CELL_SIZE])
{
switch (type)
{
case vlPOINT: case vlPOLY_POINTS:
this->Verts->InsertNextCell(npts,pts);
break;
if ( this->Verts == NULL ) // hasn't been initialized
{
this->SetVerts(new vlCellArray(1000,1000));
}
this->Verts->InsertNextCell(npts,pts);
break;
case vlLINE: case vlPOLY_LINE:
if ( this->Lines == NULL ) // hasn't been initialized
{
this->SetLines(new vlCellArray(1000,1000));
}
this->Lines->InsertNextCell(npts,pts);
break;
case vlTRIANGLE: case vlQUAD: case vlPOLYGON:
if ( this->Polys == NULL ) // hasn't been initialized
{
this->SetPolys(new vlCellArray(1000,1000));
}
this->Polys->InsertNextCell(npts,pts);
break;
case vlTRIANGLE_STRIP:
if ( this->Strips == NULL ) // hasn't been initialized
{
this->SetStrips(new vlCellArray(1000,1000));
}
this->Strips->InsertNextCell(npts,pts);
break;
......@@ -441,6 +458,16 @@ void vlPolyData::InsertNextCell(int type, int npts, int pts[MAX_CELL_SIZE])
}
}
void vlPolyData::Squeeze()
{
if ( this->Verts != NULL ) this->Verts->Squeeze();
if ( this->Lines != NULL ) this->Lines->Squeeze();
if ( this->Polys != NULL ) this->Polys->Squeeze();
if ( this->Strips != NULL ) this->Strips->Squeeze();
vlPointSet::Squeeze();
}
void vlPolyData::ReverseCell(int cellId)
{
int loc, type;
......
......@@ -23,6 +23,19 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "FNormals.hh"
#include "FTCoords.hh"
vlPointData::vlPointData()
{
this->Scalars = NULL;
this->Vectors = NULL;
this->Normals = NULL;
this->TCoords = NULL;
this->CopyScalars = 1;
this->CopyVectors = 1;
this->CopyNormals = 1;
this->CopyTCoords = 1;
}
vlPointData::vlPointData (const vlPointData& pd)
{
this->Scalars = pd.Scalars;
......
......@@ -44,6 +44,19 @@ vlStructuredDataSet::~vlStructuredDataSet()
this->Initialize();
}
int vlStructuredDataSet::GetDataDimension()
{
switch (this->DataDescription)
{
case SINGLE_POINT: return 0;
case X_LINE: case Y_LINE: case Z_LINE: return 1;
case XY_PLANE: case YZ_PLANE: case XZ_PLANE: return 2;
case XYZ_GRID: return 3;
}
}
void vlStructuredDataSet::SetDimensions(int i, int j, int k)
{
......
......@@ -609,19 +609,90 @@ void vlTransform::PrintSelf (ostream& os, vlIndent indent)
}
// Description:
// Returns vector transformed by the current transformation matrix.
// Returns point transformed by the current transformation matrix.
float *vlTransform::GetVector()
float *vlTransform::GetPoint()
{
if (this->PreMultiplyFlag)
{
this->Stack[0]->Transpose();
this->Stack[0]->VectorMultiply(this->Vector,this->Vector);
this->Stack[0]->PointMultiply(this->Point,this->Point);
this->Stack[0]->Transpose();
}
else
{
this->Stack[0]->VectorMultiply(this->Vector,this->Vector);
this->Stack[0]->PointMultiply(this->Point,this->Point);
}
return this->Vector;
return this->Point;
}
void vlTransform::MultiplyPoints(vlPoints *inPts, vlPoints *outPts)
{
float newX[4];
float *x;
int ptId, i;
int numPts = inPts->GetNumberOfPoints();
for (ptId=0; ptId < numPts; ptId++)
{
x = inPts->GetPoint(ptId);
for (i=0; i<3; i++) newX[i] = x[i];
newX[3] = 1.0;
this->Stack[0]->PointMultiply(newX,newX);
for (i=0; i<3; i++) newX[i] /= newX[3]; //normalize
outPts->SetPoint(ptId, newX);
}
}
void vlTransform::MultiplyVectors(vlVectors *inVectors, vlVectors *outVectors)
{
float newV[4];
float *v;
int ptId, i;
int numVectors = inVectors->GetNumberOfVectors();
this->Push();
this->Inverse();
this->Transpose();
for (ptId=0; ptId < numVectors; ptId++)
{
v = inVectors->GetVector(ptId);
for (i=0; i<3; i++) newV[i] = v[i];
newV[3] = 1.0;
this->Stack[0]->PointMultiply(newV,newV);
for (i=0; i<3; i++) newV[i] /= newV[3]; //normalize
outVectors->SetVector(ptId, newV);
}
this->Pop();
}
void vlTransform::MultiplyNormals(vlNormals *inNormals, vlNormals *outNormals)
{
float newN[4];
float *n;
int ptId, i;
int numNormals = inNormals->GetNumberOfNormals();
this->Push();
this->Inverse();
this->Transpose();
for (ptId=0; ptId < numNormals; ptId++)
{
n = inNormals->GetNormal(ptId);
for (i=0; i<3; i++) newN[i] = n[i];
newN[3] = 1.0;
this->Stack[0]->PointMultiply(newN,newN);
for (i=0; i<3; i++) newN[i] /= newN[3]; //normalize
outNormals->SetNormal(ptId, newN);
}
this->Pop();
}
......@@ -258,5 +258,6 @@ void vlUnstructuredGrid::Squeeze()
if ( this->Connectivity ) this->Connectivity->Squeeze();
if ( this->Cells ) this->Cells->Squeeze();
if ( this->Links ) this->Links->Squeeze();
}
vlPointSet::Squeeze();
}
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