[vtkusers] vtkThreshold question
Randall Hand
randall.hand at gmail.com
Wed Jun 14 10:18:25 EDT 2006
Well, I'll see if I can find a dataset to replicate the problem and drop it
to you guys.
In the meantime, just some more info:
1) The stack trace contained solely the vtkDataArray::Get line, no further
information... Guess Debug flags are disabled somewhere...
2) The code with a vtkPolyData:
vtkCellArray *cells = vtkCellArray::New();
cells->Allocate(nCells, 10);
vtkIdList *ids = vtkIdList::New();
ids->Allocate(3);
for(i=0; i<nCells; i++) {
fscanf(fptr, "%li %li %li %li %li", &junk, &count, &id1, &id2,
&id3);
if (count != 3) {
points->Delete();
BAIL("ADCIRC Elements can only contain 3 points!");
}
if (id1 > nPoints) { BAIL("Cell contains a point that wasn't
loaded!"); }
if (id2 > nPoints) { BAIL("Cell contains a point that wasn't
loaded!"); }
if (id3 > nPoints) { BAIL("Cell contains a point that wasn't
loaded!"); }
if (id1 <= 0) { BAIL("Cell contains a point <= 0!"); }
if (id2 <= 0) { BAIL("Cell contains a point <= 0!"); }
if (id3 <= 0) { BAIL("Cell contains a point <= 0!"); }
ids->Reset();
ids->InsertNextId(id1-1);
ids->InsertNextId(id2-1);
ids->InsertNextId(id3-1);
cells->InsertNextCell(ids);
}
fclose(fptr);
vtkPolyData *output = vtkPolyData::New();
output->Initialize();
output->Allocate();
output->SetPoints(points);
output->SetPolys(cells);
3) the modified code, with a vtkUnstructuredGrid
vtkUnstructuredGrid *output = vtkUnstructuredGrid::New();
output->Initialize();
output->Allocate(nCells, 10);
output->SetPoints(points);
vtkIdList *ids = vtkIdList::New();
ids->Allocate(3);
for(i=0; i<nCells; i++) {
fscanf(fptr, "%li %li %li %li %li", &junk, &count, &id1, &id2,
&id3);
if (count != 3) {
points->Delete();
BAIL("ADCIRC Elements can only contain 3 points!");
}
if (id1 > nPoints) { BAIL("Cell contains a point that wasn't
loaded!"); }
if (id2 > nPoints) { BAIL("Cell contains a point that wasn't
loaded!"); }
if (id3 > nPoints) { BAIL("Cell contains a point that wasn't
loaded!"); }
if (id1 <= 0) { BAIL("Cell contains a point <= 0!"); }
if (id2 <= 0) { BAIL("Cell contains a point <= 0!"); }
if (id3 <= 0) { BAIL("Cell contains a point <= 0!"); }
ids->Reset();
ids->InsertNextId(id1-1);
ids->InsertNextId(id2-1);
ids->InsertNextId(id3-1);
output->InsertNextCell(VTK_TRIANGLE, ids);
}
fclose(fptr);
So for reference, 2 things changed between the two pieces of code:
1) went from vtkPolyData to vtkUnstructuredGrid
2) Went from assigned all the cells in 1 shot with a vtkCellArray *
SetPolys, to individually adding each cell to the output Dataset.
On 6/14/06, Amy Squillacote <amy.squillacote at kitware.com> wrote:
>
> Hi Randall,
>
> vtkThreshold should be able to handle vtkPolyData; it accepts any type
> of vtkDataSet as input, and there's no apparent limitation on the type
> of cells that can be contained in the dataset to be thresholded. Would
> you please post the stack trace? If you have a small dataset that can be
> used to reproduce the problem (and that you would be able to post), that
> would be very helpful as well.
>
> - Amy
>
> Randall Hand wrote:
> > I have some code to load ADCIRC data into memory as vtkPolyData. It's
> > been working great until yesterday when I tried to pass it to a
> > vtkThreshold to eliminate some of the "masked" values, and it
> > segfaulted. a backtrace showed it somewhere in a
> > vtkDataArray::GetValue call.
> >
> > I fought with it for a good while, before I just (on a whim) switched
> > from vtkPolyData to vtkUnstructuredGrid, with all VTK_TRIANGLE cells.
> > And low and behold, it works.
> >
> > Is there some reason why a vtkPolyData can't be thresholded ( VTK5.0
> > stable)?
> >
> > ----------------------------------------
> > Randall Hand
> > Visualization Scientist
> > ERDC MSRC-ITL
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > This is the private VTK discussion list.
> > Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> >
>
>
--
----------------------------------------
Randall Hand
Visualization Scientist
ERDC MSRC-ITL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060614/a89ac282/attachment.htm>
More information about the vtkusers
mailing list