[vtkusers] Triangulating 'vertical' polygon with Delaunay2D?

Artem Babayan artem.paraview at googlemail.com
Wed May 13 08:41:16 EDT 2015


Dear David,

Thank you for your reply. Unfortunately I am apparently doing something
wrong setting up the contour triangulation.

For very simple 1-polygon example I have 1 polygon p_1 defined over subset
of points vtk_points. I first create vtkPolygon, then vtkCellArray, then
vtkPolyData, feed it to vtkContourTriangulator and call Update. The result
is apparently empty vtkCellArray?

      vtkSmartPointer<vtkPolygon> poly = vtkSmartPointer<vtkPolygon>::New();
      for(size_t v = 0; v < p_1.size(); ++v)
      {
        poly->GetPointIds()->InsertNextId(p_1[v]);
      }

      vtkSmartPointer<vtkCellArray> cell_array =
vtkSmartPointer<vtkCellArray>::New();
      cell_array->InsertNextCell(poly);

      vtkSmartPointer<vtkPolyData> boundary =
vtkSmartPointer<vtkPolyData>::New();
      boundary->SetPoints(vtk_points);
      boundary->SetPolys(cell_array);

      vtkSmartPointer<vtkContourTriangulator> tri_filter =
                     vtkSmartPointer<vtkContourTriangulator>::New();
      tri_filter->SetInputData(boundary);
      tri_filter->Update();
      cout << "After triangulation I got "  <<
tri_filter->GetOutput()->GetNumberOfCells()  << " cells\n";

Could you tell me what can be possibly wrong here?


On 11 May 2015 at 13:36, David Gobbi <david.gobbi at gmail.com> wrote:

> Hi Artem,
>
> You can try using vtkContourTriangulator, it only uses the connected
> points for the triangulation and it works in any orientation:
>
> http://www.vtk.org/doc/nightly/html/classvtkContourTriangulator.html#details
>
> Delaunay2D also has a method for working in planes other than the XY
> plane: calling the method SetProjectionPlaneMode(VTK_BEST_FITTING_PLANE)
> should work, if all of your input points are in the same plane.
>
>  - David
>
>
> On Mon, May 11, 2015 at 4:47 AM, Artem Babayan <
> artem.paraview at googlemail.com> wrote:
>
>> Hello,
>>
>> I have
>>
>> 1) vtk_poijnts -- set of 3D points (vtkPoints object) located within the
>> computational 3D box.
>> 2) poly_1 -- std::vector<int> -- connected subset of points from 1)
>> representing non-convex polygon on the side of computational box. E.g. in
>> XZ plane.
>> 3) poly_hole_1, poly_hole_2 -- 2 subsets of points from 1) each
>> representing possibly non-convex hole in poly_1 from 2).
>>
>> How am I visualise it with VTK?
>>
>> I assume that as I have holes in polygon the only choice of I have is to
>> use vtkDelaunay2D?
>>
>> vtkDelaunay2D apparently uses all points from vtk_points for
>> triangulization, while I need only points from poly_1, poly_hole_1 and
>> poly_hole_2 ?
>>
>> I need to tell somehow vtkDelaunay2D than I want to tesselate in XZ plane
>> rather than in XY plane?
>>
>> Thank you
>> Artem
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150513/41e0e676/attachment.html>


More information about the vtkusers mailing list