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

**URL:** https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482
**Category:** ParaView Support
**Tags:** vtk
**Created:** [February 24, 2023, 6:34am UTC](https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482 "2023-02-24T06:34:33Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Albers\_Steven](https://discourse.paraview.org/user_avatar/discourse.paraview.org/albers_steven/32/10391_2.png) [@Albers\_Steven](https://discourse.paraview.org/u/Albers_Steven)
#### Post date: [February 24, 2023, 6:34am UTC](https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482/1 "2023-02-24T06:34:33Z")

</div>

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

 ![image](https://discourse.paraview.org/uploads/default/original/2X/4/491b9df5e1aaf5617b69b319fd31dcac43b8e23a.jpeg)

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.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/e/ebf05d1f544aa611fe232c0390c2d2fd55072dfd.png)

So, Could you show me the algorithm about this reset action?

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

Please help me!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 24, 2023, 8:47am UTC](https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482/2 "2023-02-24T08:47:25Z")

</div>

Hi @Albers_Steven

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

```auto
      <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>

```

The doc is here:  
[https://kitware.github.io/paraview-docs/latest/cxx/classvtkSMBoundsDomain.html#ab291fcc0b9345a01a36337b34d4a8dd0ae46aa9978e10f02a8d3e06194d77085f](https://kitware.github.io/paraview-docs/latest/cxx/classvtkSMBoundsDomain.html#ab291fcc0b9345a01a36337b34d4a8dd0ae46aa9978e10f02a8d3e06194d77085f)

hth,

---

<div class="post-metadata">

### Author: ![Albers\_Steven](https://discourse.paraview.org/user_avatar/discourse.paraview.org/albers_steven/32/10391_2.png) [@Albers\_Steven](https://discourse.paraview.org/u/Albers_Steven)
#### Post date: [February 24, 2023, 10:43am UTC](https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482/3 "2023-02-24T10:43:25Z")

</div>

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

 ![image](https://discourse.paraview.org/uploads/default/original/2X/1/1832a25edaab3c24bb303db7a746ed5e2824b520.png)

Then I look into .h file, explain that for

```auto
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.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/a/a30fc7c22e88e06aa77a497bb517e1ce01e25f6a.png)

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.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 24, 2023, 10:47am UTC](https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482/4 "2023-02-24T10:47:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Albers\_Steven](https://discourse.paraview.org/user_avatar/discourse.paraview.org/albers_steven/32/10391_2.png) [@Albers\_Steven](https://discourse.paraview.org/u/Albers_Steven)
#### Post date: [February 25, 2023, 2:54am UTC](https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482/5 "2023-02-25T02:54:29Z")

</div>

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?

 ![image](https://discourse.paraview.org/uploads/default/original/2X/f/f40e9eaed34c79dd62ddea5b7ee38b3c55bc72f1.png)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 27, 2023, 8:29am UTC](https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482/6 "2023-02-27T08:29:58Z")

</div>

What is the behavior you expect ? In which context ?

What is the behavior you get ?

---

<div class="post-metadata">

### Author: ![Albers\_Steven](https://discourse.paraview.org/user_avatar/discourse.paraview.org/albers_steven/32/10391_2.png) [@Albers\_Steven](https://discourse.paraview.org/u/Albers_Steven)
#### Post date: [February 27, 2023, 10:41am UTC](https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482/7 "2023-02-27T10:41:31Z")

</div>

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

For example, a density.vtk

 ![image](https://discourse.paraview.org/uploads/default/original/2X/9/91db8c041d554552600a81df8d30d8d8c110e23f.png)

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]`,

 ![image](https://discourse.paraview.org/uploads/default/original/2X/f/ff429a9954f0fefce18dcf5173d23f46f4348d65.jpeg)

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`

 ![image](https://discourse.paraview.org/uploads/default/original/2X/0/07d2406fc4f89bb6bf1df20484a1aa78fb208337.jpeg)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 27, 2023, 10:42am UTC](https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482/8 "2023-02-27T10:42:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Albers\_Steven](https://discourse.paraview.org/user_avatar/discourse.paraview.org/albers_steven/32/10391_2.png) [@Albers\_Steven](https://discourse.paraview.org/u/Albers_Steven)
#### Post date: [February 28, 2023, 3:53am UTC](https://discourse.paraview.org/t/logic-behind-warp-by-vector-reset-scalar-factor-button/11482/9 "2023-02-28T03:53:00Z")

</div>

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