Commit f5f86046 authored by Cory Quammen's avatar Cory Quammen

Replace glyph data rescaling with scale factor

Revert back to a simple scale factor for controlling overall glyph
size and remove the data rescaling feature that mapped data values
linearly to a range of vector sizes.

Also rearrange UI components so that the orientation array is above
scale options and glyph transform properties are after everything
else.
parent 3f5893af
......@@ -233,8 +233,6 @@ vtkCxxSetObjectMacro(vtkPVGlyphFilter, SourceTransform, vtkTransform);
vtkPVGlyphFilter::vtkPVGlyphFilter()
: VectorScaleMode(SCALE_BY_MAGNITUDE)
, SourceTransform(nullptr)
, MaximumGlyphSize(1.0)
, RescaleGlyphs(true)
, GlyphMode(ALL_POINTS)
, MaximumNumberOfSamplePoints(5000)
, Seed(1)
......@@ -244,8 +242,6 @@ vtkPVGlyphFilter::vtkPVGlyphFilter()
{
this->SetController(vtkMultiProcessController::GetGlobalController());
this->SetNumberOfInputPorts(2);
this->GlyphDataRange[0] = VTK_DOUBLE_MAX;
this->GlyphDataRange[1] = -VTK_DOUBLE_MAX;
}
//-----------------------------------------------------------------------------
......@@ -559,12 +555,14 @@ bool vtkPVGlyphFilter::Execute(vtkDataSet* input, vtkInformationVector* sourceVe
return true;
}
#if 0
if (this->GlyphDataRange[0] > this->GlyphDataRange[1])
{
vtkErrorMacro(
"First element in GlyphDataRange must be less than or equal to the second element.");
return false;
}
#endif
if (orientArray && orientArray->GetNumberOfComponents() > 3)
{
......@@ -600,24 +598,6 @@ bool vtkPVGlyphFilter::Execute(vtkDataSet* input, vtkInformationVector* sourceVe
return 1;
}
double dataRange[2] = { 0.0, 1.0 };
if (scaleArray && this->GlyphDataRange[0] != this->GlyphDataRange[1])
{
dataRange[0] = this->GlyphDataRange[0];
dataRange[1] = this->GlyphDataRange[1];
}
else
{
dataRange[0] = this->GlyphDataRange[1] - DBL_EPSILON;
dataRange[1] = this->GlyphDataRange[1];
}
double den = dataRange[1] - dataRange[0];
if (den == 0.0)
{
den = 1.0;
}
// Allocate storage for output PolyData
vtkPointData* outputPD = output->GetPointData();
outputPD->CopyVectorsOff();
......@@ -752,30 +732,11 @@ bool vtkPVGlyphFilter::Execute(vtkDataSet* input, vtkInformationVector* sourceVe
}
}
}
else
{
// If not scaling by array, set the glyph to the maximum glyph size
scalex = scaley = scalez = this->MaximumGlyphSize;
}
// Clamp and scale glyph if a scale array is set and the RescaleGlyphs option is on.
// If the scaleArray is a vector and the vector scale mode is not set to SCALE_BY_COMPONENTS,
// also rescale (by magnitude). However, if SCALE_BY_COMPONENTS is on and the scaleArray is
// a scalar, go ahead and rescale the array.
if (scaleArray && this->RescaleGlyphs &&
(this->VectorScaleMode != SCALE_BY_COMPONENTS || scaleArray->GetNumberOfComponents() == 1))
{
vtkMath::ClampValue(&scalex, dataRange);
vtkMath::ClampValue(&scaley, dataRange);
vtkMath::ClampValue(&scalez, dataRange);
scalex = (scalex - dataRange[0]) / den;
scaley = (scaley - dataRange[0]) / den;
scalez = (scalez - dataRange[0]) / den;
double multiplier = this->MaximumGlyphSize;
scalex = scalex * multiplier;
scaley = scaley * multiplier;
scalez = scalez * multiplier;
}
// Apply scale factor
scalex *= this->ScaleFactor;
scaley *= this->ScaleFactor;
scalez *= this->ScaleFactor;
// Check ghost points.
// If we are processing a piece, we do not want to duplicate
......
......@@ -88,35 +88,6 @@ public:
vtkGetObjectMacro(Controller, vtkMultiProcessController);
//@}
//@{
/**
* Get/set the range of the data. The first element defines the value that maps to glyph size
* zero, and the second element defines the value that maps to the maximum glyph size. Data values
* inside the range are mapped linearly to the range [0, MaximumGlyphSize], while data values
* outside this range will be clamped to this range prior to mapping to the glyph size.
*/
vtkSetVector2Macro(GlyphDataRange, double);
vtkGetVector2Macro(GlyphDataRange, double);
//@}
//@{
/**
* Get/set the maximum glyph size. The upper data value specified in the GlyphDataRange
* will map to this glyph size.
*/
vtkSetMacro(MaximumGlyphSize, double);
//@}
//@{
/**
* Get/set whether to map scale array values to the glyph size range [0, MaximumGlyphSize].
* If off, raw values from the scale array will be used if the scale array is set.
*/
vtkSetMacro(RescaleGlyphs, bool);
vtkGetMacro(RescaleGlyphs, bool);
vtkBooleanMacro(RescaleGlyphs, bool);
//@}
//@{
/**
* Get/set the vector scaling mode. This mode determines how glyphs are scaled when the
......@@ -151,6 +122,15 @@ public:
vtkGetMacro(OutputPointsPrecision, int);
//@}
//@{
/**
* Set/get scale factor used to change the size of glyphs. This factor is
* applied uniformly in each dimension.
*/
//@}
vtkSetMacro(ScaleFactor, double);
vtkGetMacro(ScaleFactor, double);
//@{
/**
* Set/Get the mode at which glyphs will be generated.
......@@ -254,9 +234,7 @@ protected:
int VectorScaleMode;
vtkTransform* SourceTransform;
double GlyphDataRange[2];
double MaximumGlyphSize;
bool RescaleGlyphs;
double ScaleFactor;
int GlyphMode;
int MaximumNumberOfSamplePoints;
int Seed;
......
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