[vtkusers] How to construct polygon?

Rakesh Patil rakesh.p at tataelxsi.co.in
Thu Apr 13 11:38:04 EDT 2017


Hi,


This question seems to be simple, but I am not able to get any output for this. I am not able to understand what is happening in this case:


vtkSmartPointer<vtkPoints> tpoints = vtkSmartPointer<vtkPoints>::New();

vtkSmartPointer<vtkPolygon> poly = vtkSmartPointer<vtkPolygon>::New();

vtkSmartPointer<vtkCellArray> carr = vtkSmartPointer<vtkCellArray>::New();

vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();



poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( 4.39116, -2.39117, 4.5));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( 4.39116, -2.39117, 3));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( 4.39116, -2.39117, 1.5));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( 4.39116, -2.39117, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( 4.08748, -2.87967, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( 3.05391, -3.95899, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( 1.74755, -4.68466, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( 0.28509, -4.99187, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -1.20284, -4.85316, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -2.58332, -4.28094, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -3.73305, -3.32631, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -4.54931, -2.07456, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -4.95919, -0.637487, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -4.92609, 0.856528, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -4.45295, 2.27403, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -3.58205, 3.4884, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -2.39117, 4.39116, 0));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -2.39117, 4.39116, 1.5));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -2.39117, 4.39116, 3));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -2.39117, 4.39116, 4.5));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -2.39117, 4.39116, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -3.58205, 3.4884, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -4.45295, 2.27403, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint( -4.92609, 0.856528, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint(-4.95919, -0.637487, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint(-4.54931, -2.07456, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint(-3.73305, -3.32631, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint(-2.58332, -4.28094, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint(-1.20284, -4.85316, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint(0.28509, -4.99187, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint(1.74755, -4.68466, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint(3.05391, -3.95899, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint(4.08748, -2.87967, 6));

poly->GetPointIds()->InsertNextId(tpoints->InsertNextPoint(4.39116, -2.39117, 6));

carr->InsertNextCell(poly);


    polyData->SetPoints(tpoints);

    polyData->SetPolys(carr);


    vtkSmartPointer<vtkTriangleFilter> tfilter = vtkSmartPointer<vtkTriangleFilter>::New();

    tfilter->SetInputData(polyData);

    tfilter->Update();



    vtkSmartPointer<vtkPolyDataMapper> pmapper = vtkSmartPointer<vtkPolyDataMapper>::New();

    pmapper->SetInputConnection(tfilter->GetOutputPort());


    vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();

    actor->SetMapper(pmapper);

    actor->GetProperty()->SetRepresentationToSurface();

    actor->GetProperty()->EdgeVisibilityOn();

    actor->GetProperty()->SetEdgeColor(1.0, 0.0, 0.0);


    renderer->AddActor(actor);

    renderer->ResetCamera();



I am not able to view the output if I use vtkTriangleFilter. I have attached two screenshots. One is to show how the expected output should come. Another is the vtk's output without applying vtkTriangleFilter. How do I get the curved surfaces based on the above geometry (points)?


Am I missing anything there?



Thanks & Regards

Rakesh Patil

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170413/741ec981/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: expectedOutput.png
Type: image/png
Size: 17820 bytes
Desc: expectedOutput.png
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170413/741ec981/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkOutput_wo_tri.png
Type: image/png
Size: 11686 bytes
Desc: vtkOutput_wo_tri.png
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170413/741ec981/attachment-0003.png>


More information about the vtkusers mailing list