[vtkusers] Improve the Rendering Performance...
Gatos Gatos
gatos12 at hotmail.com
Mon Feb 21 12:47:52 EST 2005
Hi
I would like to know if there is any way to to improve the performance on
the
following code.
I run the following example with 100000 points (here only 6) and starts to
be slow.
I played with the
vtkTriangleFilter,
vtkStripper ,
and the ImmediateModeRenderingOff();
but it looks that there is no difference in preformance.
Also how can I use the filter after I initialize the actor (eg: during the
interaction)?
//filter->SetTargetReduction(0.5);
Is it any way or I have to reconstruct the triangle mesh from the begining?
Thank you very much in advance
kostas
-----------------------------------------------------------------
vtkFloatArray* pcoords = vtkFloatArray::New();
pcoords->SetNumberOfComponents(3);
pcoords->SetNumberOfTuples(6);
float pts[6][3] = { {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0},
{1.0, 0.0, 0.0}, {1.0, 1.0, 0.0},
{2.0, 0.0, 0.0}, {2.0, 1.0, 0.0} };
for (int i=0; i<6; i++) { pcoords->SetTuple(i, pts[i]); }
vtkPoints* points = vtkPoints::New();
points->SetData(pcoords);
// Create the dataset. In this case, we create a vtkPolyData
vtkPolyData* polydata = vtkPolyData::New();
// Assign points and cells
polydata->SetPoints(points);
vtkTriangle *triangle;
vtkCellArray* tris = vtkCellArray::New();
triangle=vtkTriangle::New();
triangle->GetPointIds()->SetId(0,0);
triangle->GetPointIds()->SetId(1,2);
triangle->GetPointIds()->SetId(2,1);
tris->InsertNextCell(triangle);
triangle->Delete();
polydata->SetPolys(tris);
//vtkDecimatePro * filter = vtkDecimatePro::New();
//filter->SetInput(polydata);
//filter->SetMaximumError(0);
//filter->SetTargetReduction(0.5);
//polydata = (vtkPolyData*) filter->GetOutput();
vtkTriangleFilter *vtf = vtkTriangleFilter::New();
vtf->SetInput(polydata);
polydata = (vtkPolyData*) vtf->GetOutput();
vtkPolyDataNormals *bNormals = vtkPolyDataNormals::New();
bNormals->SetInput(polydata);
//bNormals->SetFeatureAngle(60.0);
vtkStripper *bStripper = vtkStripper::New();
bStripper->SetInput(bNormals->GetOutput());
//Create the mapper
vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
mapper->SetInput(bStripper->GetOutput());
mapper->ScalarVisibilityOff();
mapper->ImmediateModeRenderingOff();
// Create an actor.
vtkActor* actor = vtkActor::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(1,1,0);
renderer->AddActor(actor);
More information about the vtkusers
mailing list