# vtkTexture repeat BUG: unexpected-extra repeat with squeezed shape

**URL:** https://discourse.vtk.org/t/vtktexture-repeat-bug-unexpected-extra-repeat-with-squeezed-shape/10041
**Category:** Support
**Created:** [December 2, 2022, 7:01am UTC](https://discourse.vtk.org/t/vtktexture-repeat-bug-unexpected-extra-repeat-with-squeezed-shape/10041 "2022-12-02T07:01:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![yujhuang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yujhuang/32/2821_2.png) [@yujhuang](https://discourse.vtk.org/u/yujhuang)
#### Post date: [December 2, 2022, 7:01am UTC](https://discourse.vtk.org/t/vtktexture-repeat-bug-unexpected-extra-repeat-with-squeezed-shape/10041/1 "2022-12-02T07:01:31Z")

</div>

single Texture sample:  
 ![test](https://discourse.vtk.org/uploads/default/original/2X/d/d3bae7e75449081b64d14935d1f452c9b1f2da71.png)

 ![image](https://discourse.vtk.org/uploads/default/original/2X/7/7acdd8263376c446006368bcd6cbefaab2303ba7.jpeg)  
when we zoom in, we can see that there is squeezed repeats along rows of textures:  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/a/a87ff46784be0c6101cd6d69ab27550c1999ee68.jpeg)

so I tried to repeat vtkTexture on a tubeActor, but there appears glitches, which I am pretty sure are squeezed textures.  
Since I used vtkTransformTextureCoords to arrange texture coordinates, it should have generated exact number of repeats every row as I set. Now I don’t know where the problem is.

```auto
        int number = points.size();
        vtkSmartPointer<vtkPoints> pointsdata = vtkSmartPointer<vtkPoints>::New();
        int count = 0;
        for(auto it = points.begin(); it != points.end(); ++it,++count)//遍历点集并转换VTKpoints
        {
            auto current = *it;
            pointsdata->InsertPoint(count,current[0],current[1],current[2]);
        }

        vtkSmartPointer<vtkCellArray> lines=vtkSmartPointer<vtkCellArray>::New();
        lines->InsertNextCell(number);
        for(int i=0;i<number;i++)
        {
            lines->InsertCellPoint(i);
        }

        vtkSmartPointer<vtkPolyData> polyData=vtkSmartPointer<vtkPolyData>::New();
        polyData->SetPoints(pointsdata);
        polyData->SetLines(lines);

        vtkSmartPointer<vtkDoubleArray> tubeRadius=vtkSmartPointer<vtkDoubleArray>::New();
        tubeRadius->SetName("TubeRadius");
        tubeRadius->SetNumberOfTuples(number);

        auto itr = radiuslist.begin();
        for(int i=0;i<number;i++,++itr)//设置半径列表
        {
            double radius = *itr;
            tubeRadius->SetTuple1(i,radius);
        }
        polyData->GetPointData()->AddArray(tubeRadius);//将半径列表匹配vtkPolyData
        polyData->GetPointData()->SetActiveScalars("TubeRadius");
       vtkSmartPointer<vtkTubeFilter> tube=vtkSmartPointer<vtkTubeFilter>::New();
        tube->SetInputData(polyData);
        tube->SetNumberOfSides(64);
        tube->SetVaryRadiusToVaryRadiusByAbsoluteScalar();
        tube->SetGenerateTCoords(1);

        vtkSmartPointer<vtkTransformTextureCoords> xform = vtkSmartPointer<vtkTransformTextureCoords>::New();;
        xform->SetInputConnection(tube->GetOutputPort());
        xform->SetScale(number,7,0);
        xform->Update();

        auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
        mapper->SetInputConnection(xform->GetOutputPort());
        mapper->ScalarVisibilityOff();
       vtkSmartPointer<vtkPNGReader> reader = vtkSmartPointer<vtkPNGReader>::New();
        reader->SetFileName("C:/Users/Administrator/Desktop/test.png");
        reader->Update();

        vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::New();
        texture->SetInputConnection(reader->GetOutputPort());
        texture->RepeatOn();
        texture->SetEdgeClamp(true);

        auto actor = vtkSmartPointer<vtkActor>::New();
        actor->SetMapper(mapper);
        actor->SetTexture(texture);

```

---

<div class="post-metadata">

### Author: ![yujhuang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yujhuang/32/2821_2.png) [@yujhuang](https://discourse.vtk.org/u/yujhuang)
#### Post date: [December 5, 2022, 3:11am UTC](https://discourse.vtk.org/t/vtktexture-repeat-bug-unexpected-extra-repeat-with-squeezed-shape/10041/2 "2022-12-05T03:11:01Z")

</div>

To have a better demonstration, I am using human picture for texture. and there are squeezed textures.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/5/5fdf4643a47119ed647a50dfe01768342a4502cd.jpeg)

---

<div class="post-metadata">

### Author: ![yujhuang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yujhuang/32/2821_2.png) [@yujhuang](https://discourse.vtk.org/u/yujhuang)
#### Post date: [December 6, 2022, 6:19am UTC](https://discourse.vtk.org/t/vtktexture-repeat-bug-unexpected-extra-repeat-with-squeezed-shape/10041/3 "2022-12-06T06:19:30Z")

</div>

I looked vtkTextureMapToCylinder, it can do  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/0/0e21264bf66f8bb343702f96285d89538fd03bf0.png)  
Maybe that is the difference. Unfortunanately , I cannot use this since I need to tube based on a curved line and with different radius.  
I probably try to do some research on the code behind “PreventSeamOn” and how I can do similar things on my tube actor.

---

<div class="post-metadata">

### Author: ![yujhuang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yujhuang/32/2821_2.png) [@yujhuang](https://discourse.vtk.org/u/yujhuang)
#### Post date: [December 7, 2022, 3:02am UTC](https://discourse.vtk.org/t/vtktexture-repeat-bug-unexpected-extra-repeat-with-squeezed-shape/10041/4 "2022-12-07T03:02:27Z")

</div>

![image](https://discourse.vtk.org/uploads/default/original/2X/d/d7ad0132fd9ec5bb3e956dd4c266cf7838413525.png)  
There is, what I found in 2012 vtk pipeemail: now we know why the seam problem is happenning. But another problem is how I can calculate texture coordinates using 0.5/N at corner myself and apply them to what I have so far.

---

<div class="post-metadata">

### Author: ![yujhuang](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yujhuang/32/2821_2.png) [@yujhuang](https://discourse.vtk.org/u/yujhuang)
#### Post date: [December 7, 2022, 3:11am UTC](https://discourse.vtk.org/t/vtktexture-repeat-bug-unexpected-extra-repeat-with-squeezed-shape/10041/5 "2022-12-07T03:11:08Z")

</div>

Found solution here: [Unwanted interpolation in vtkTexture](https://discourse.vtk.org/t/unwanted-interpolation-in-vtktexture/5556)  
when I turn on SeemlessV in PolyDataMapper, the “glitches” gone.  
Instead, it tries to connect itself over the “seam”.  
Look that nose, I hope that someone has better suggestions.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/8/8764a391f97c480419a9bce1c4c4124860e07aca.jpeg)
