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

*** empty log message ***

parent aaa47929
......@@ -49,6 +49,7 @@ public:
void InsertScalar(int i, float s) {S.InsertValue(i,(int)s);};
void InsertScalar(int i, int s) {S.InsertValue(i,s);};
int InsertNextScalar(int s) {return S.InsertNextValue(s);};
int InsertNextScalar(float s) {return S.InsertNextValue((int)s);};
private:
vlBitArray S;
......
......@@ -51,6 +51,7 @@ public:
void InsertScalar(int i, float s) {S.InsertValue(i,(char)s);};
void InsertScalar(int i, char s) {S.InsertValue(i,s);};
int InsertNextScalar(char s) {return S.InsertNextValue(s);};
int InsertNextScalar(float s) {return S.InsertNextValue((char)s);};
private:
vlCharArray S;
......
......@@ -15,9 +15,13 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Copy PolyData at every input point.
//
// .NAME vlGlyph3D - copy oriented and scaled geometry to every input point
// .SECTION Description
// vlGlyph3D is a filter that copies a geometry representation (in
// vlPolyData form) to every input point. The geometry may be oriented
// along the input vectors or normals, and it may be scaled according
// to scalar data or vector magnitude.
#ifndef __vlGlyph3D_h
#define __vlGlyph3D_h
......@@ -25,8 +29,8 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#define SCALE_BY_SCALAR 0
#define SCALE_BY_VECTOR 1
#define ORIENT_BY_VECTOR 0
#define ORIENT_BY_NORMAL 1
#define USE_VECTOR 0
#define USE_NORMAL 1
class vlGlyph3D : public vlDataSetToPolyFilter
{
......@@ -60,28 +64,20 @@ public:
vlSetMacro(Orient,int);
vlGetMacro(Orient,int);
vlSetMacro(OrientMode,int);
vlGetMacro(OrientMode,int);
void OrientByVector() {this->SetScaleMode(ORIENT_BY_VECTOR);};
void OrientByNormal() {this->SetScaleMode(ORIENT_BY_NORMAL);};
vlSetMacro(VectorMode,int);
vlGetMacro(VectorMode,int);
void UseVector() {this->SetVectorMode(USE_VECTOR);};
void UseNormal() {this->SetVectorMode(USE_NORMAL);};
protected:
// Usual data generation method
void Execute();
// Geometry to copy to each point
vlPolyData *Source;
// Determine whether scaling of geometry is performed
int Scaling;
// Scale by scalar value or vector magnitude
int ScaleMode;
// Scale factor to use to scale geometry
float ScaleFactor;
// Range to use to perform scalar scaling
float Range[2];
// boolean controls whether to "orient" data
int Orient;
// Orient via normal or via vector data
int OrientMode;
vlPolyData *Source; // Geometry to copy to each point
int Scaling; // Determine whether scaling of geometry is performed
int ScaleMode; // Scale by scalar value or vector magnitude
float ScaleFactor; // Scale factor to use to scale geometry
float Range[2]; // Range to use to perform scalar scaling
int Orient; // boolean controls whether to "orient" data
int VectorMode; // Orient/scale via normal or via vector data
};
#endif
......
......@@ -58,6 +58,13 @@ public:
this->P[id-1] = x[1];
return id/3;
}
int InsertNextPoint(float *x) {
int id = this->P.GetMaxId() + 3;
this->P.InsertValue(id,(int)x[2]);
this->P[id-2] = (int)x[0];
this->P[id-1] = (int)x[1];
return id/3;
}
protected:
vlIntArray P;
......
......@@ -31,8 +31,9 @@ public:
virtual vlNormals *MakeObject(int sze, int ext=1000) = 0;
virtual int GetNumberOfNormals() = 0;
virtual float *GetNormal(int i) = 0;
virtual void SetNormal(int i,float x[3]) = 0; // fast insert
virtual void InsertNormal(int i, float x[3]) = 0; // allocates memory as necessary
virtual void SetNormal(int i,float n[3]) = 0; // fast insert
virtual void InsertNormal(int i, float n[3]) = 0; // allocates memory as necessary
virtual int InsertNextNormal(float n[3]) = 0;
virtual void Squeeze() = 0;
void GetNormals(vlIdList& ptId, vlFloatNormals& fp);
......
......@@ -34,6 +34,7 @@ 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 int InsertNextPoint(float x[3]) = 0;
virtual void Squeeze() = 0; // reclaim memory
void GetPoints(vlIdList& ptId, vlFloatPoints& fp);
......
......@@ -64,6 +64,8 @@ public:
int GetNumberOfPolys();
int GetNumberOfStrips();
// Allocate storage for cells when using following InsertNextCell method
void Allocate(int numCells=1000, int extSize=1000);
// 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()
......
......@@ -18,17 +18,17 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
//
// Create geometry for structured data
//
#ifndef __vlStructuredGeometry_h
#define __vlStructuredGeometry_h
#ifndef __vlStructuredGeometryFilter_h
#define __vlStructuredGeometryFilter_h
#include "SD2PolyF.hh"
class vlStructuredGeometry : public vlStructuredDataSetToPolyFilter
class vlStructuredGeometryFilter : public vlStructuredDataSetToPolyFilter
{
public:
vlStructuredGeometry();
~vlStructuredGeometry() {};
char *GetClassName() {return "vlStructuredGeometry";};
vlStructuredGeometryFilter();
~vlStructuredGeometryFilter() {};
char *GetClassName() {return "vlStructuredGeometryFilter";};
void PrintSelf(ostream& os, vlIndent indent);
void SetExtent(int iMin, int iMax, int jMin, int jMax, int kMin, int kMax);
......
......@@ -51,6 +51,7 @@ public:
void InsertScalar(int i, float s) {S.InsertValue(i,(short)s);};
void InsertScalar(int i, short s) {S.InsertValue(i,s);};
int InsertNextScalar(short s) {return S.InsertNextValue(s);};
int InsertNextScalar(float s) {return S.InsertNextValue((short)s);};
private:
vlShortArray S;
......
......@@ -15,16 +15,22 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Sample implicit function on StructuredPointSet
//
// .NAME vlSampleFunction - sample an implicit function over a structured point set
// .SECTION Description
// vlSampleFunction is a source object that evaluates an implicit function
// and normals at each point in a vlStructuredPointSet. The user can
// specify the sample dimensions and location in space to perform the
// sampling. To create closed surfaces (in conjunction with the
// vlContourFilter), capping can be turned on to set a particular
// value on the boundaries of the sample space.
#ifndef __vlSampleFunction_h
#define __vlSampleFunction_h
#include "DS2SPtsF.hh"
#include "SPtsSrc.hh"
#include "ImpFunc.hh"
class vlSampleFunction : public vlDataSetToStructuredPointsFilter
class vlSampleFunction : public vlStructuredPointsSource
{
public:
vlSampleFunction();
......@@ -39,8 +45,8 @@ public:
void SetSampleDimensions(int dim[3]);
vlGetVectorMacro(SampleDimensions,int);
void SetModelBounds(float *bounds);
void SetModelBounds(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax);
void SetModelBounds(float *bounds);
vlGetVectorMacro(ModelBounds,float);
vlSetMacro(Capping,int);
......@@ -50,6 +56,12 @@ public:
vlSetMacro(CapValue,float);
vlGetMacro(CapValue,float);
vlSetMacro(ComputeNormals,int);
vlGetMacro(ComputeNormals,int);
vlBooleanMacro(ComputeNormals,int);
unsigned long int GetMTime();
protected:
void Execute();
void Cap(vlFloatScalars *s);
......@@ -59,6 +71,7 @@ protected:
int Capping;
float CapValue;
vlImplicitFunction *ImplicitFunction;
int ComputeNormals;
};
#endif
......
......@@ -34,6 +34,7 @@ public:
virtual float GetScalar(int i) = 0;
virtual void SetScalar(int i, float s) = 0; // fast insert
virtual void InsertScalar(int i, float s) = 0; // allocates memory as necessary
virtual int InsertNextScalar(float s) = 0;
virtual void Squeeze() = 0;
void GetScalars(vlIdList& ptId, vlFloatScalars& fs);
......
......@@ -32,8 +32,9 @@ public:
virtual vlTCoords *MakeObject(int sze, int d=2, int ext=1000) = 0;
virtual int GetNumberOfTCoords() = 0;
virtual float *GetTCoord(int i) = 0;
virtual void SetTCoord(int i,float *x) = 0; // fast insert
virtual void InsertTCoord(int i, float *x) = 0; // allocates memory as necessary
virtual void SetTCoord(int i,float *tc) = 0; // fast insert
virtual void InsertTCoord(int i, float *tc) = 0; // allocates memory as necessary
virtual int InsertNextTCoord(float *tc) = 0;
virtual void Squeeze() = 0;
void GetTCoords(vlIdList& ptId, vlFloatTCoords& fp);
......
......@@ -32,8 +32,9 @@ public:
virtual vlVectors *MakeObject(int sze, int ext=1000) = 0;
virtual int GetNumberOfVectors() = 0;
virtual float *GetVector(int i) = 0;
virtual void SetVector(int i,float x[3]) = 0; // fast insert
virtual void InsertVector(int i, float x[3]) = 0; // allocates memory as necessary
virtual void SetVector(int i,float v[3]) = 0; // fast insert
virtual void InsertVector(int i, float v[3]) = 0; // allocates memory as necessary
virtual int InsertNextVector(float v[3]) = 0;
virtual void Squeeze() = 0;
void GetVectors(vlIdList& ptId, vlFloatVectors& fp);
......
......@@ -123,6 +123,7 @@ void vlGeometryFilter::Execute()
// Allocate
//
newPts = new vlFloatPoints(1000,10000);
this->Allocate(1000,10000);
this->PointData.CopyAllocate(pd,1000,10000);
//
// Traverse cells to extract geometry
......
......@@ -16,7 +16,15 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include "Glyph3D.hh"
#include "Trans.hh"
#include "FVectors.hh"
#include "FNormals.hh"
#include "vlMath.hh"
// Description
// Construct object with scaling on, scaling mode is by scalar value,
// scale factor = 1.0, the range is (0,1), orient geometry is on, and
// orientation is by vector.
vlGlyph3D::vlGlyph3D()
{
this->Source = NULL;
......@@ -26,7 +34,7 @@ vlGlyph3D::vlGlyph3D()
this->Range[0] = 0.0;
this->Range[1] = 1.0;
this->Orient = 1;
this->OrientMode = ORIENT_BY_VECTOR;
this->VectorMode = USE_VECTOR;
}
vlGlyph3D::~vlGlyph3D()
......@@ -52,7 +60,7 @@ void vlGlyph3D::PrintSelf(ostream& os, vlIndent indent)
os << indent << "Orient Mode: " << (this->OrientMode == ORIENT_BY_VECTOR ? "Orient by vector\n" : "Orient by normal\n");
os << indent << "Orient Mode: " << (this->VectorMode == USE_VECTOR ? "Orient by vector\n" : "Orient by normal\n");
}
}
......@@ -61,19 +69,23 @@ void vlGlyph3D::Execute()
vlPointData *pd;
vlScalars *inScalars;
vlVectors *inVectors;
int numPts;
int i;
vlNormals *inNormals, *sourceNormals;
int numPts, numSourcePts, numSourceCells;
int inPtId, i;
vlPoints *sourcePts;
vlCellArray *sourceVerts;
vlCellArray *sourceLines;
vlCellArray *sourcePolys;
vlCellArray *sourceStrips;
vlCellArray *sourceCells;
vlFloatPoints *newPts;
vlCellArray *newVerts;
vlCellArray *newLines;
vlCellArray *newPolys;
vlCellArray *newStrips;
float *x, s, *v;
vlFloatScalars *newScalars=NULL;
vlFloatVectors *newVectors=NULL;
vlFloatNormals *newNormals=NULL;
float *x, s, *v, vNew[3];
vlTransform trans;
vlCell *cell;
vlIdList *cellPts;
int npts, pts[MAX_CELL_SIZE];
int orient, scaleSource, ptIncr, cellId;
float scale, den;
vlMath math;
//
// Initialize
//
......@@ -82,67 +94,178 @@ void vlGlyph3D::Execute()
pd = this->Input->GetPointData();
inScalars = pd->GetScalars();
inVectors = pd->GetVectors();
inNormals = pd->GetNormals();
numPts = this->Input->GetNumberOfPoints();
//
// Allocate storage for output PolyData
//
sourcePts = this->Source->GetPoints();
numSourcePts = sourcePts->GetNumberOfPoints();
numSourceCells = this->Source->GetNumberOfCells();
sourceNormals = this->Source->GetPointData()->GetNormals();
newPts = new vlFloatPoints(numPts*numSourcePts);
if (inScalars != NULL)
newScalars = new vlFloatScalars(numPts*numSourcePts);
if (inVectors != NULL || inNormals != NULL )
newVectors = new vlFloatVectors(numPts*numSourcePts);
if (sourceNormals != NULL)
newNormals = new vlFloatNormals(numPts*numSourcePts);
if ( ! this->Source )
// Setting up for calls to PolyData::InsertNextCell()
if ( (sourceCells=this->Source->GetVerts())->GetNumberOfCells() > 0 )
{
vlErrorMacro(<< "No data to copy\n");
return;
this->SetVerts(new vlCellArray(numPts*sourceCells->GetSize()));
}
else
if ( (sourceCells=this->Source->GetLines())->GetNumberOfCells() > 0 )
{
this->Source->Update();
this->SetLines(new vlCellArray(numPts*sourceCells->GetSize()));
}
if ( (sourceCells=this->Source->GetPolys())->GetNumberOfCells() > 0 )
{
this->SetPolys(new vlCellArray(numPts*sourceCells->GetSize()));
}
if ( (sourceCells=this->Source->GetStrips())->GetNumberOfCells() > 0 )
{
this->SetStrips(new vlCellArray(numPts*sourceCells->GetSize()));
}
//
// Allocate storage for output PolyData
// Copy (input scalars) to (output scalars) and either (input vectors or
// normals) to (output vectors). All other point attributes are copied
// from Source.
//
sourcePts = this->Source->GetPoints();
sourceVerts = this->Source->GetVerts();
sourceLines = this->Source->GetLines();
sourcePolys = this->Source->GetPolys();
sourceStrips = this->Source->GetStrips();
newPts = new vlFloatPoints(numPts*sourcePts->GetNumberOfPoints());
newVerts = new vlCellArray(numPts*sourceVerts->GetSize());
newLines = new vlCellArray(numPts*sourceLines->GetSize());
newPolys = new vlCellArray(numPts*sourcePolys->GetSize());
newStrips = new vlCellArray(numPts*sourceStrips->GetSize());
pd = this->Source->GetPointData();
this->PointData.CopyScalarsOff();
this->PointData.CopyVectorsOff();
this->PointData.CopyNormalsOff();
this->PointData.CopyAllocate(pd,numPts*numSourcePts);
//
// First copy all topology (transformation independent)
//
for (inPtId=0; inPtId < numPts; inPtId++)
{
ptIncr = inPtId * numSourcePts;
for (cellId=0; cellId < numSourceCells; cellId++)
{
cell = this->Source->GetCell(cellId);
cellPts = cell->GetPointIds();
npts = cellPts->GetNumberOfIds();
for (i=0; i < npts; i++) pts[i] = cellPts->GetId(i) + ptIncr;
this->InsertNextCell(cell->GetCellType(),npts,pts);
}
}
//
// Traverse all points, copying data to point
// Traverse all Input points, transforming Source points and copying
// point attributes.
//
if ( this->VectorMode == USE_VECTOR && inVectors != NULL ||
this->VectorMode == USE_NORMAL && inNormals != NULL )
orient = 1;
else
orient = 0;
if ( this->Scaling &&
((this->ScaleMode == SCALE_BY_SCALAR && inScalars != NULL) ||
(this->ScaleMode == SCALE_BY_VECTOR && (inVectors || inNormals))) )
scaleSource = 1;
else
scaleSource = 0;
for (i=0; i<numPts; i++)
for (inPtId=0; inPtId < numPts; inPtId++)
{
x = this->Input->GetPoint(i);
if (inScalars) s = inScalars->GetScalar(i);
if (inVectors) v = inVectors->GetVector(i);
ptIncr = inPtId * numSourcePts;
trans.Identity();
// translate Source to Input point
x = this->Input->GetPoint(inPtId);
trans.Translate(x[0], x[1], x[2]);
if ( this->VectorMode == USE_NORMAL )
v = inNormals->GetNormal(inPtId);
else
v = inVectors->GetVector(inPtId);
scale = math.Norm(v);
if ( orient )
{
// Copy Input vector
for (i=0; i < numSourcePts; i++)
newVectors->InsertVector(ptIncr+i,v);
if ( this->Orient )
{
vNew[0] = (v[0]+scale) / 2.0;
vNew[1] = v[1] / 2.0;
vNew[2] = v[2] / 2.0;
trans.RotateWXYZ(180.0,vNew[0],vNew[1],vNew[2]);
}
}
// determine scale factor from scalars if appropriate
if ( inScalars != NULL )
{
// Copy Input scalar
for (i=0; i < numSourcePts; i++)
newScalars->InsertScalar(ptIncr+i,scale);
if ( this->ScaleMode == SCALE_BY_SCALAR )
{
if ( (den = this->Range[1] - this->Range[0]) == 0.0 ) den = 1.0;
scale = inScalars->GetScalar(inPtId);
scale = (scale < this->Range[0] ? this->Range[0] :
(scale > this->Range[1] ? this->Range[1] : scale));
scale = (scale - this->Range[0]) / den;
}
}
// scale data if appropriate
if ( scaleSource )
{
scale *= this->ScaleFactor;
if ( scale == 0,0 ) scale = 1.0e-10;
trans.Scale(scale,scale,scale);
}
// multiply points and normals by resulting matrix
trans.MultiplyPoints(sourcePts,newPts);
if ( sourceNormals != NULL )
trans.MultiplyNormals(sourceNormals,newNormals);
// Copy point data from source
for (i=0; i < numSourcePts; i++)
this->PointData.CopyData(pd,i,ptIncr+i);
}
//
// Update ourselves
//
this->SetPoints(newPts);
this->SetVerts(newVerts);
this->SetLines(newLines);
this->SetPolys(newPolys);
this->SetStrips(newStrips);
this->PointData.SetScalars(newScalars);
this->PointData.SetVectors(newVectors);
this->PointData.SetNormals(newNormals);
this->Squeeze();
}
//
// Description:
// Override update method because execution can branch two ways (Input
// and Source)
//
void vlGlyph3D::Update()
{
// make sure input is available
if ( !this->Input )
if ( this->Input == NULL )
{
vlErrorMacro(<< "No input!");
return;
}
if ( this->Source == NULL )
{
vlErrorMacro(<< "No input!\n");
vlErrorMacro(<< "No data to copy");
return;
}
......
......@@ -22,7 +22,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "TriStrip.hh"
#include "Quad.hh"
#include "Polygon.hh"
//
// Initialize static member. This member is used to simplify traversal
// of verts, lines, polygons, and triangle strips lists. It basically
// "marks" empty lists so that the traveral method "GetNextCell"
......@@ -44,6 +44,8 @@ vlPolyData::vlPolyData ()
this->Links = NULL;
}
// Description:
// Perform shallow construction of vlPolyData.
vlPolyData::vlPolyData(const vlPolyData& pd) :
vlPointSet(pd)
{
......@@ -148,6 +150,8 @@ vlCell *vlPolyData::GetCell(int cellId)
}
// Description:
// Set the cell array defining vertices.
void vlPolyData::SetVerts (vlCellArray* v)
{
if ( v != this->Verts && v != this->Dummy )
......@@ -158,12 +162,18 @@ void vlPolyData::SetVerts (vlCellArray* v)
this->Modified();
}
}
// Description:
// Get the cell array defining vertices. If there are no vertices, an
// empty array will be returned (convenience to simplify traversal).
vlCellArray* vlPolyData::GetVerts()
{
if ( !this->Verts ) return this->Dummy;
else return this->Verts;
}
// Description:
// Set the cell array defining lines.
void vlPolyData::SetLines (vlCellArray* l)
{
if ( l != this->Lines && l != this->Dummy )
......@@ -174,12 +184,18 @@ void vlPolyData::SetLines (vlCellArray* l)
this->Modified();
}
}
// Description:
// Get the cell array defining lines. If there are no lines, an
// empty array will be returned (convenience to simplify traversal).
vlCellArray* vlPolyData::GetLines()
{
if ( !this->Lines ) return this->Dummy;
else return this->Lines;
}
// Description:
// Set the cell array defining polygons.
void vlPolyData::SetPolys (vlCellArray* p)
{
if ( p != this->Polys && p != this->Dummy )
......@@ -190,12 +206,18 @@ void vlPolyData::SetPolys (vlCellArray* p)
this->Modified();
}
}<