<DIV>I derived a class from vtkOpenGLActor, it works fine for me.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Luke<BR><BR><B><I>Wiebke Timm &lt;wiebke.timm@uni-bielefeld.de&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Hi!<BR><BR>On 04.05.2004, at 16:19, Simon DROUIN wrote:<BR><BR>&gt; I had the same problem.<BR><BR>Same for me... Trying to make an actor class which can hold an <BR>additional int for an ID. Seems like a lot of people need to do <BR>something like that and it's not covered in the book in detail... :( So <BR>maybe somebody who already did that and it worked could write a howto <BR>or something?<BR>I wasn't sure if it was better to start a new thread for this but <BR>because it's basically the same problem I posted to this thread.<BR><BR><BR>&gt; There is probably a more elegant solution using factories, but I <BR>&gt; haven't tried it.<BR><BR>Hm, I use vtk with qt and tried to derive a factory like it's described <BR>in the book. But my actors aren't shown either. I'm not sure if I have <BR>to derive from vtkActor or vtkOpenGLActor either...<BR><BR>I extended vtkFactory _and_ vtkActor
 because the book said so. That's <BR>a lot of code for adding an int to a class...<BR><BR><BR>This is my code, maybe someone can say what I did wrong so maybe all of <BR>us could use it then...? It compiles but no actors are shown and at the <BR>end of exectution (when I quit the qt Application) it segfaults.<BR><BR><BR>vtkMyFactory.h:<BR><BR>################################################################ Begin <BR>of file<BR>#ifndef OBJF_H<BR>#define OBJF_H<BR>#include <VTKOBJECTFACTORY.H><BR>#endif<BR><BR>#include <VTKMYACTOR.H><BR><BR><BR>class vtkMyFactory : public vtkObjectFactory {<BR><BR>public:<BR>vtkMyFactory();<BR>virtual const char* GetVTKSourceVersion();<BR>virtual const char* GetDescription();<BR><BR>};<BR><BR>################################################################ End of <BR>file<BR><BR><BR><BR>vtkMyFactory.cc:<BR><BR>################################################################ Begin <BR>of file<BR>#include "vtkMyFactory.h"<BR>#include
 "vtkVersion.h"<BR><BR>VTK_CREATE_CREATE_FUNCTION(vtkMyActor);<BR><BR>VTK_FACTORY_INTERFACE_IMPLEMENT(vtkMyFactory);<BR><BR>vtkStandardNewMacro(vtkMyFactory);<BR><BR><BR>vtkMyFactory::vtkMyFactory() {<BR><BR>this-&gt;RegisterOverride("vtkActor", "vtkMyActor", "vtkActor with ID", <BR>1,<BR>vtkObjectFactoryCreatevtkMyActor);<BR><BR>}<BR><BR>const char* vtkMyFactory::GetVTKSourceVersion() {<BR>return VTK_SOURCE_VERSION;<BR>}<BR><BR>const char* vtkMyFactory::GetDescription() {<BR>return "Factory needed to extend vtkActor by and int ID...";<BR>}<BR><BR>################################################################ End of <BR>file<BR><BR><BR><BR><BR>vtkMyActor.h:<BR><BR>################################################################ Begin <BR>of file<BR>#include <VTKACTOR.H><BR><BR>class vtkMyActor : public vtkActor {<BR>public:<BR>vtkMyActor();<BR>int GetID();<BR>void SetID(int id);<BR>static vtkMyActor* New();<BR><BR>private:<BR>int id; // id of this glyph's
 actor<BR><BR>};<BR><BR>################################################################ End of <BR>file<BR><BR><BR><BR><BR>vtkMyActor.cc:<BR><BR>################################################################ Begin <BR>of file<BR>#include "vtkMyActor.h"<BR><BR>#ifndef OBJF_H<BR>#define OBJF_H<BR>#include <VTKOBJECTFACTORY.H><BR>#endif<BR><BR>#include "vtkSetGet.h"<BR><BR>vtkMyActor::vtkMyActor() {<BR>this-&gt;id = -1;<BR>}<BR><BR>int vtkMyActor::GetID() {<BR>return this-&gt;id;<BR>}<BR><BR>void vtkMyActor::SetID(int id) {<BR>this-&gt;id = id;<BR>}<BR><BR>vtkStandardNewMacro(vtkMyActor);<BR>################################################################ End of <BR>file<BR><BR>vtkStandardNewMacro is defined in vtkSetGet.h...<BR><BR><BR><BR><BR>GUI.cc (which is called by my main method because it's a QWidget- I <BR>omitted the includes and unrelevant stuff) holds<BR><BR>#######<BR>GUI::GUI(QWidget* parent, const char* name) : QWidget(parent,name)
 {<BR><BR>vtkObjectFactory::RegisterFactory((vtkObjectFactory*)vtkMyFactory:: <BR>New());<BR>vtkQtObjectFactory::RegisterObjectFactory();<BR><BR><BR>...<BR><BR># All Actors are added to the renderer with ren-&gt;AddActor(actor);<BR><BR>...<BR><BR>}<BR><BR>#######<BR><BR>That stuff already worked/showed Actors for the code I posted earlier <BR>on this mailing list, so the error is definitely in the definion of the <BR>vtkMyActors. Back then I inherited from vtkActor directly overwriting <BR>the New method and it _showed_ the actors.<BR><BR><BR>I also ran valgrind ( a memory leak checker) on the program that held <BR>of the code above and it gave me this many times - I don't know what <BR>happens, but the int is not allocated I think:<BR><BR>==521== Invalid read of size 4<BR>==521== at 0x40AD5FD7: <BR>vtkObjectFactory::RegisterFactory(vtkObjectFactory*) (in /usr/lib/libvt<BR>==521== by 0x805D312: GUI::GUI(QWidget*, char const*) (in <BR>/home/goya/glyphview/Tests/GlyphWrap<BR>==521== by
 0x805EA98: main (in <BR>/home/goya/glyphview/Tests/GlyphWrapper-Test/GUI)<BR>==521== Address 0x450FAFF0 is not stack'd, malloc'd or free'd<BR><BR><BR>...and this:<BR><BR>==521== Invalid read of size 4<BR>==521== at 0x40AD4E92: vtkObjectBase::PrintHeader(std::ostream&amp;, <BR>vtkIndent) (in /usr/lib/libvt<BR>==521== by 0x405A2DCC: vtkRenderer::Render() (in <BR>/usr/lib/libvtkRendering.so.4.2.4)<BR>==521== by 0x405AA521: vtkRendererCollection::Render() (in <BR>/usr/lib/libvtkRendering.so.4.2.4)<BR>==521== by 0x4059875D: vtkRenderWindow::DoStereoRender() (in <BR>/usr/lib/libvtkRendering.so.4.2.4<BR><BR>==521== Invalid read of size 4<BR>==521== at 0x40AAB4B2: operator&lt;&lt;(std::ostream&amp;, vtkIndent const&amp;) <BR>(in /usr/lib/libvtkCommon.s<BR>==521== by 0x40AD4EB7: vtkObjectBase::PrintHeader(std::ostream&amp;, <BR>vtkIndent) (in /usr/lib/libvt<BR>==521== by 0x405A2DCC: vtkRenderer::Render() (in <BR>/usr/lib/libvtkRendering.so.4.2.4)<BR>==521== by 0x405AA521:
 vtkRendererCollection::Render() (in <BR>/usr/lib/libvtkRendering.so.4.2.4)<BR>==521== Address 0x4 is not stack'd, malloc'd or free'd<BR><BR>==521== Process terminating with default action of signal 11 (SIGSEGV): <BR>dumping core<BR>==521== Address not mapped to object at address 0x4<BR>==521== at 0x40AAB4B2: operator&lt;&lt;(std::ostream&amp;, vtkIndent const&amp;) <BR>(in /usr/lib/libvtkCommon.s<BR>==521== by 0x40AD4EB7: vtkObjectBase::PrintHeader(std::ostream&amp;, <BR>vtkIndent) (in /usr/lib/libvt<BR>==521== by 0x405A2DCC: vtkRenderer::Render() (in <BR>/usr/lib/libvtkRendering.so.4.2.4)<BR>==521== by 0x405AA521: vtkRendererCollection::Render() (in <BR>/usr/lib/libvtkRendering.so.4.2.4)<BR><BR><BR>...and in the leak summary:<BR><BR>==521== 24 bytes in 1 blocks are definitely lost in loss record 137 of <BR>449<BR>==521== at 0x4002F202: operator new(unsigned) <BR>(vg_replace_malloc.c:162)<BR>==521== by 0x40AD2E45: vtkObject::New() (in <BR>/usr/lib/libvtkCommon.so.4.2.4)<BR>==521==
 by 0x805D30A: GUI::GUI(QWidget*, char const*) (in <BR>/home/goya/glyphview/Tests/GlyphWrap<BR>==521== by 0x805EA98: main (in <BR>/home/goya/glyphview/Tests/GlyphWrapper-Test/GUI)<BR>==521==<BR>==521==<BR>==521== 48 bytes in 1 blocks are definitely lost in loss record 207 of <BR>449<BR>==521== at 0x4002F202: operator new(unsigned) <BR>(vg_replace_malloc.c:162)<BR>==521== by 0x412BAD0C: (within /usr/lib/libqt-mt.so.3.2.3)<BR>==521== by 0x412BD26A: QGLWidget::setContext(QGLContext*, QGLContext <BR>const*, bool) (in /usr/li<BR>==521== by 0x412BCED5: QGLWidget::init(QGLContext*, QGLWidget <BR>const*) (in /usr/lib/libqt-mt.so<BR><BR><BR><BR>I didn't post everything from the valgrind output because it would make <BR>this post even bigger, but I hope I got the important parts of it.<BR><BR>Does anyone have an idea what's wrong? Maybe someone with knowledge of <BR>the things that vtk does internally...<BR>I would be really really thankful and maybe it helps others out there <BR>too if we
 manage to get a working derivation of a vtkActor...<BR><BR><BR>Ciao!<BR>Wiebke<BR><BR>_______________________________________________<BR>This is the private VTK discussion list. <BR>Please keep messages on-topic. Check the FAQ at: <HTTP: vtkfaq cgi-bin public.kitware.com><BR>Follow this link to subscribe/unsubscribe:<BR>http://www.vtk.org/mailman/listinfo/vtkusers</BLOCKQUOTE><p>
                <hr size=1><font face=arial size=-1>Do you Yahoo!?<br><a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/hotjobs/hotjobs_mail_signature_footer_textlink/evt=23983/*http://hotjobs.sweepstakes.yahoo.com/careermakeover">Win a $20,000 Career Makeover at Yahoo! HotJobs </a>