# Problem setting normals to polydata and TubeFilter

**URL:** https://discourse.vtk.org/t/problem-setting-normals-to-polydata-and-tubefilter/2046
**Category:** Web
**Created:** [November 5, 2019, 10:49am UTC](https://discourse.vtk.org/t/problem-setting-normals-to-polydata-and-tubefilter/2046 "2019-11-05T10:49:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![anon10073585](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@anon10073585](https://discourse.vtk.org/u/anon10073585)
#### Post date: [November 5, 2019, 10:49am UTC](https://discourse.vtk.org/t/problem-setting-normals-to-polydata-and-tubefilter/2046/1 "2019-11-05T10:49:55Z")

</div>

I can set my own normals to a polydata (lines) in vtk.js, and it works fine. But when I try to use a TubeFilter with said polydata, it doesn’t work; I can only generate the tube if I don’t set the normals. The program doesn’t run any code after calling `tubeFilter.update()` .

I create my normals as so:

```auto
  const numSegments = 1;
  const normals = new Float32Array(3 * (numSegments + 1));
  const normalArray = vtkDataArray.newInstance({
    name: 'Normals',
    values: normals,
    numberOfComponents: 3,
  });

  for(let i=0; i<numSegments + 1; i++) {
	normals[i*3+0] = 0;
	normals[i*3+1] = 0;
	normals[i*3+2] = 1;
  }

```

And set it to the polydata as so:

`polyData.getPointData().setNormals(normalArray);`

I create the tube filter as so:

```auto
const tubeFilter = vtkTubeFilter.newInstance();
tubeFilter.setCapping(false);
tubeFilter.setNumberOfSides(50);
tubeFilter.setRadius(0.1);
tubeFilter.setInputData(polyData);
tubeFilter.setInputArrayToProcess(0, 'Scalars', 'PointData', 'Scalars');
tubeFilter.update(); // Program stops here

```

Why isn’t it working? What am I doing wrong? What do I have to do to generate a tube with my own normals?  
Here’s the full code: [index.js](http://vtk.1045678.n5.nabble.com/file/t342808/index.js); it’s a simplified version of [this example](https://kitware.github.io/vtk-js/examples/TubeFilter.html).

[Here’s an image](http://vtk.1045678.n5.nabble.com/file/t342808/img.jpg) of the line with the tube generated when no normals are set (left) and only the line when normals are set (right), as the code stops after trying to generate the tube.

Thanks to anyone who can help.

---

<div class="post-metadata">

### Author: ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)
#### Post date: [November 5, 2019, 3:56pm UTC](https://discourse.vtk.org/t/problem-setting-normals-to-polydata-and-tubefilter/2046/2 "2019-11-05T15:56:31Z")

</div>

This seems like a bug in the TubeFilter. The code you have looks right.

I’ll try to find some time to look into it. Not sure where the bug might be but feel free to look at the logic where normals are generated.

---

<div class="post-metadata">

### Author: ![Donny\_Zimmerman](https://discourse.vtk.org/user_avatar/discourse.vtk.org/donny_zimmerman/32/301_2.png) [@Donny\_Zimmerman](https://discourse.vtk.org/u/Donny_Zimmerman)
#### Post date: [November 5, 2019, 10:13pm UTC](https://discourse.vtk.org/t/problem-setting-normals-to-polydata-and-tubefilter/2046/3 "2019-11-05T22:13:00Z")

</div>

Shouldn’t this line:  
tubeFilter.setInputArrayToProcess(0, ‘Scalars’, ‘PointData’, ‘Scalars’);

be:  
tubeFilter.setInputArrayToProcess(0, ‘Scalars’, ‘PointData’, ‘Normals’);

---

<div class="post-metadata">

### Author: ![anon10073585](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@anon10073585](https://discourse.vtk.org/u/anon10073585)
#### Post date: [November 5, 2019, 10:37pm UTC](https://discourse.vtk.org/t/problem-setting-normals-to-polydata-and-tubefilter/2046/4 "2019-11-05T22:37:43Z")

</div>

> [@Donny\_Zimmerman](#):
>
> Shouldn’t this line:  
> tubeFilter.setInputArrayToProcess(0, ‘Scalars’, ‘PointData’, ‘Scalars’);
> 
> be:  
> tubeFilter.setInputArrayToProcess(0, ‘Scalars’, ‘PointData’, ‘Normals’);

I tried that but it didn’t work.
