[vtkusers] Wireframe embed on the Surface
John Platt
jcplatt at lineone.net
Sun Mar 21 14:05:55 EST 2004
Hi Subhas,
Try using a separate mapper for sphere2
vtkPolyDataMapper *sphereMapper2 = vtkPolyDataMapper::New();
sphereMapper2->SetInput(sphereS->GetOutput());
vtkActor *sphere2 = vtkActor::New();
// sphere2->SetMapper(sphereMapper);
sphere2->SetMapper(sphereMapper2);
You will also probably need
vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
More information can be found if you search the mailing list.
John.
-----Original Message-----
From: vtkusers-admin at vtk.org [mailto:vtkusers-admin at vtk.org] On Behalf
Of Hamp Donald
Sent: 21 March 2004 17:30
To: vtk
Cc: vtk
Subject: [vtkusers] Wireframe embed on the Surface
Hi
I want to display the surface plot of a sphere and
I want to embed the wireframe (different color) of the
same sphere on it.
I have used two actors using the same geometry.
Please find my program below. When I am commenting the
line
ren1->AddActor(sphere1);
I am getting the wireframe plot (as it should be). But
it gives the surface plot of the sphere when I
uncommented the line ren1->AddActor(sphere1); During
the surface plot, it uses the wireframe color.
If I display wireframe in a different location, it
gives the surface plot of both the spheres with
different color.
I am doing some mistake. Respond Please.
Best Regards
Subhas
int main(int argc, char *argv[])
{
// The following lines create a sphere represented
by polygons.
//
vtkSphereSource *sphereS = vtkSphereSource::New();
sphereS->SetThetaResolution(10);
sphereS->SetPhiResolution(10);
sphereS->SetRadius(1.0);
// The mapper is responsible for pushing the
geometry into the graphics
// library. It may also do color mapping, if scalars
or other attributes
// are defined.
//
vtkPolyDataMapper *sphereMapper =
vtkPolyDataMapper::New();
sphereMapper->SetInput(sphereS->GetOutput());
//sphereMapper->SetInput(triangularMesh);
// The actor is a grouping mechanism: besides the
geometry (mapper), it
vtkActor *sphere1 = vtkActor::New();
sphere1->SetMapper(sphereMapper);
sphere1->GetProperty()->SetColor(1,1,1);
sphere1->GetProperty()->SetAmbient(1.0);
sphere1->GetProperty()->SetDiffuse(0);
sphere1->GetProperty()->SetSpecular(0);
//sphere->GetProperty()->SetRepresentationToWireframe();
//sphere->GetProperty()->SetLineWidth(1.5);
//sphere->GetProperty()->SetSpecularPower(5.0);
vtkActor *sphere2 = vtkActor::New();
sphere2->SetMapper(sphereMapper);
sphere2->GetProperty()->SetColor(1,0,0);
sphere2->GetProperty()->SetAmbient(1.0);
sphere2->GetProperty()->SetDiffuse(0);
sphere2->GetProperty()->SetSpecular(0);
sphere2->GetProperty()->SetRepresentationToWireframe();
//sphere2->SetPosition(0, 2, 0);
// Create the graphics structure. The renderer
renders into the
// render window. The render window interactor
captures mouse events
// and will perform appropriate camera or actor
manipulation
// depending on the nature of the events.
//
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
// Add the actors to the renderer, set the
background and size.
//
ren1->AddActor(sphere1);
ren1->AddActor(sphere2);
ren1->SetBackground(0.1, 0.2, 0.4);
renWin->SetSize(400, 200);
// Set up the lighting.
//
vtkLight *light = vtkLight::New();
light->SetFocalPoint(1.875,0.6125,0);
light->SetPosition(0.875,1.6125,1);
ren1->AddLight(light);
// We want to eliminate perspective effects on the
apparent lighting.
// Parallel camera projection will be used. To zoom
in parallel projection
// mode, the ParallelScale is set.
//
ren1->GetActiveCamera()->SetFocalPoint(0,0,0);
ren1->GetActiveCamera()->SetPosition(0,0,1);
ren1->GetActiveCamera()->SetViewUp(0,1,0);
ren1->GetActiveCamera()->ParallelProjectionOn();
ren1->ResetCamera();
ren1->GetActiveCamera()->SetParallelScale(1.5);
// This starts the event loop and invokes an initial
render.
//
iren->Initialize();
iren->Start();
// Exiting from here, we have to delete all the
instances that
// have been created.
//
sphere1->Delete();
sphere2->Delete();
sphereMapper->Delete();
//sphere1->Delete();
ren1->Delete();
renWin->Delete();
iren->Delete();
return 0;
}
__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list