[vtkusers] Moving points

Sensei senseiwa at tin.it
Fri Nov 19 09:10:23 EST 2004


Hi.

I'm new to VTK, and I'm finding difficulties in creating an object and 
making one of its points move, and as you can easily understand, without 
succeeding. I don't know how to update the geometry of a convex set and 
then update the scene.

This is what I do:

1. create the points
2. create a convex set
3. creat a grid (is there another way?)
4. create a mapper, actor, render...
5. move the point (the point set)




*beforePoints = vtkPoints::New();
beforePoints->SetNumberOfPoints(nop);
for (i = 0; i < nop; i++)
    beforePoints->InsertPoint(i, theDomain->getNode(i)->getCrds()[0],
                                 theDomain->getNode(i)->getCrds()[1],
                                 theDomain->getNode(i)->getCrds()[2]);

*beforeSolid = vtkConvexPointSet::New();
beforeSolid->GetPointIds()->SetNumberOfIds(nop);
for (i = 0; i < nop; i++)
    beforeSolid->GetPointIds()->SetId(i, i);

*beforeGrid = vtkUnstructuredGrid::New();
beforeGrid->Allocate(1, 1);
beforeGrid->InsertNextCell(beforeSolid->GetCellType(),
                            beforeSolid->GetPointIds());
beforeGrid->SetPoints(beforePoints);

*beforeMapper = vtkDataSetMapper::New();
beforeMapper->SetInput(beforeGrid);

*beforeActor = vtkActor::New();
beforeActor->SetMapper(beforeMapper);
beforeActor->GetProperty()->SetColor(1, 0, 0);
beforeActor->GetProperty()->SetOpacity(0.1);

*theRenderer = vtkRenderer::New();
theRenderer->AddActor(beforeActor);
theRenderer->SetBackground(0.1, 0.2, 0.5);

*theWindow = vtkRenderWindow::New();
theWindow->AddRenderer(theRenderer);
theWindow->SetSize(500, 500);

*theInteractor = vtkRenderWindowInteractor::New();
theInteractor->SetRenderWindow(theWindow);

theInteractor->Initialize();
theWindow->Render();

float step = 0.1;
int times = 0;
while (times < 1000)
{
    beforePoints->GetPoint(0)[0] += step;
    // AND NOW????
    times++;
    theRenderer->Render();
    sleep(1);
}



-- 
Sensei <mailto:senseiwa at tin.it> <pgp:8998A2DB>
        <icqnum:241572242>
        <yahoo!:sensei_sen>
        <msn-id:sensei_sen at hotmail.com



More information about the vtkusers mailing list