[vtkusers] CellLocator, Octrees and Segfaults...

Obada Mahdi omahdi at gmx.de
Sun Oct 22 18:51:24 EDT 2006


Hi Philipp!

On 10/22/06, Philipp Kemmeter <gildedfalcon at googlemail.com> wrote:
> I've tried to use it and to iterate through those cubic cells which
> are the nodes of an octree. But  without success.
>
> Here is the code snip of my try:
[...]
>   int num = cellLocator->GetNumberOfBuckets();
>   for (int i = 0; i < num; i++) {
>         std::cout << "Bucket " << i << ": ";
>         std::cout << cellLocator->GetCells(i)->GetNumberOfIds();
>   }
>
>
> The output is short: "Segmentation Error".

The problem is that only leaf nodes point to actual instances of
"vtkIdList".  Inner nodes are marked with an internally defined
constant (1), causing a segfault when being dereferenced (leaf nodes
are probably NULL if the corresponding octant is empty, I am not sure
about that).

The methods GetNumberOfBuckets() and GetCells(int) interface directly
to the internal array representing the "flattened" octree.  I am not
sure, however, how much of this structure is actually meant to be
exposed through the vtkCellLocator interface; the doxygen
documentation does not seem to mention the array layout, and constants
for empty or inner nodes are not defined as part of the public
interface either.

Hopefully someone else can clear things up.


Regards

Obada



More information about the vtkusers mailing list