[vtkusers] Disappearing image

Bill Lorensen bill.lorensen at gmail.com
Tue Jun 1 22:45:44 EDT 2010


You must:
ren->AddActor(actor);
before the first render.


On Sat, May 29, 2010 at 8:39 AM, Roger Mason <rmason at mun.ca> wrote:
> Hello,
>
> I have created the following by translation to C++ from a file
> PerlinTerrain.py found on the web.  The Python version produces and
> displays a surface.
>
> // #includes snipped
> int main(int argc, char** argv)
> {
>
>  vtkPlane* plane = vtkPlane::New();
>
>  vtkPerlinNoise* p1 = vtkPerlinNoise::New();
>  p1->SetFrequency(1, 1, 0);
>
>  vtkPerlinNoise* p2 = vtkPerlinNoise::New();
>  p2->SetFrequency(3, 5, 0);
>  p2->SetPhase(0.5, 0.5, 0);
>
>  vtkPerlinNoise* p3 = vtkPerlinNoise::New();
>  p3->SetFrequency(16, 16, 0);
>
>  vtkImplicitSum* sum = vtkImplicitSum::New();
>  sum->SetNormalizeByWeight(1);
>  sum->AddFunction(plane);
>  sum->AddFunction(p1, 0.2);
>  sum->AddFunction(p2, 0.1);
>  sum->AddFunction(p3, 0.02);
>
>  vtkSampleFunction* sample = vtkSampleFunction::New();
>  sample->SetImplicitFunction(sum);
>  sample->SetSampleDimensions(65, 65, 20);
>  sample->SetModelBounds(-1, 1, -1, 1, -0.5, 0.5);
>  sample->ComputeNormalsOff();
>
>  vtkContourFilter* surface = vtkContourFilter::New();
>  surface->SetInputConnection(sample->GetOutputPort());
>  surface->SetValue(0, 0.0);
>
>  vtkPolyDataNormals* smooth = vtkPolyDataNormals::New();
>  smooth->SetInputConnection(surface->GetOutputPort());
>  smooth->SetFeatureAngle(90);
>
>  vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
>  mapper->SetInputConnection(smooth->GetOutputPort());
>  mapper->ScalarVisibilityOff();
>
>  vtkActor* actor = vtkActor::New();
>  actor->SetMapper(mapper);
>  actor->GetProperty()->SetColor(0.4, 0.2, 0.1);
>
>  // Create the renderer etc.
>  vtkRenderer* ren = vtkRenderer::New();
>  vtkRenderWindow* renWin = vtkRenderWindow::New();
>  renWin->AddRenderer(ren);
>  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
>  iren->SetRenderWindow(renWin);
>
>  iren->Initialize();
>  renWin->Render();
>  iren->Start();
>
> // Clean-up snipped
>  return 0;
> }
>
> The version above compiles without errors or warnings.  The window
> appears and remains visible.  The image seems to be drawn but then
> disappears, leaving an empty window.
>
> This is my first try at using VTK.  If anyone can spot my mistake,
> please help.
>
> Thanks,
> Roger
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK 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