Deriving from VTK classes?

Bryan VanDeVen bryanv at arlut.utexas.edu
Fri Sep 17 15:51:06 EDT 1999


> Keeping track indeed is not what I desire. The same effect could be obtained
> checking the actual class name with 'GetClassName()', at the same time being
> more efficient. I still would not be able to recognize classes from my own
> extentions
> that I will write later on. This would require that any new module that
> derives from
> my extended class adds to a global pointer list, or inserts its pointer into
> every
> object that will ever reference it. I think this is impossible.

Well you could have each of your new classes register strings for their
names and new operations (that are not in normal library objects) in
some global (singleton) dictionary object.  That would allow you to
match classnames against operations in a generic fashion and would not
require any compile time change to the singleton dictionary mechanism
when new objects are added. i.e.:

vtkWindow* window = this->VTKWindow;

if ( OperationMap->Supports( window->GetClassName, "GetOrientation" ) )
{

  int* dir = window->GetOrientation();

}  else  {

  // something with regular VTKWindows...

}

Of course all of this is getting rather abstruse and seems somewhat far
afield of normal proctices, I feel.  This method probably runs afoul of
static initialization issues too.  But if you need this amount of
dynamism, perhaps the effort is justified.


> My constraints are:
> i)    I would like to be able to use the standard vtkdll.dll
>           (it is not compiled with RTT turned on by default)
> ii)   I would like to use it in a consistent manner that other
> users/designers
>       have found to work well

Ah, it had not occurred to me that RTTI was off by default. 

> I will try to compile the library with RTT turned on, and take the
> dynamic_cast<>
> route.  Given I will succeed, do you know how this could make it into the
> official
> release? (at least for Windows VC++) I think I would not be the only one who
> can
> take advantage of this.

Well, I guess the important immediate question is: how wide will this
app of your be distributed?  If it's not going to be compiled from
scratch by people who might have their own versions of vtk, then hack
away at VTK to your heart's delight.  Otherwise,  as to how it would
make it into the official release, I do not know. Perhaps an email or
"bug" request at the vtk main sight might produce a discussion among the
developers.

> BTW.: Do other compilers support this feature as well?

Well I believe that the newest g++ and Sun compilers do.  Those are the
only two I use with any frequency.  But, now that the standard is not a
moving target there are probably more and more compilers that support
these newer additions.

-- 
Bryan Van de Ven
Applied Research Labs
University of Texas, Austin


-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list