Hello,<br><br>I am facing problem in triangulation for few datasets. I have VTK compiled for 64-bit machine and some datasets get triangulated and some do not. I went through the doxygen help for vtkDelaunay2D which says that<br>
<br><b>The Delaunay triangulation can be numerically sensitive in some cases.
To prevent problems, try to avoid injecting points that will result in
triangles with bad aspect ratios (1000:1 or greater). In practice this
means inserting points that are "widely dispersed", and enables smooth
transition of triangle sizes throughout the mesh. (You may even want to
add extra points to create a better point distribution.) If numerical
problems are present, you will see a warning message to this effect at
the end of the triangulation process.<br><br></b>Now how can I verify or make sure that there are no numerical problems in the input dataset? I am reading input dataset from a file. Is there any direct or indirect way to remove such problems if they exists?<br>
<br>At very first point I thought of vtkCleanPolyData filter to use. But this takes very long time for large data. If this is the only way to remove numerical problems, then can vtkCleanPolyData filter be made to execute faster?<br>
<br>Please suggest me something. Below is the code I am using<br><br>#include <iostream><br>#include <vtkPoints.h><br>#include <vtkDoubleArray.h><br>#include <vtkPointData.h><br>#include <vtkPolyData.h><br>
#include <vtkDelaunay2D.h><br>#include <vtkCellArray.h><br>#include <vtkSmartPointer.h><br>#include <vtkPolyDataMapper.h><br>#include <vtkRenderer.h><br>#include <vtkRenderWindowInteractor.h><br>
#include <vtkRenderWindow.h><br>#include <vtkCleanPolyData.h><br><br>int main()<br>{<br> vtkPoints *points = vtkPoints::New();<br> vtkDoubleArray *scalarArray = vtkDoubleArray::New();<br> vtkCellArray *polyVertex = vtkCellArray::New();<br>
<br> std::string filename="carto-gebco.pts";<br><br> FILE *fp = fopen(filename.c_str(), "r");<br> if(!fp){<br> std::cout << "Unable to open file" << std::endl;<br>
return -1 ;<br> }<br><br> char buffer[256];<br> char str[256];<br> double xval, yval, zval;<br> vtkIdType i = 0;<br> <br> while(fgets(buffer, 256, fp)) //return false;<br> {<br> str[0]='\0';<br>
sscanf(buffer, "%lf%lf%lf", &xval, &yval, &zval);<br><br> points->InsertPoint(i, xval, <br> yval,0);<br> scalarArray->InsertTuple1(i, zval);<br> polyVertex->InsertNextCell(1, &i);<br>
<br> i++;<br> }<br> std::cout << "Completed reading input data" << std::endl;<br> points->Modified();<br> scalarArray->Modified();<br> polyVertex->Modified();<br>
<br> vtkPolyData *pd = vtkPolyData::New();<br> pd->SetPoints(points);<br> pd->GetPointData()->SetScalars(scalarArray);<br> pd->SetVerts(polyVertex);<br> <br> points->Delete();<br> scalarArray->Delete();<br>
polyVertex->Delete();<br><br> std::cout << "Checking duplicate points" << std::endl;<br> vtkSmartPointer<vtkCleanPolyData> cpd = vtkSmartPointer<vtkCleanPolyData>::New();<br>
cpd->SetInput(pd);<br> pd->Delete();<br> cpd->SetTolerance(0.00001);<br> cpd->Update();<br><br> std::cout << "Triangulating data" << std::endl;<br> vtkDelaunay2D *del = vtkDelaunay2D::New();<br>
del->SetInputConnection(cpd->GetOutputPort()); <br> del->SetTolerance(0.00001);<br> del->Update();<br><br> std::cout << "Completed triangulation" << std::endl;<br> vtkSmartPointer<vtkPolyDataMapper> triangulatedMapper =<br>
vtkSmartPointer<vtkPolyDataMapper>::New();<br> triangulatedMapper->SetInputConnection(del->GetOutputPort());<br> del->Delete();<br> vtkSmartPointer<vtkActor> triangulatedActor =<br> vtkSmartPointer<vtkActor>::New();<br>
triangulatedActor->SetMapper(triangulatedMapper);<br> <br> // Create a renderer, render window, and interactor<br> vtkSmartPointer<vtkRenderer> renderer =<br> vtkSmartPointer<vtkRenderer>::New();<br>
vtkSmartPointer<vtkRenderWindow> renderWindow =<br> vtkSmartPointer<vtkRenderWindow>::New();<br> renderWindow->AddRenderer(renderer);<br> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br>
vtkSmartPointer<vtkRenderWindowInteractor>::New();<br> renderWindowInteractor->SetRenderWindow(renderWindow);<br> <br> // Add the actor to the scene<br> renderer->AddActor(triangulatedActor);<br> // renderer->AddActor(triangulatedActor);<br>
renderer->SetBackground(.3, .6, .3); // Background color green<br> <br> // Render and interact<br> renderWindow->Render();<br> renderWindowInteractor->Start();<br><br> fclose(fp);<br> <br> return 0;<br>
}<br><br>Here is a sample input data<br><br><a id="HyperLink1" href="http://www.fileflyer.com/view/dkhbrBR" style="display:inline-block;width:331px">http://www.fileflyer.com/view/dkhbrBR</a><br><br>Thanks<br><br>Regards<br>
Rakesh Patil <b> <br></b>