# Logic behind "Warp By Vector" Reset Scalar Factor button

Hi, I’m using a file to use this “Warp By Vector” filter function.

When a click this filter, it give me a default scalar factor value of number 1. But when I click reset button, it picked a reasonable value for me, but i don’t really know what Paraview did behind this action.

I’ve checked code of Paraview git repo, but I can’t find this code.

It’s handled by the vtkSMBoundsDomain, in array scaled extent mode.

``````      <DoubleVectorProperty command="SetScaleFactor"
default_values="1.0"
name="ScaleFactor"
number_of_elements="1"
panel_visibility="default">
<BoundsDomain name="range" mode="array_scaled_extent">
<RequiredProperties>
<Property function="Input" name="Input" />
<Property function="ArraySelection" name="SelectInputVectors" />
</RequiredProperties>
</BoundsDomain>
<Hints>
<NoDefault/>
</Hints>
<Documentation>Each component of the selected vector array will be
multiplied by the value of this property before being used to compute
new point coordinates.</Documentation>
</DoubleVectorProperty>

``````

hth,

1 Like

Cool. For my case, to use Warp by vector scalar factor. I run into this code to calculate the maxBounds value.

Then I look into .h file, explain that for

``````ARRAY_SCALED_EXTENT: the range is set to (0, (arrayMagnitude / maxbounds) * this->ScaleFactor)
where maxbounds is the length of the longest axis for the bounding box. and arrayMagnitude the maximum magnitude of the array.
``````

But in all case, the default scalarFactor value is set to 0.1.

So, when I use this formula `(arrayMagnitude / maxbounds) * this->ScaleFactor)` this->ScaleFactor value is always 0.1. And finally, the results is not equal to paraview app value.

Ok, is there a bug ? This is not clear.

No, I mean according that code, I can only get maxbounds value, and this->ScaleFactor value is always default 0.1, so at last the results is not equal to Paraview app results. So I wonder if I miss something?

What is the behavior you expect ? In which context ?

What is the behavior you get ?

First, Sorry for my description before. I’m using vtk.js to use warp by vector filter.

For example, a density.vtk

It’s bounds are `[0, 16.51, -5.66214, 5.66214, 23.3312, 36.195]` and the vector Momentum dataRange is `[-368.5409851074219, 368.37799072265625], [-392.2900085449219, 380.30999755859375], [-287.2699890136719, 297.85101318359375]`,

In this function above, i think
`this->ArrayRangeDomain->GetNumberOfEntries() = 3`,
and then arrayScaleFactor is `349.1066640218099` after line 300;

At line 302, `maxbounds` is 16.51. So in line 303 maxbounds equals
`(0.1 / 349.1066640218099) * 16.51 = 0.004729213647714433`.

Thus, the max value of scalar factor should be this value `0.004729213647714433`.

But when i use paraview to warpbyvector, and paraview give me the max value of scalar factor is `0.00519717`. and it’s not equal. `0.00519717 != 0.004729213647714433`

So I’m asking once again, is ParaView behavior expected ? If yes, what is your actual question ?

Yes, Paraview behaviors as expected, sorry to bother you.