[vtk-developers] Virtual methods in VTK classes

Charl P. Botha c.p.botha at ewi.tudelft.nl
Tue Jul 1 07:44:47 EDT 2003


Hi Will!

On Tue, 2003-07-01 at 13:31, Will Schroeder wrote:
> BoxWidget is a relatively new addition (as are most of the widgets). As 
> John B. said, in many cases the methods are not virtual because the 
> implementor(s) of the class did not forsee subclassing, etc. Since we are 
> breaking new ground with the widgets (i.e., we have no pre-existing 
> implementation to compare with) I expect that things like this will 
> continue to evolve.

The 3D widgets are in my list of "most useful VTK, err, widgets", but
probably because I spend a lot of time with interaction problems. 
AFAIK, you were the major force behind this.  Thanks!!

> 
> The place to watch for virtuals is methods that are used in tight loops 
> (e.g., GetPoint(), GetCell()). After making this mistake more than once and 
> now having decent compilers on hand, I try to use templating whenever 
> possible in this situation to avoid performance problems. So if you are 
> going to modify a method to become virtual--and it's used in a tight 
> loop--you'll want to bounce it off the list and think about the performance 
> problem. Otherwise, I'd go ahead and make the changes.

Okay, noted.  I'll be very careful with this.

BTW, whilst playing with this, I noticed that HandleOn() and HandleOff()
have never been implemented.  They're declared in the class, but because
they weren't virtual, the compiler doesn't complain.  Do you have this
code lying around perhaps?  If not, I'll think something up.

Thanks again,
Charl

-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/



More information about the vtk-developers mailing list