Hi everyone,<div><br></div><div>I want to display efficiently a streaming data. Every fraction of second, I get approximately 100 new points with colors, and I want to display the continuous stream of data. </div><div>Here is what I have done,</div>
<div><br></div><div>I have created a vtkPolyData object. Every time I get new set of points I put them in a cell and dump the cell in the polydata object.</div><div><br></div><div>the polydata object is connected to vtkPolyDataMapper . I call mapper->modified() and mapper->update() method every time I had new data.</div>
<div><br></div><div>This works fine when I don't interact the display window. When I try to interact the display window with mouse , it gives segmentation fault with nvidia opengl driver.</div><div><br></div><div>Can anyone please guide me to do this task correctly. i am relatively new to rendering portion of vtk. If there is any reference code for it , do point it out.</div>
<div><br></div><div><br></div><div><br></div><div>Code------------</div><div><br></div><div>code for adding new data:</div><div><br></div><div><div>void update_data(std::vector< double > data_set, std::vector< char > colors)</div>
<div>{</div></div><div><div> /* Checks for validity of input data. */ </div><div> assert( data_set.size() == colors.size() );</div><div> </div><div> int _num_pts = data_set.size() / 3; </div><div> </div><div> display_data->GetVerts()->InsertNextCell( _num_pts );</div>
<div> </div><div> double x[3];</div><div> </div><div> vtkPoints *_points;</div><div> </div><div> vtkUnsignedCharArray *_colors ;</div><div> </div><div> vtkCellArray *_verts = display_data->GetVerts();</div><div> </div>
<div> _verts->InsertNextCell(_num_pts);</div><div> </div><div> if( display_data->GetNumberOfPoints() > 0 )</div><div> {</div><div> _points = display_data->GetPoints();</div><div> </div><div> _colors = (vtkUnsignedCharArray *)(display_data->GetPointData()->GetScalars());</div>
<div> </div><div> }</div><div> else</div><div> {</div><div> _points = vtkPoints::New();</div><div> </div><div> _colors = vtkUnsignedCharArray::New();</div><div> </div><div> _colors->SetName("colors");</div>
<div> _colors->SetNumberOfComponents(3);</div><div> </div><div> }</div><div> </div><div> for( int i = 0; i < _num_pts; i++ )</div><div> {</div><div> x[0] = data_set[ 3 * i ];</div><div> x[1] = data_set[ 3 * i + 1 ];</div>
<div> x[2] = data_set[ 3 * i + 2 ];</div><div> </div><div> int _id = _points->InsertNextPoint( x );</div><div> </div><div> _verts->InsertCellPoint( _id );</div><div> </div><div> const unsigned char _color[] = { colors[3 * i + 2], colors[3 * i + 1] , colors[3 * i ] };</div>
<div> </div><div> ( _colors )->InsertNextTupleValue( _color );</div><div> } </div></div><div><br></div><div>}</div><div><br></div><div><br></div><div><br></div><div>-------------------------------------------------For rendering-----------------------------------------------------------</div>
<div><br></div><div><br></div><div><div> mapper->Modified();</div><div> mapper->Update();</div><div> renderer->ResetCameraClippingRange();</div><div> rendererWindow->Render();</div></div><div><br></div><div><br>
</div><div><br></div><div>Thanks</div><div><br></div><div>Avanindra Singh</div>