[vtkusers] vtkTriangleStrip, cont'd

Richard Frank rickfrank at me.com
Tue Dec 8 20:45:04 EST 2015


Here's some code that shows the issue I'm trying to resolve...


I have some sampled 3D points that are essentially a tube. (I cut out a lot of data, show the example doesn't look like a tube, but this shows the issue) 

I can build the surface of the tube but, the two ends of the tube want to join together. In the program below, you can see the wide strips that go straight back from one end to the other.

How do I disconnect the strips at the ends from each other?

Thanks,

Rick

Code:

#include <Windows.h>
#include <vector>
#include "vtkPointData.h"
#include "vtkProperty.h"
#include "vtkPolyLine.h"
#include "vtkSmartPointer.h"
#include "vtkTriangleStrip.h"
#include "vtkPolyData.h"
#include "vtkDataSetMapper.h"
#include "vtkCellArray.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkInteractorStyleTrackballCamera.h"


double points[][3] = { {55.582, -190.774, 844.647},
{ 55.2271,-193.744,835.244 },
{ 52.7171,-199.737,819.319 },
{ 47.7865,-207.213,803.631 },
{ 39.795,-213.97,790.551 },
{ 30.0697,-218.514,778.441 },
{ 21.8655,-219.257,769.834 },
{ 12.5418,-219.67,757.889 },
{ 6.50188,-218.147,748.296 },
{ 2.99031,-218.521,736.832 },
{ 2.33774,-221.3,723.745 },
{ 1.34548,-224.755,709.287 },
{ -1.03045,-231.667,692.916 },
{ -5.04376,-237.586,678.402 },
{ -9.08177,-242.151,668.611 },
{ -11.5051,-247.929,656.06 },
{ -13.9007,-251.23,643.571 },
{ -15.0945,-252.57,634.539 },
{ -11.9482,-253.68,624.517 },
{ -7.25365,-253.349,612.844 },
{ -1.01116,-256.384,604.258 },
{ 6.21204,-254.857,588.511 },
{ 59.9477,-197.404,846.897 },
{ 59.9313,-199.564,839.104 },
{ 57.6438,-204.789,822.469 },
{ 52.0044,-212.025,805.899 },
{ 43.6559,-218.774,790.717 },
{ 32.9718,-224.02,776.905 },
{ 23.1723,-225.666,767.488 },
{ 14.773,-226.315,756.226 },
{ 9.02408,-225.264,745.333 },
{ 7.50066,-225.347,736.11 },
{ 6.98553,-227.96,725.841 },
{ 6.41854,-230.82,712.1 },
{ 4.55219,-236.488,696.478 },
{ -0.0278958,-242.796,679.726 },
{ -4.68599,-247.164,669.687 },
{ -7.1335,-252.351,658.019 },
{ -9.93603,-256.519,644.824 },
{ -10.8628,-258.134,635.523 },
{ -9.02904,-260.297,627.886 },
{ -5.39866,-261.661,617.874 },
{ 1.09968,-263.716,609.148 },
{ 9.97905,-262.779,591.124 },
{ 59.9345,-205.175,849.43 },
{ 59.8925,-206.997,843.841 },
{ 59.2423,-211.942,828.25 },
{ 54.2427,-218.078,810.932 },
{ 46.1204,-224.687,793.598 },
{ 34.072,-229.764,778.557 },
{ 23.1483,-231.134,767.532 },
{ 15.0776,-232.306,757.456 },
{ 9.19118,-232.253,744.755 },
{ 8.52304,-233.668,737.046 },
{ 6.99084,-235.889,728.858 },
{ 6.90973,-238.782,716.418 },
{ 5.37757,-243.673,703.468 },
{ 7.21037,-251.466,682.958 },
{ -3.4923,-253.845,673.482 },
{ -5.82057,-258.661,662.418 },
{ -9.181,-263.004,647.922 },
{ -10.9386,-265.091,637.243 },
{ -9.5132,-267.003,629.82 },
{ -6.4218,-268.871,620.346 },
{ 0.024518,-270.644,610.015 },
{ 10.0565,-271.125,592.232 },
{ 55.1264,-211.233,851.308 },
{ 55.1035,-212.784,847.383 },
{ 54.4377,-217.608,834.291 },
{ 51.8816,-224.065,819.034 },
{ 44.9272,-231.02,801.288 },
{ 33.487,-236.35,783.635 },
{ 21.6961,-237.217,770.259 },
{ 13.7675,-238.825,761.378 },
{ 5.61639,-238.367,747.816 },
{ 3.34256,-240.212,740.076 },
{ 2.66214,-242.742,731.875 },
{ 1.99014,-245.187,720.447 },
{ 1.05857,-249.728,710.252 },
{ -2.11927,-255.48,692.17 },
{ -7.14656,-259.549,678.762 },
{ -9.45814,-264.12,667.803 },
{ -12.7369,-268.44,652.29 },
{ -14.6491,-271.149,638.979 },
{ -13.126,-272.96,630.127 },
{ -10.7058,-274.801,619.895 },
{ -3.20754,-277.047,608.081 },
{ 5.14991,-278.048,591.133 },
{ 47.7996,-213.863,852.017 },
{ 47.847,-214.562,848.301 },
{ 47.1094,-219.045,837.31 },
{ 44.9596,-225.066,824.916 },
{ 39.0062,-233.221,810.519 },
{ 28.4987,-238.904,793.583 },
{ 16.9902,-242.235,778.82 },
{ 8.65652,-242.315,770.631 },
{ -0.706025,-241.288,753.856 },
{ -4.36561,-242.724,743.54 },
{ -5.30576,-244.801,733.411 },
{ -5.83709,-248.177,722.879 },

{ -3.74893,-287.198,689.906 },
{ -1.38069,-292.909,684.796 },
{ 0.480259,-296.168,679.003 },
{ -15.6413,-263.062,693.585 },
{ -14.6015,-267.124,693.203 },
{ -13.0928,-271.291,691.977 },
};


int main(int c, char **argv)
{

vtkSmartPointer<vtkPoints> trianglePoints = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkTriangleStrip> triangleStrips = vtkSmartPointer<vtkTriangleStrip>::New();
vtkSmartPointer<vtkCellArray> triangleCells = vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkPolyData> trianglePolyData = vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkDataSetMapper> triangleMapper = vtkSmartPointer<vtkDataSetMapper>::New();
vtkSmartPointer<vtkActor> triangleActors = vtkSmartPointer<vtkActor>::New();
vtkSmartPointer<vtkCellArray> triangleVertices = vtkSmartPointer<vtkCellArray>::New();



size_t count = sizeof(points) / (3 * sizeof(double));

for (auto i = 0; i < count; i++)
{
vtkIdType id = trianglePoints->InsertNextPoint(points[i]);
triangleVertices->InsertNextCell(VTK_VERTEX);
triangleVertices->InsertCellPoint(id);
}


triangleStrips->GetPointIds()->SetNumberOfIds(count);
trianglePolyData->SetVerts(triangleVertices);
trianglePolyData->SetPoints(trianglePoints);
for (auto ns = 0; ns < count; ns++)
{
triangleStrips->GetPointIds()->SetId(ns, ns);
}
triangleCells->InsertNextCell(triangleStrips);

trianglePolyData->SetStrips(triangleCells);






triangleMapper->SetInputData(trianglePolyData);
triangleActors->SetMapper(triangleMapper);

triangleActors->GetProperty()->SetRepresentationToSurface();
triangleActors->GetProperty()->SetColor(1, 1, 0);
triangleActors->GetProperty()->SetSpecular(0.9);
triangleActors->GetProperty()->SetSpecularPower(1);
triangleActors->GetProperty()->SetAmbient(0.4);

vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();

renderer->AddActor(triangleActors);

vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);

vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);

vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
renderWindowInteractor->SetInteractorStyle(style);

renderWindowInteractor->Initialize();
renderWindowInteractor->Start();


return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151209/38b893c2/attachment.html>


More information about the vtkusers mailing list