Commit e0649c0c authored by John Tourtellott's avatar John Tourtellott

Revise vtkImageSimpleSource to minimize number of cast operations

Previous logic was scaling poorly
Also:
* Expose options to enable/disable SMP and set "desired bytes per piece"
* Change paraview source name to "Fast Uniform Grid"
* Change whole extent property to non-advanced
parent 5bcc7565
......@@ -10,9 +10,9 @@
show_in_toolbar="0">
<Proxy group="sources" name="AMRGaussianPulseSource" />
<Proxy group="sources" name="DataObjectGenerator" />
<Proxy group="sources" name="FastUniformGrid" />
<Proxy group="sources" name="HierarchicalFractal" />
<Proxy group="sources" name="HyperTreeGridSource" />
<Proxy group="sources" name="SimpleImage" />
<Proxy group="sources" name="ImageMandelbrotSource" />
<Proxy group="sources" name="LiveProgrammableSource" />
<Proxy group="sources" name="RandomHyperTreeGridSource" />
......
<?xml version="1.0" ?>
<pqevents>
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menuSources" />
<pqevent object="pqClientMainWindow/menubar/menuSources/Alphabetical" command="activate" arguments="Simple Image" />
<pqevent object="pqClientMainWindow/menubar/menuSources/Alphabetical" command="activate" arguments="Fast Uniform Grid" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/menubar/menuFilters/pqProxyGroupMenuManager0/Cut" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/CutFunction/ProxySelectionWidget/frame/ChosenProxyWidget/InteractivePlane/useZNormal" command="activate" arguments="" />
......
......@@ -1062,11 +1062,11 @@
</SourceProxy>
<!-- ==================================================================== -->
<SourceProxy class="vtkImageSimpleSource"
label="Simple Image"
name="SimpleImage">
<Documentation long_help="Create an image in 3 dimensions with scalar and vector data arrays, consuming minimal computational resources."
short_help="Create an image with scalar and vector arrays.">The
Simple Image source can be used to create a uniform rectilinear
label="Fast Uniform Grid"
name="FastUniformGrid">
<Documentation long_help="Create a uniform grid in 3 dimensions with scalar and vector data arrays, consuming minimal computational resources."
short_help="Create a 3D uniform grid with scalar and vector arrays.">The
Fast Uniform Grid source can be used to create a uniform
grid with scalar values derived from relatively light
computations. The active scalar array is named "X", and
is set to the X coordinate for each pixel. There are two
......@@ -1078,8 +1078,7 @@
<IntVectorProperty command="SetWholeExtent"
default_values="-10 10 -10 10 -10 10"
name="WholeExtent"
number_of_elements="6"
panel_visibility="advanced">
number_of_elements="6">
<IntRangeDomain name="range" />
<Documentation>The six values in the property indicate the X, Y, and Z
extent of the output data. The first two numbers are the minimum and
......@@ -1088,6 +1087,28 @@
inclusive, so values of -10, 10, -10, 10, =10, 10 indicate that the
dimensions of the output will be 21 x 21 x 21.</Documentation>
</IntVectorProperty>
<IntVectorProperty command="SetEnableSMP"
default_values="0"
name="EnableSMP"
number_of_elements="1"
panel_visibility="advanced">
<Documentation>
Enable/disable SMP for threading.
</Documentation>
<BooleanDomain name="bool" />
</IntVectorProperty>
<IntVectorProperty command="SetDesiredBytesPerPiece"
default_values="65536"
name="DesiredBytesPerPiece"
number_of_elements="1"
panel_visibility="advanced">
<Documentation>
The desired bytes per piece when the volume is split for SMP execution.
When SMP is enabled, this is used to subdivide the volume into pieces.
Smaller pieces allow for better dynamic load balancing, but increase
the total overhead.
</Documentation>
</IntVectorProperty>
</SourceProxy>
<!-- ==================================================================== -->
<SourceProxy class="vtkPlaneSource"
......
......@@ -262,15 +262,32 @@ void vtkImageSimpleSource::ThreadedRequestData(vtkInformation* vtkNotUsed(reques
double* distPtr = static_cast<double*>(distArray->GetVoidPointer(0)) + begin;
double* swirlPtr = static_cast<double*>(swirlArray->GetVoidPointer(0)) + 3 * begin;
// Loop over voxels
int dZ = extent[5] - extent[4] + 1;
int dY = extent[3] - extent[2] + 1;
int dX = extent[1] - extent[0] + 1;
// Convert and save x and y indices to double values
double* yValues = new double[dY];
for (int idxY = extent[2], i = 0; !this->AbortExecute && idxY <= extent[3]; idxY++, i++)
{
yValues[i] = static_cast<double>(idxY);
}
double* xValues = new double[dX];
for (int idxX = extent[0], i = 0; idxX <= extent[1]; idxX++, i++)
{
xValues[i] = static_cast<double>(idxX);
}
// Loop over voxels
unsigned long progressGoal = dY * dZ;
unsigned long progressStep = progressGoal <= 20 ? 1 : progressGoal / 20;
unsigned long progressCount = 0;
for (int idxZ = extent[4]; idxZ <= extent[5]; idxZ++)
{
for (int idxY = extent[2]; !this->AbortExecute && idxY <= extent[3]; idxY++)
double z = static_cast<double>(idxZ);
double zSquared = z * z;
for (int idxY = extent[2], j = 0; !this->AbortExecute && idxY <= extent[3]; idxY++, j++)
{
progressCount++;
if ((threadId == 0) && (progressCount % progressStep) == 0)
......@@ -278,19 +295,23 @@ void vtkImageSimpleSource::ThreadedRequestData(vtkInformation* vtkNotUsed(reques
this->UpdateProgress(static_cast<double>(progressCount) / progressGoal);
}
for (int idxX = extent[0]; idxX <= extent[1]; idxX++)
double y = yValues[j];
double yzSquared = y * y + zSquared;
for (int idxX = extent[0], i = 0; idxX <= extent[1]; idxX++, i++)
{
*xPtr = static_cast<double>(idxX);
double x = xValues[i];
*xPtr = x;
xPtr++;
*distPtr = static_cast<double>(idxX * idxX + idxY * idxY + idxZ * idxZ);
*distPtr = x * x + yzSquared;
distPtr++;
*swirlPtr = idxY;
*swirlPtr = y;
swirlPtr++;
*swirlPtr = idxZ;
*swirlPtr = z;
swirlPtr++;
*swirlPtr = idxX;
*swirlPtr = x;
swirlPtr++;
} // for (idxX)
xPtr += outIncY;
......@@ -301,4 +322,7 @@ void vtkImageSimpleSource::ThreadedRequestData(vtkInformation* vtkNotUsed(reques
distPtr += outIncZ;
swirlPtr += 3 * outIncZ;
} // for (idxZ)
delete[] yValues;
delete[] xValues;
}
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