[vtkusers] RE: deriving my own class from vtkActor

vtk replies vtk_replies at yahoo.com
Thu Oct 10 17:27:29 EDT 2002


Hi,
I ran into a similar problems with deriving my own
classes from vtk classes - it turned out that when I
created my child class instance, the parent class
variables were not intialized. These variables were
used in some of the functions in the parent class that
I wanted to use. Since I use vtk3.2, I dont know what
are the variables in vtkActor class that need
initialization in vtk4.0

[The following is an overkill, but it is just another
way of doing things - (the disadvantages of doing it
are having to re-run config , making changes to lib,
and possible memory leaks - not sure - there are
probably better ways- if at all nothing, someone will
point to simpler way to you after seeing my elaborate
mail :)) ).

(1) put the additional function, eg., fun1() , that
you wish to have in your derived class as a Virtual
function in the vtkActor class.

(2) then, define the fun1() in the derived class to do
what you want it to do.

(3) define the New() function in your derived class. 

(4) in your derived class constructor call the
vtkActor() contstructor with appropriate values for
intializing any variables in the class - this will
properly instantiate any vtkActor class variables.

(5) you probably already have a destructor for your
derived class in place.

(5) for destroying instances of your derived class,
call the Delete() method ( since u created the derived
class using the New() method in vtk). 
It should ( probably not cause any mem leaks :) ) call
delete() of vtkActor class and then finally delete
your class instance too. 

(6) in the Makefile.in of the appropriate directory,
add vtkActor to the list of Abstract classes

(7) add your derived class to the list of Concrete
classes

(8) SAVE all other files that you have changed and
your own files to a different dir. 

(9) re-run config with your own options and make to
integrate your class into the library.
]

good luck !

cheers,
Joseph. 


--- vtkusers-request at public.kitware.com wrote:
> Send vtkusers mailing list submissions to
> 	vtkusers at public.kitware.com
> 
> To subscribe or unsubscribe via the World Wide Web,
> visit
> 	http://public.kitware.com/mailman/listinfo/vtkusers
> or, via email, send a message with subject or body
> 'help' to
> 	vtkusers-request at public.kitware.com
> 
> You can reach the person managing the list at
> 	vtkusers-admin at public.kitware.com
> 
> When replying, please edit your Subject line so it
> is more specific
> than "Re: Contents of vtkusers digest..."
> 
> 

> Subject: RE: [vtkusers] deriving my own class from
> vtkActor
> From: "Charl P. Botha" <c.p.botha at its.tudelft.nl>
> To: vtkusers at public.kitware.com
> Date: 09 Oct 2002 15:48:53 +0200
> 
> On Wed, 2002-10-09 at 15:29, Jerome, Ron wrote:
> > I ran into the same problem, I derived my class
> from vtkOpenGLActor instead
> > and it worked fine.
> 
> As far is I know, this is not The Right Way(tm) if
> you want to add
> functionality in a generic fashion.  This would mean
> that your class can
> only work on OpenGL targets.  A better way would be
> to derive from
> vtkActor and also CONTAIN an instance of vtkActor as
> member that can be
> used to perform rendering.  The contained vtkActor
> will specialise (due
> to the object factories) as per usual.
> 
> > Ron Jerome
> > Institute for Chemical Process and 
> > Environmental Technology
> > National Research Council Canada
> > 613-993-5346
> > 
> > 
> > >-----Original Message-----
> > >From: Steffen Oeltze
> [mailto:Steffen.Oeltze at Student.Uni-Magdeburg.DE]
> > >Sent: Wednesday, October 09, 2002 6:00 AM
> > >To: Vtkusers (E-mail)
> > >Subject: [vtkusers] deriving my own class from
> vtkActor
> > >
> > >
> > >Dear VTK-users,
> > >
> > >I have tried to derive my own class from vtkActor
> using the following
> > >code:
> > >
> > >class FIB_TRACK : public vtkActor
> > >{
> > >public:
> > >    FIB_TRACK(double [3], double [3], bool);
> > >    ~FIB_TRACK();
> > >....
> > >}
> > >
> > >For creating a new object I use:
> > >
> > >FIB_TRACK *newAct = new FIB_TRACK(seedpoint,
> dims, true);
> > >
> > >Then, I construct the rendering pipeline, add the
> actor to the
> > >renderer and render the window but nothing
> happens. Is there
> > >anyone who can help me ?
> > >
> > >Regards,
> > >Steffen
> > >_______________________________________________
> > >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://public.kitware.com/mailman/listinfo/vtkusers
> > >
> -- 
> charl p. botha http://cpbotha.net/
> http://visualisation.tudelft.nl/
> 


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com



More information about the vtkusers mailing list