[vtkusers] Inheritance question

Matt Valerio mattdvalerio at ieee.org
Tue Nov 8 12:16:05 EST 2005


Hello VTK users,

I'm new to VTK and am trying to write a visualization app for some data I
have.

I want to create an object (like a cone) that I can modify its height,
radium, color, opacity, ambient light, position, and direction all at once.

For example, I have the following code that creates 1 object:
----------------------------
vtkConeSource *m_pCone;
vtkPolyDataMapper *m_pConeMapper;
vtkActor *m_pConeActor;
vtkProperty *m_pConeProperty;

m_pCone = vtkConeSource::New();
m_pCone->SetHeight( 3 );
m_pCone->SetRadius( 1 );
m_pCone->SetResolution( 50 );

m_pConeProperty = vtkProperty::New();
m_pConeProperty->SetColor( 0.1, 0.6, 0.3);
m_pConeProperty->SetOpacity( 1.0 );
m_pConeProperty->SetAmbient( 0.8 );
	
m_pConeMapper = vtkPolyDataMapper::New();
m_pConeMapper->SetInput( m_pCone->GetOutput() );
m_pConeActor = vtkActor::New();
m_pConeActor->SetMapper( m_pConeMapper );
m_pConeActor->SetProperty( m_pConeProperty );
m_pConeActor->SetPosition( 1.0, 1.0, 1.0 );
-----------------------------
Then I can add m_pConeActor to the renderer.

Can I create my own class that inherits from a VTK class that will let me do
something like

MyCone* a = MyCone::New();
a->SetAttributes( 3, 1, 50, 0.1, 0.6, 0.3, 1.0, 0.8, 1.0, 1.0, 1.0 );

and set all of the values at once?

What class could I inherit from to do this?

Are there any examples to start from?

Any help would be greatly appreciated!

Thanks,
Matt






More information about the vtkusers mailing list