# vtkStripper not joining contiguous lines to form a single vtkPolyLine.

**URL:** https://discourse.vtk.org/t/vtkstripper-not-joining-contiguous-lines-to-form-a-single-vtkpolyline/2402
**Category:** Support
**Created:** [January 10, 2020, 5:58pm UTC](https://discourse.vtk.org/t/vtkstripper-not-joining-contiguous-lines-to-form-a-single-vtkpolyline/2402 "2020-01-10T17:58:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 10, 2020, 5:58pm UTC](https://discourse.vtk.org/t/vtkstripper-not-joining-contiguous-lines-to-form-a-single-vtkpolyline/2402/1 "2020-01-10T17:58:01Z")

</div>

Here is the rendering of three vtkLines:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/5/5697f2cf77c15d3d365ae15d7a877233f596c2ef.png)

Now I use `vtkStripper` in the hopes of getting a single `vtkPolyLine`:

```
    vtkSmartPointer<vtkPolyData> poly = vtkSmartPointer<vtkPolyData>::New();
    poly->SetPoints( points );
    poly->SetLines( segments );
    poly->GetCellData()->SetScalars( dataIndexes );

    vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper>::New();
    stripper->SetInputData( poly );
    stripper->SetMaximumLength( 200 );
    stripper->JoinContiguousSegmentsOn();
    stripper->Update();

    Application::instance()->logInfo("=====>" + QString::number( poly->GetNumberOfCells() ));
    Application::instance()->logInfo("=====>" + QString::number( stripper->GetOutput()->GetNumberOfCells() ));

```

Here’s what I get:  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/7/77fec52365f03833ebf1925aa333792d2d0afc15.png)

I was supposed to get just one object count in the second call.

Here is the data used to build the geometry:

```
test
8
x_initial
x_final
y_initial
y_final
z_initial
z_final
color_code
0.0	0.0	0.0	0.0	0.0	1.0	1
0.0	0.0	0.0	0.0	1.0	2.0	2
0.0	0.0	0.0	0.0	2.0	3.0	1

```

As can be seen, there is no geometry mismatch that would cause `vtkStripper` to misbehave.

I’ll appreciate any help.

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.vtk.org/u/Kenichiro-Yoshimi)
#### Post date: [January 16, 2020, 10:42am UTC](https://discourse.vtk.org/t/vtkstripper-not-joining-contiguous-lines-to-form-a-single-vtkpolyline/2402/2 "2020-01-16T10:42:21Z")

</div>

Hello,

Could you try to run vtkCleanPolyData filter on the polydata before vtkStripper?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 16, 2020, 5:07pm UTC](https://discourse.vtk.org/t/vtkstripper-not-joining-contiguous-lines-to-form-a-single-vtkpolyline/2402/3 "2020-01-16T17:07:45Z")

</div>

Yes, that solved it. Thanks a lotKenichiro! 😀

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 16, 2020, 5:11pm UTC](https://discourse.vtk.org/t/vtkstripper-not-joining-contiguous-lines-to-form-a-single-vtkpolyline/2402/4 "2020-01-16T17:11:46Z")

</div>

The code with the solution:

```auto
    vtkSmartPointer<vtkPolyData> poly = vtkSmartPointer<vtkPolyData>::New();
    poly->SetPoints( points );
    poly->SetLines( segments );
    poly->GetCellData()->SetScalars( dataIndexes );

    vtkSmartPointer<vtkCleanPolyData> cleanPolyData = vtkSmartPointer<vtkCleanPolyData>::New();
    cleanPolyData->SetInputData( poly );
    cleanPolyData->Update();

    vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper>::New();
    stripper->SetInputConnection( cleanPolyData->GetOutputPort() );
    stripper->SetMaximumLength( 200 );
    stripper->JoinContiguousSegmentsOn();
    stripper->Update();

    Application::instance()->logInfo("=====>" + QString::number( poly->GetNumberOfCells() ));
    Application::instance()->logInfo("=====>" + QString::number( stripper->GetOutput()->GetNumberOfCells() ));

```
