<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi<br>
<br>
I would suggest to set the locator for you dataset.<br>
<br>
By default the locator is a vtkMergePoints locator, which might not
be setup to work well for large data.<br>
To check if this is the case, you could call Print(cout) on the
locator after running the clean filter.<br>
<br>
If the parameters (Divisions) are the same, then it is not trying to
compute good parameters for the dataset.<br>
The number of divisions controls how many bins there are to put the
points in each dimenions.<br>
In my experience you will get good performance if you have around
120 points per bin. You can try to set the divisions based on the
bounding box of your dataset.<br>
<br>
If your data is not sampled very evenly spaced you might want to use
an octree point locator:<br>
<a class="moz-txt-link-freetext" href="http://www.vtk.org/doc/nightly/html/classvtkIncrementalOctreePointLocator.html">http://www.vtk.org/doc/nightly/html/classvtkIncrementalOctreePointLocator.html</a><br>
<br>
e.g. something like this:<br>
<br>
loc = vtkIncrementalOctreePointLocator::New();<br>
loc-><span class="Apple-style-span" style="border-collapse:
separate; color: rgb(0, 0, 0); font-family: 'Times New Roman';
font-style: normal; font-variant: normal; font-weight: normal;
letter-spacing: normal; line-height: normal; orphans: 2;
text-align: -webkit-auto; text-indent: 0px; text-transform: none;
white-space: normal; widows: 2; word-spacing: 0px;
-webkit-border-horizontal-spacing: 0px;
-webkit-border-vertical-spacing: 0px;
-webkit-text-decorations-in-effect: none;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;
font-size: medium; "><span class="Apple-style-span"
style="font-family: 'Lucida Grande', Verdana, Geneva, Arial,
sans-serif; font-size: 13px; line-height: 16px; "><a class="el"
href="classvtkIncrementalOctreePointLocator.html#acba69b2b6f98df7dd733bcea37e2b953"
style="color: rgb(61, 87, 140); font-weight: bold;
text-decoration: underline; ">SetMaxPointsPerLeaf</a>(128);<br>
loc->BuildLocator();<br>
</span></span>clean->SetLocator(loc);<br>
<br>
<br>
<br>
On 1/4/2012 7:10 AM, rakesh patil wrote:
<blockquote
cite="mid:CAOG35cneP2SB1f1CNazhnhO4kojYNmSiCzC4vcrGVku8PYcTvQ@mail.gmail.com"
type="cite">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 moz-do-not-send="true" 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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>
Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Please keep messages on-topic and check the VTK FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
</pre>
</blockquote>
</body>
</html>