[vtkusers] Are there limitations in vtkDelaunay2D?
Tanweer Rashid
trash001 at odu.edu
Sat Jan 11 22:59:36 EST 2014
Hi,
I am trying to generate triangles from sets of points. I am using
vtkDelaunay2D for this. For some pointsets, vtkDelaunay2D is not generating
any triangles. Following is the code I am using. I am basically creating a
vtkPolyData using the points, and then applying vtkDelaunay2D on that
polydata. Lastly, I am visualizing the output.
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vtkSmartPointer.h>
#include <vtkIdList.h>
#include <vtkCellArray.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkActor.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkDelaunay2D.h>
#include <vtkPolyDataWriter.h>
using namespace std;
int main() {
int pointIndex[] = {0, 1, 2, 3};
// Points
double **pts = new double*[3];
pts[0] = new double[3] {8.53125, 7.53125, 1.53125};
pts[1] = new double[3] {8.53125, 7.53125, 2.53125};
pts[2] = new double[3] {8.26562, 8.26562, 2.53125};
pts[3] = new double[3] {8.26562, 8.26562, 1.53125};
vtkSmartPointer<vtkPoints> points =
vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkIdList> pointList =
vtkSmartPointer<vtkIdList>::New();
for (int i = 0; i < 4; i++) {
points->InsertPoint(i, pts[i][0], pts[i][1], pts[i][2]);
pointList->InsertNextId(i);
}
vtkSmartPointer<vtkCellArray> vertexArray =
vtkSmartPointer<vtkCellArray>::New();
vertexArray->InsertNextCell(pointList);
vtkSmartPointer<vtkPolyData> pdata =
vtkSmartPointer<vtkPolyData>::New();
pdata->SetPoints(points);
pdata->SetVerts(vertexArray);
vtkSmartPointer<vtkDelaunay2D> del =
vtkSmartPointer<vtkDelaunay2D>::New();
del->SetProjectionPlaneMode(VTK_BEST_FITTING_PLANE);
del->SetInput(pdata);
del->Update();
vtkSmartPointer<vtkPolyData> output = del->GetOutput();
cout << "Number of cells: " << output->GetNumberOfCells() <<
endl;
cout << "Number of points: " << output->GetNumberOfPoints() <<
endl;
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(output);
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkSmartPointer<vtkRenderer> ren =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renwin =
vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderWindowInteractor> iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renwin->AddRenderer(ren);
iren->SetRenderWindow(renwin);
ren->AddActor(actor);
renwin->Render();
iren->Start();
return 0;
}
For the 4 points in the code, I am not getting any triangulations. Can
someone tell me why? I was wondering if this is because of some kind of
limitation with vtkDelaunay2D or perhaps because my code is incorrect. Any
help is appreciated.
--
Tanweer Rashid
MSVE Dept.
Old Dominion University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140111/9dc14071/attachment.html>
More information about the vtkusers
mailing list