Commit 1db210f6 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Release 0.3

parent 45fa18c3
......@@ -51,6 +51,9 @@ protected:
void Execute();
// list of data sets to append together
vlDataSetCollection InputList;
//Filter interface
int GetDataReleased();
void SetDataReleased(int flag);
};
#endif
......
......@@ -52,6 +52,10 @@ protected:
// list of data sets to append together
vlPolyDataCollection InputList;
//Filter interface
int GetDataReleased();
void SetDataReleased(int flag);
};
#endif
......
......@@ -68,6 +68,11 @@ public:
protected:
// Usual data generation method
void Execute();
// Filter interface
int GetDataReleased();
void SetDataReleased(int flag);
void InitializeBoolean();
// list of data sets to append together
......
......@@ -15,18 +15,23 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlContourFilter - generate iso-surfaces/iso-lines from scalar values
// .SECTION Description
// vlContourFilter is a filter that takes as input any data set and
// vlContourFilter is a filter that takes as input any dataset and
// generates on output iso-surfaces and/or iso-lines. The exact form
// of the output depends upon the dimensionality of the input data.
// Data consisting of 3D cells will generate iso-surfaces, data
// consisting of 2D cells will generate iso-lines, and data with 1D
// or 0D cells will generate iso-points. Combinations of output type
// is possible if the input dimension is mixed.
// If the input type is volume (e.g., 3D structured point dataset),
// you may wish to use vlMarchingCubes. This class is specifically tailored
// for volumes and is therefore much faster.
// .SECTION Caveats
// vlContourFilter uses variations of marching cubes to generate output
// primitives. The output primitives are disjoint - that is, points may
// be generated that are coincident but distinct. You may want to use
// vlCleanPolyData to remove the coincident points.
// vlCleanPolyData to remove the coincident points. Also, the iso-surface
// is not generated with surface normals. Use vlPolyNormals to create them,
// if desired.
#ifndef __vlContourFilter_h
#define __vlContourFilter_h
......
......@@ -40,20 +40,43 @@ public:
vlGetMacro(Value,float);
// Description:
// Specify separation distance between points.
// Specifysub-voxel size at which to generate point..
vlSetClampMacro(Distance,float,1.0e-06,LARGE_FLOAT);
vlGetMacro(Distance,float);
// Description:
// Every "Increment" point is added to the list of points. This parameter, if
// set to a large value, can be used to limit the number of points while
// retaining good accuracy.
vlSetClampMacro(Increment,int,1,LARGE_INTEGER);
vlGetMacro(Increment,int);
protected:
void Execute();
void SubDivide(float pMin[3], float pMax[3], float values[8],
float distance2, vlCell& cell);
void AddPoint(float pcoords[3], vlCell& cell);
void SubDivide(float origin[3], float h[3], vlFloatScalars &values);
void AddPoint(float x[3]);
float Value;
float Distance;
int Increment;
// wworking variables
int Count;
vlFloatPoints *NewPts;
vlCellArray *NewVerts;
};
inline void vlDividingCubes::AddPoint(float x[3])
{
if ( ! (this->Count++ % this->Increment) )
{
int pts[1];
pts[0] = this->NewPts->InsertNextPoint(x);
this->NewVerts->InsertNextCell(1,pts);
}
}
#endif
......@@ -46,8 +46,9 @@ public:
void Initialize();
void GetCellPoints(int cellId, vlIdList& ptIds) {this->DataSet->GetCellPoints(cellId, ptIds);};
void GetPointCells(int ptId, vlIdList& cellIds) {this->DataSet->GetPointCells(ptId, cellIds);};
int FindCell(float x[3], vlCell *cell, float tol2, int& subId, float pc[3]) {return this->DataSet->FindCell(x,cell,tol2,subId,pc);};
int FindCell(float x[3], vlCell *cell, float tol2, int& subId,
float pc[3], float weights[MAX_CELL_SIZE])
{return this->DataSet->FindCell(x,cell,tol2,subId,pc,weights);};
void ComputeBounds();
// Object interface
......@@ -67,6 +68,8 @@ protected:
void SetDataReleased(int flag);
};
#endif
......@@ -45,8 +45,8 @@ public:
{this->Geometry->GetCellPoints(cellId, ptIds);};
void GetPointCells(int ptId, vlIdList& cellIds)
{this->Geometry->GetPointCells(ptId, cellIds);};
int FindCell(float x[3], vlCell *cell, float tol2, int& subId, float pc[3])
{return this->Geometry->FindCell(x,cell,tol2,subId,pc);};
int FindCell(float x[3], vlCell *cell, float tol2, int& subId, float pc[3], float weights[MAX_CELL_SIZE])
{return this->Geometry->FindCell(x,cell,tol2,subId,pc,weights);};
void ComputeBounds() {this->Geometry->ComputeBounds();};
......@@ -99,6 +99,10 @@ protected:
vlDataSet *TCoords; // texture coords
vlDataSet *Tensors; // tensors
vlDataSet *UserDefined; // user defined
//Filter interface
int GetDataReleased();
void SetDataReleased(int flag);
};
#endif
......
......@@ -16,10 +16,14 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
// .NAME vlRibbonFilter - create oriented ribbons from lines defined in polygonal dataset
// .SECTION Description
// vlRibbonFilter is a filter to create oriented ribbons from lines defined
// in polygonal dataset. The orientation of the ribbon is perpendicular to the
// line normals (if any). If no line normals are defined, then normals are
// computed. An offset angle can be specified to rotate the ribbon with respect
// to the normal. This is useful to construct a tube from ribbons.
// in polygonal dataset. The orientation of the ribbon is along the line
// segments and perpendicular to "projected" line normals. Projected line
// normals are the original line normals projected to be perpendicular to
// the local line segment. An offset angle can be specified to rotate the
// ribbon with respect to the normal.
// The input line must not have duplicate points, or normals at points that
// are parallel to the incoming/outgoing line segments. (Duplicate points
// can be removed with vlCleanPolyData).
#ifndef __vlRibbonFilter_h
#define __vlRibbonFilter_h
......@@ -35,19 +39,33 @@ public:
void PrintSelf(ostream& os, vlIndent indent);
// Description:
// Set the radius (offset distance) of the ribbon from the line.
vlSetClampMacro(Radius,float,0,LARGE_FLOAT);
vlGetMacro(Radius,float);
// Set the "half" width of the ribbon. If the width is allowed to vary,
// this is the minimum width.
vlSetClampMacro(Width,float,0,LARGE_FLOAT);
vlGetMacro(Width,float);
// Description:
// Set the offset angle of the ribbon from the line normal.
vlSetClampMacro(Angle,float,0,360);
vlGetMacro(Angle,float);
// Description:
// Turn on/off the variation of ribbon width with scalar value.
vlSetMacro(VaryWidth,int);
vlGetMacro(VaryWidth,int);
vlBooleanMacro(VaryWidth,int);
// Description:
// Set the maximum ribbon width in terms of a multiple of the minimum width.
vlSetMacro(WidthFactor,float);
vlGetMacro(WidthFactor,float);
protected:
void Execute();
float Radius;
float Width;
float Angle;
int VaryWidth; //controls whether width varies with scalar data
float WidthFactor;
};
#endif
......
......@@ -33,13 +33,9 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlStreamLine_h
#define __vlStreamLine_h
#include "DS2PolyF.hh"
#include "Streamer.hh"
#define INTEGRATE_FORWARD 0
#define INTEGRATE_BACKWARD 1
#define INTEGRATE_BOTH_DIRECTIONS 2
class vlStreamLine : public vlDataSetToPolyFilter
class vlStreamLine : public vlStreamer
{
public:
vlStreamLine();
......@@ -47,97 +43,19 @@ public:
char *GetClassName() {return "vlStreamLine";};
void PrintSelf(ostream& os, vlIndent indent);
void SetStartLocation(int cellId, int subId, float pcoords[3]);
int GetStartLocation(int& subId, float pcoords[3]);
void SetStartPosition(float x[3]);
float *GetStartPosition();
// Description:
// Specify the maximum length of the streamline expressed in elapsed time.
vlSetClampMacro(MaximumPropagationTime,float,0.0,LARGE_FLOAT);
vlGetMacro(MaximumPropagationTime,float);
// Description:
// Specify the maximum length of the streamline expressed in the number
// of integration steps.
vlSetClampMacro(MaximumSteps,int,1,LARGE_INTEGER);
vlGetMacro(MaximumSteps,int);
// Description:
// Specify the direction in which to integrate the streamline.
vlSetClampMacro(IntegrationDirection,int,
INTEGRATE_FORWARD,INTEGRATE_BOTH_DIRECTIONS);
vlGetMacro(IntegrationDirection,int);
// Description:
// Specify a nominal integration step size (expressed as a fraction of
// the size of each cell).
vlSetClampMacro(IntegrationStepLength,float,0.001,0.5);
vlGetMacro(IntegrationStepLength,float);
// Description:
// Specify the nominal length of the line segements used to graphically
// depict the streamline. This is a fractional value of the input bounding
// box.
vlSetClampMacro(RepresentationStepLength,float,0.0001,0.1);
vlGetMacro(RepresentationStepLength,float);
// Description:
// Turn on/off the computation of vorticity.
vlSetMacro(Vorticity,int);
vlGetMacro(Vorticity,int);
vlBooleanMacro(Vorticity,int);
// Description:
// Specify the length of a dash expressed in time.
vlSetClampMacro(DashTime,float,0.0,LARGE_FLOAT);
// Specify the length of a dash expressed in time. This is the combined
// length of both the "on" and "off" parts of the dash.
vlSetClampMacro(DashTime,float,0.000001,LARGE_FLOAT);
vlGetMacro(DashTime,float);
// Description:
// For each dash, specify the fraction of the dash that is "on". A factor
// of 1.0 will result in a continuous line, a factor of 0.5 will result in
// dashed that are half on and half off.
vlSetClampMacro(DashFactor,float,0.0,1.0);
vlGetMacro(DashFactor,float);
protected:
// Usual data generation method
// Convert streamer array into vlPolyData
void Execute();
// Starting from cell location
int StartCell;
int StartSubId;
float StartPCoords[3];
// starting from global x-y-z position
float StartPosition[3];
// length of streamline is generated by time, or by MaximumSteps
float MaximumPropagationTime;
// MaximumSteps prevents "nearly" infinite loops
int MaximumSteps;
// integration direction
int IntegrationDirection;
// the length (fraction of cell size) of integration steps
float IntegrationStepLength;
// the length of line segments used to represent stream line (expressed
// as fraction of bounding box of input)
float RepresentationStepLength;
// boolean controls whether vorticity is computed
int Vorticity;
// the combined length of on/off portion of dash
float DashTime;
// the fraction of on versus off in dash
float DashFactor;
};
#endif
......
......@@ -23,6 +23,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
// the variation of the tube radius is such that it preserves mass flux in
// incompressible flow. The number of sides for the tube can also be
// specified.
// .SECTION Caveats
// The number of tube sides must be greater than 3. If you wish to use fewer
// sides (i.e., a ribbon), use vlRibbonFilter.
// The input line must not have duplicate points, or normals at points that
// are parallel to the incoming/outgoing line segments. (Duplicate points
// can be removed with vlCleanPolyData).
#ifndef __vlTubeFilter_h
#define __vlTubeFilter_h
......@@ -38,7 +44,7 @@ public:
void PrintSelf(ostream& os, vlIndent indent);
// Description:
// Set the maximum tube radius (maximum because the tube radius may vary).
// Set the minimum tube radius (minimum because the tube radius may vary).
vlSetClampMacro(Radius,float,0.0,LARGE_FLOAT);
vlGetMacro(Radius,float);
......@@ -49,16 +55,14 @@ public:
vlBooleanMacro(VaryRadius,int);
// Description:
// Set the number of sides for the tube. If n=0, line is generated. If
// n=1, ribbon is generated. For n=2, two ribbons in cross configuration
// are generated.
vlSetClampMacro(NumberOfSides,int,0,LARGE_INTEGER);
// Set the number of sides for the tube. At a minimum, number of sides is 3.
vlSetClampMacro(NumberOfSides,int,3,LARGE_INTEGER);
vlGetMacro(NumberOfSides,int);
// Description:
// Specify an initial offset rotation.
vlSetMacro(Rotation,float);
vlGetMacro(Rotation,float);
// Set the maximum tube radius in terms of a multiple of the minimum radius.
vlSetMacro(RadiusFactor,float);
vlGetMacro(RadiusFactor,float);
protected:
// Usual data generation method
......@@ -67,7 +71,7 @@ protected:
float Radius; //minimum radius of tube
int VaryRadius; //controls whether radius varies with scalar data
int NumberOfSides; //number of sides to create tube
float Rotation; //rotation of initial side of tube
float RadiusFactor; //maxium allowablew radius
};
#endif
......
......@@ -176,3 +176,13 @@ void vlAppendFilter::PrintSelf(ostream& os, vlIndent indent)
this->InputList.PrintSelf(os,indent.GetNextIndent());
}
int vlAppendFilter::GetDataReleased()
{
return this->DataReleased;
}
void vlAppendFilter::SetDataReleased(int flag)
{
this->DataReleased = flag;
}
......@@ -214,6 +214,16 @@ void vlAppendPolyData::Execute()
}
int vlAppendPolyData::GetDataReleased()
{
return this->DataReleased;
}
void vlAppendPolyData::SetDataReleased(int flag)
{
this->DataReleased = flag;
}
void vlAppendPolyData::PrintSelf(ostream& os, vlIndent indent)
{
vlPolyData::PrintSelf(os,indent);
......
......@@ -256,15 +256,6 @@ void vlBooleanStructuredPoints::Append(vlStructuredPoints *sp)
}
}
void vlBooleanStructuredPoints::PrintSelf(ostream& os, vlIndent indent)
{
vlStructuredPoints::PrintSelf(os,indent);
vlFilter::_PrintSelf(os,indent);
os << indent << "Input DataSets:\n";
this->InputList.PrintSelf(os,indent.GetNextIndent());
}
// Description:
// Set the i-j-k dimensions on which to perform boolean operation.
void vlBooleanStructuredPoints::SetSampleDimensions(int i, int j, int k)
......@@ -333,3 +324,23 @@ void vlBooleanStructuredPoints::SetModelBounds(float xmin, float xmax, float ymi
}
}
int vlBooleanStructuredPoints::GetDataReleased()
{
return this->DataReleased;
}
void vlBooleanStructuredPoints::SetDataReleased(int flag)
{
this->DataReleased = flag;
}
void vlBooleanStructuredPoints::PrintSelf(ostream& os, vlIndent indent)
{
vlStructuredPoints::PrintSelf(os,indent);
vlFilter::_PrintSelf(os,indent);
os << indent << "Input DataSets:\n";
this->InputList.PrintSelf(os,indent.GetNextIndent());
}
......@@ -19,28 +19,20 @@ vlDividingCubes::vlDividingCubes()
{
this->Value = 0.0;
this->Distance = 0.1;
this->Increment = 1;
this->Count = 0;
}
void vlDividingCubes::PrintSelf(ostream& os, vlIndent indent)
{
vlStructuredPointsToPolyDataFilter::PrintSelf(os,indent);
os << indent << "Value: " << this->Value << "\n";
os << indent << "Distance: " << this->Distance << "\n";
}
void vlDividingCubes::Execute()
{
int cellId;
vlCell *brick;
vlPointData *pd;
int i, j, k, idx;
vlFloatPoints *newPts;
vlScalars *inScalars;
vlIdList *brickPts;
vlFloatScalars brickScalars(8);
float len2;
vlCellArray *newVerts;
vlScalars *inScalars;
vlIdList voxelPts(8);
vlFloatScalars voxelScalars(8);
float ar[3], origin[3], x[3];
int dim[3], jOffset, kOffset, product;
int above, below, vertNum;
vlStructuredPoints *input=(vlStructuredPoints *)this->Input;
......@@ -49,6 +41,7 @@ void vlDividingCubes::Execute()
// Initialize self; check input; create output objects
//
this->Initialize();
this->Count = 0;
// make sure we have scalar data
if ( ! (inScalars = input->GetPointData()->GetScalars()) )
......@@ -57,45 +50,68 @@ void vlDividingCubes::Execute()
return;
}
// just deal with volume data
// just deal with volumes
if ( input->GetDataDimension() != 3 )
{
vlErrorMacro("Bad input: only treats 3D point sets");
vlErrorMacro("Bad input: only treats 3D structured point datasets");
return;
}
// creating points
newPts = new vlFloatPoints(5000,25000);
newVerts = new vlCellArray(5000,25000);
// prepare to interpolate data
pd = input->GetPointData();
this->PointData.InterpolateAllocate(pd,5000,25000);
input->GetDimensions(dim);
input->GetAspectRatio(ar);
input->GetOrigin(origin);
// creating points
this->NewPts = new vlFloatPoints(25000,50000);
this->NewVerts = new vlCellArray(25000,50000);
//
// Loop over all cells checking to see which straddle the specified value
// Loop over all cells checking to see which straddle the specified value. Since
// we know that we are working with a volume, can create appropriate data directly.
//
for ( cellId=0; cellId = input->GetNumberOfCells(); cellId++ )
for ( k=0; k < (dim[2]-1); k++)
{
brick = input->GetCell(cellId);
brickPts = brick->GetPointIds();
inScalars->GetScalars(*brickPts,brickScalars);
kOffset = k*product;
x[2] = origin[2] + k*ar[2];
// loop over 8 points of brick to check if cell straddles value
for ( above=below=0, vertNum=0; vertNum < 8; vertNum++ )
for ( j=0; j < (dim[1]-1); j++)
{
if ( brickScalars.GetScalar(vertNum) > this->Value )
above = 1;
else if ( brickScalars.GetScalar(vertNum) < this->Value )
below = 1;
jOffset = j*dim[0];
x[1] = origin[1] + j*ar[1];
if ( above && below ) // recursively generate points
for ( i=0; i < (dim[0]-1); i++)
{
len2 = brick->GetLength2();
// this->SubDivide();
idx = i + jOffset + kOffset;
x[0] = origin[0] + i*ar[0];
// get point ids of this voxel
voxelPts.SetId(0, idx);
voxelPts.SetId(1, idx + 1);
voxelPts.SetId(2, idx + dim[0]);
voxelPts.SetId(3, idx + dim[0] + 1);
voxelPts.SetId(4, idx + product);
voxelPts.SetId(5, idx + product + 1);
voxelPts.SetId(6, idx + product + dim[0]);
voxelPts.SetId(7, idx + product + dim[0] + 1);
// get scalars of this voxel
inScalars->GetScalars(voxelPts,voxelScalars);
// loop over 8 points of voxel to check if cell straddles value
for ( above=below=0, vertNum=0; vertNum < 8; vertNum++ )
{
if ( voxelScalars.GetScalar(vertNum) >= this->Value )
above = 1;
else if ( voxelScalars.GetScalar(vertNum) < this->Value )
below = 1;
if ( above && below ) // recursively generate points
{
this->SubDivide(x, ar, voxelScalars);
}
}
}
}
}
}
//
// Update ourselves
//
......@@ -106,14 +122,106 @@ void vlDividingCubes::Execute()
this->SetVerts(newVerts);
}
void vlDividingCubes::SubDivide(float pMin[3], float pMax[3], float values[8],
float distance2, vlCell& cell)
static int ScalarInterp[8][8] = {{0,8,12,24,16,22,20,26},
{8,1,24,13,22,17,26,21},
{12,24,2,9,20,26,18,23},
{24,13,9,3,26,21,23,19},
{16,22,20,26,4,10,14,25},
{22,17,26,21,10,5,25,15},
{20,26,18,23,14,25,6,11},
{26,21,23,19,25,15,11,7}};
void vlDividingCubes::SubDivide(float origin[3], float h[3], vlFloatScalars &values)
{
int i;
float hNew[3];
for (i=0; i<3; i++) hNew[i] = h[i] / 2.0;
// if subdivided far enough, create point and end termination
if ( h[0] < this->Distance && h[1] < this->Distance && h[2] < this->Distance )
{
int i;
float x[3];
for (i=0; i <3; i++) x[i] = origin[i] + hNew[i];
this->AddPoint(x);
return;
}
// otherwise, create eight sub-voxels and recurse