[vtkusers] Closest point on a streamtube
Jeff Lee
jeff at cdnorthamerica.com
Tue Aug 16 16:54:42 EDT 2005
By the way, this can easily happen if you have a polydata like a
streamline which might index into a set of points which aren't
referenced by the polydata's cells. Could theoretically happen with any
polydata, though.
-J
Jeff Lee wrote:
> Hi James,
> Without getting into too much detail, there is a bug in
> vtkPointLocator which can potentially access a negative index into the
> Hashtable array (buckets) if there are points in the dataset which
> fall outside the bounds of the dataset. I have been so busy that I
> haven't submitted a patch, but you can try this if you can't wait.
>
> vtkPointLocator.cxx::BuildLocator() should look something like this
> (add the stuff in bold italics)
>
> ...
> idx = ijk[0] + ijk[1]*ndivs[0] + ijk[2]*product;
> */ if (idx > -1)
> { // make sure valid bucket id, negative if point outside
> // dataset bounds.../*
> bucket = this->HashTable[idx];
> if ( ! bucket )
> {
> bucket = vtkIdList::New();
> bucket->Allocate(this->NumberOfPointsPerBucket,
> this->NumberOfPointsPerBucket/3);
> this->HashTable[idx] = bucket;
> */ }/*
> bucket->InsertNextId(i);
> }
>
> ...
>
> James C Robinson wrote:
>
>> Dear All,
>>
>> I have a set of flow vectors associated with the points of an
>> unstructured grid. I use the following to create a stream tube:
>>
>> pStreamLine->SetInput(pUnstructuredGrid) ; // vtkStreamTracer
>>
>> pStreamTube->SetInput(pStreamLine->GetOutput()) ; // vtkTubeFilter
>>
>> pStreamMapper->SetInput(pStreamTube->GetOutput()) ; // vtkPolyDataMapper
>>
>> pStreamActor->SetMapper(pStreamMapper); // vtkActor
>>
>> At any given time I wish to find the closest point in the stream tube
>> (say the closest point in the underlying polyline of the stream
>> tracer) to the camera (in order to keep the radius of the stream tube
>> fairly constant on the screen). To this end I do the following:
>>
>> vtkDataSet* pDataSet =
>> (vtkDataSet*)((pStreamLine->GetOutput())->GetPoints()) ;
>>
>> pClosestStreamPointLocator->SetDataSet(pDataSet) ; // vtkPointLocator
>>
>> pClosestStreamPointLocator->AutomaticOn() ;
>>
>> pClosestStreamPointLocator->BuildLocator() ;
>>
>> I then use
>>
>> pClosestStreamPointLocator->BuildLocator() ; // In case the stream
>> tube has changed since the locator was last updated.
>>
>> pClosestStreamPointLocator->FindClosestPoint(camPos) ; // Where
>> camPos is a float[3] array.
>>
>> when I wish to find the closest point. However, it causes a crash. I
>> am obviously doing something pretty simple wrong. Please advise…….
>>
>> Jim
>>
>> *James C Robinson**, *
>>
>> *+** 42 Rivergrove**,***
>>
>> * **Glanmire**,***
>>
>> * **Co. **Cork,*
>>
>> * **Eire*
>>
>> *'** +353 21 4822028*
>>
>> * +353 87 2393010*
>>
>> *-** jrobinson at eircom.net <mailto:jrobinson at eircom.net>>
>> <mailto:jrobinson at eircom.net> *
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>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
>>
>>
>
>_______________________________________________
>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
>
>
More information about the vtkusers
mailing list