<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-family: Verdana,Geneva,sans-serif'>
<p>The code appeared a little messed up, sorry about that. I attached the code on the ColoredPoints.cxx file.</p>
<p> </p>
<div> </div>
<p>El 27-04-2015 09:59, javier.maestro@nabla-designs.es escribió:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<p>Hi all,</p>
<p>I'm testing VTK limits rendering a large number of points of a vtkPolyData structure. I'm trying to determine how many points can I use so the frame rate is fast enough for a specific application.</p>
<p>As expected, as the number of points gets bigger, the rendering takes more time and the frame rate decreases. I expect the frame rate to decrease but I also expect it to keep a constant value. However even though at first it seems to be constant, sometimes the frame rate drops drastically and it takes a while to get back to that constant rate.</p>
<p>I'm using a grid of points (128 x 400) just as an example. I get 6 FPS using the program below (PC Intel Core 2 Duo 2GHz, 3GB RAM, Windows 7), but sometimes it drops to 0 FPS and it stays in there for periods of 1 min. Is there any reason for the inconsistent frame rate?</p>
<p>Thanks.</p>
<p>#include <vtkVersion.h><br />#include <vtkSmartPointer.h><br />#include <vtkPoints.h><br />#include <vtkPolyData.h><br />#include <vtkPointData.h><br />#include <vtkCellArray.h><br />#include <vtkUnsignedCharArray.h><br />#include <vtkPolyDataMapper.h><br />#include <vtkActor.h><br />#include <vtkRenderWindow.h><br />#include <vtkRenderer.h><br />#include <vtkRenderWindowInteractor.h><br />#include <vtkVertexGlyphFilter.h><br />#include <vtkProperty.h><br />#include <vtkLookupTable.h><br />#include <vtkFloatArray.h><br />#include <vtkPoints.h><br />#include <vtkTextActor.h><br />#include <vtkTextProperty.h><br />#include <vtkCommand.h><br />#include <stdio.h><br /><br />#define LINES_X 128<br />#define LINES_Y 400<br /><br />/** Update callback. */<br />class vtkTimerCallback : public vtkCommand{<br /><br /> public:<br /> /** New operator. */<br /> static vtkTimerCallback *New(){<br /> return (vtkTimerCallback *)new vtkTimerCallback;<br /> }<br /> /** Callback timer. */ <br /> virtual void Execute(vtkObject *caller,<br /> unsigned long vtkNotUsed(eventId), void *vtkNotUsed(callData)){<br /> <br /> static char value[40];<br /> static int counter = 0;<br /><br /> vtkRenderWindowInteractor *iren = <br /> static_cast<vtkRenderWindowInteractor*>(caller);<br /><br /> // Update frame counter<br /> textActor->SetInput(value);<br /> textActor->Modified();<br /> sprintf(&value[0], "%d", counter ++); <br /><br /> // Just render again (data hasn't really changed)<br /> poly->Modified();<br /> iren->Render();<br /> }<br /><br /> // Access polydata and text actor<br /> vtkSmartPointer<vtkPolyData> poly;<br /> vtkSmartPointer<vtkTextActor> textActor;<br />};<br /><br />// Cell connectivity<br />vtkSmartPointer<vtkCellArray> getCells(){<br /><br /> vtkSmartPointer<vtkCellArray> mesh = <br /> vtkSmartPointer<vtkCellArray>::New();<br /><br /> int nx = LINES_X;<br /> int ny = LINES_Y;<br /> for(int i=0;i<nx-1;i++){<br /> for(int j=0;j<ny-1;j++){<br /> mesh->InsertNextCell(4);<br /> mesh->InsertCellPoint((0+j) + ny*i);<br /> mesh->InsertCellPoint((ny+j) + ny*i);<br /> mesh->InsertCellPoint((ny+1+j) + ny*i);<br /> mesh->InsertCellPoint((1+j)+ ny*i);<br /> }<br /> }<br /> return mesh;<br />}<br /><br />int main(int, char *[]){<br /><br /> // Polydata<br /> vtkSmartPointer<vtkPoints> points = <br /> vtkSmartPointer<vtkPoints>::New();<br /> vtkSmartPointer<vtkFloatArray> scalars = <br /> vtkSmartPointer<vtkFloatArray>::New();<br /> vtkSmartPointer<vtkPolyData> poly = <br /> vtkSmartPointer<vtkPolyData>::New();<br /><br /> for(int a=0;a<LINES_X;a++){<br /> for(int b=0;b<LINES_Y;b++){<br /> points->InsertNextPoint((float)a, (float)b, 0);<br /> float value = (float)a/(float)LINES_X;<br /> scalars->InsertNextValue(value);<br /> }<br /> } <br /> poly->SetPoints(points);<br /> poly->GetPointData()->SetScalars(scalars);<br /> poly->SetPolys(getCells());<br /><br /> // Mapper<br /> vtkSmartPointer<vtkPolyDataMapper> mapper =<br /> vtkSmartPointer<vtkPolyDataMapper>::New();<br /> mapper->SetInputData(poly);<br /> mapper->ScalarVisibilityOn();<br /> mapper->SetScalarModeToUsePointData();<br /> mapper->SetColorModeToMapScalars();<br /> mapper->SetScalarRange(0, 1.0);<br /><br /> // Lookup Table<br /> vtkSmartPointer<vtkLookupTable> lookupTable = <br /> vtkSmartPointer<vtkLookupTable>::New();<br /> lookupTable->SetTableRange(0, 1.0);<br /> mapper->SetLookupTable(lookupTable);<br /> mapper->ReleaseDataFlagOn();<br /> mapper->ImmediateModeRenderingOn();<br /><br /> // Actor<br /> vtkSmartPointer<vtkActor> actor =<br /> vtkSmartPointer<vtkActor>::New();<br /> actor->SetMapper(mapper);<br /><br /> // Renderer<br /> vtkSmartPointer<vtkRenderer> renderer =<br /> vtkSmartPointer<vtkRenderer>::New();<br /> vtkSmartPointer<vtkRenderWindow> renderWindow =<br /> vtkSmartPointer<vtkRenderWindow>::New();<br /> renderWindow->AddRenderer(renderer);<br /><br /> // Setup the text and add it to the window<br /> vtkSmartPointer<vtkTextActor> textActor = <br /> vtkSmartPointer<vtkTextActor>::New();<br /> textActor->GetTextProperty()->SetFontSize ( 24 );<br /> textActor->SetPosition2 ( 10, 40 );<br /> renderer->AddActor2D ( textActor );<br /> textActor->SetInput ( "0" );<br /> textActor->GetTextProperty()->SetColor ( 1.0,0.0,0.0 );<br /><br /> // Add actors<br /> renderer->AddActor(actor);<br /> renderer->AddActor(textActor);<br /><br /> // Interactor<br /> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br /> vtkSmartPointer<vtkRenderWindowInteractor>::New();<br /> renderWindowInteractor->SetRenderWindow(renderWindow);<br /><br /> // Render<br /> renderWindow->Render();<br /> renderWindowInteractor->Initialize(); <br /><br /> // Sign up to receive TimerEvent (Update)<br /> vtkSmartPointer<vtkTimerCallback> timerCallback = <br /> vtkSmartPointer<vtkTimerCallback>::New();<br /> timerCallback->poly = poly;<br /> timerCallback->textActor = textActor;<br /> renderWindowInteractor->AddObserver(vtkCommand::TimerEvent, timerCallback);<br /> renderWindowInteractor->CreateRepeatingTimer(1);<br /><br /> // Start interactor<br /> renderWindowInteractor->Start(); <br /><br /> return EXIT_SUCCESS;<br />}<br /><br /></p>
<div> </div>
</blockquote>
</body></html>