<div dir="ltr"><p style="margin-left: 3pt;"><i><span lang="EN-GB"> Thank you very much Amy. The program compiles without any errors!</span></i></p><p style="margin-left: 3pt;"><i><span lang="EN-GB"> However , I still have a problem : The OpenGl lines doesn't display on the screen.</span></i></p>
<p style="margin-left: 3pt;"><i><span lang="EN-GB"> I check In Debug Mode, the </span></i><font size="2"><span lang="EN-GB">RenderOpaqueGeometry function is executed permanently ( following the pipeline). <br></span></font></p>
<p style="margin-left: 3pt;"><i><span lang="EN-GB"> <br></span></i></p><p style="margin-left: 3pt;"><i><span lang="EN-GB"><br></span></i></p><p style="margin-left: 3pt;"><i><span lang="EN-GB">----- In the main propram----------<br>
</span></i></p><p style="margin-left: 3pt;"><span lang="EN-GB"> .............<br></span></p><p style="margin-left: 3pt;"><span lang="EN-GB"> vtkRenderer<span> </span>*renderer = vtkRenderer<span> </span>::New();</span></p>
<p><span lang="EN-GB"> vtkMyDerivedProp->
RenderOpaqueGeometry(renderer);</span></p>
<p><span lang="EN-GB"> renderer->AddProp(vtkMyDerivedProp);</span></p><p><span lang="EN-GB"> ...........<br></span></p><p><span lang="EN-GB">---- In Myderived class----------------<br></span></p><p><font size="2"><span lang="EN-GB">virtual int
RenderOpaqueGeometry(vtkViewPort* )</span><br><br></font>{ <br></p><div><pre><font size="2"><span lang="EN-GB"><span style="font-family: arial,helvetica,sans-serif;"> glBegin (GL_LINES);</span><div style="font-family: arial,helvetica,sans-serif;" class="Ih2E3d">
<span> </span><span> </span>glVertex2f (-2.5, 2.5);<br><span> </span><span> </span>glVertex2f (2.5, -2.5);<br><span> </span><span> </span>glEnd ();</div></span><span style="font-family: Arial;" lang="EN-GB"></span></font><font size="2"><span lang="EN-GB">}</span></font></pre>
</div><br>Any suggestions ? Did I miss something ?<br><br>Thank you in advance,<br>Amine<br><br><br><div class="gmail_quote">2008/8/19 Amy Squillacote <span dir="ltr"><<a href="mailto:ahs@cfdrc.com">ahs@cfdrc.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Amine,<br>
<br>
You cannot use VTK_RENDERING_EXPORT since you are not adding your class to the vtkRendering library. You'll need to create your own export macro. There is an example of setting up your own additional library for VTK in the VTK/Examples/Build/vtkLocal directory of the VTK source tree.<br>
<br>
- Amy<br>
<br>
Mohammed Amine SAHTARI wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
<br>
I use vtkStandardNewMacro to add New macro. The problem is that I got 5 link errors even if I include the librairies of VTK (In VS 8).<br>
<br>
Hereby, you find my derived class (.h & .cxx).<br>
<br>
---------------- vtkMyDerivedProp.h -------------------------<br>
<br>
#ifndef __vtkMyDerivedProp_h<br>
#define __vtkMyDerivedProp_h<br>
#include "vtkProp.h"<br>
<br>
class VTK_RENDERING_EXPORT vtkMyDerivedProp : public vtkProp<br>
{<br>
public:<br>
<br>
vtkTypeRevisionMacro(vtkMyDerivedProp,vtkProp);<br>
void PrintSelf(ostream& os, vtkIndent indent);<br>
static vtkMyDerivedProp* New();<br>
<br>
protected:<br>
<br>
vtkMyDerivedProp();<br>
~vtkMyDerivedProp();<br>
<br>
private:<br>
<br>
vtkMyDerivedProp(const vtkMyDerivedProp&); // Not implemented. void operator=(const vtkMyDerivedProp&); // Not implemented.<br>
<br>
};<br>
<br>
#endif<br>
<br>
---------------- vtkMyDerivedProp.cxx -------------------------<br>
<br>
#include "vtkMyDerivedProp.h"<br>
<br>
#include "vtkObjectFactory.h"<br>
<br>
vtkCxxRevisionMacro(vtkMyDerivedProp, "$Revision: 1.36 $");<br>
<br>
vtkStandardNewMacro(vtkMyDerivedProp);<br>
<br>
vtkMyDerivedProp::vtkMyDerivedProp(){}<br>
<br>
vtkMyDerivedProp::~vtkMyDerivedProp(){}<br>
<br>
void vtkMyDerivedProp::PrintSelf(ostream& os, vtkIndent indent)<br>
{<br>
this->Superclass::PrintSelf(os,indent);<br>
}<br>
<br>
-------------------------------------- Errors ------------------------------------------<br>
<br>
*I got 5 errors *<br>
<br>
1>vtkMyDerivedProp.obj : error LNK2001: unresolved external symbol "private: virtual char const * __thiscall vtkMyDerivedProp::GetClassNameInternal(void)const " (?GetClassNameInternal@vtkMyDerivedProp@@EBEPBDXZ)<br>
<br>
1>vtkMyDerivedProp.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall vtkMyDerivedProp::IsA(char const *)" (?IsA@vtkMyDerivedProp@@UAEHPBD@Z)<br>
<br>
1>vtkMyDerivedProp.obj : error LNK2001: unresolved external symbol "protected: virtual class vtkObjectBase * __thiscall vtkMyDerivedProp::NewInstanceInternal(void)const " (?NewInstanceInternal@vtkMyDerivedProp@@MBEPAVvtkObjectBase@@XZ)<br>
<br>
1>vtkMyDerivedProp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const vtkMyDerivedProp::`vftable'" (__imp_??_7vtkMyDerivedProp@@6B@) referenced in function "protected: __thiscall vtkMyDerivedProp::vtkMyDerivedProp(void)" (??0vtkMyDerivedProp@@IAE@XZ)<br>
<br>
1>C:\Documents and Settings\asahtari\Mes documents\Projet\Bibillothéques\VTK\MyTest\MyLib.dll : fatal error LNK1120: 4 unresolved externals<br>
<br>
When I put vtkMyDerivedProp instead of vtkProp3D, it compiles without any error.<br>
I don't understand .Is it a matter of VTK librairies ? Please Help!<br>
<br>
Amine<br>
<br></div></div><div><div></div><div class="Wj3C7c">
2008/8/14 Utkarsh Ayachit <<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a> <mailto:<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>>><br>
<br>
Please keep the questions to the mailing list, so that others can<br>
benefit/contribute as well.<br>
<br>
To add New():<br>
* take a look at any concrete class in VTK eg. vtkCollection (the<br>
New is<br>
declared in the header and defined using<br>
vtkStandardNewMacro(vtkCollection); in the cxx.<br>
<br>
* not using the viewport in the RenderOpaqueGeometry should not be a<br>
problem. It's only provided if needed.<br>
<br>
Utkarsh<br>
<br>
<br>
<br>
<br>
Mohammed Amine SAHTARI wrote:<br>
<br>
Thank you very much Utkarsh.<br>
<br>
I am tring to implement your solution but I have some problems.<br>
<br>
1) I create vtkMyDerivedProp.h and vtkMyDerivedProp.cxx<br>
<br>
I subclass vtkProp :<br>
- I copy the class code of vtkProp3D (.h and .c files)<br>
- I replace all the words :<br>
vtkProp3D /by/ /vtkMyDerivedProp /and Prop3D by<br>
/MyDerivedProp/<br>
- I include /"vtkGl.h"/ in vtkMyDerivedProp.h<br>
- I add RenderOpaqueGeometry() in vtkMyDerivedProp.h<br>
like this :<br>
/virtual int RenderOpaqueGeometry(vtkViewPort* )<br>
{/<br>
<br>
/ glBegin (GL_LINES);<br>
<br>
glVertex2f (-2.5, 2.5);<br>
<br>
glVertex2f (2.5, -2.5);<br>
<br>
<br>
glEnd ();/<br>
<br>
/ }/<br>
<br>
2) In my program : - I include and instantiate vtkMyDerivedProp :<br>
<br>
/ //# include "vtkMyDerivedProp.h"<br>
vtkMyDerivedProp *MyDerivedProp;/<br>
<br>
- I use vtkMyDerivedProp :<br>
<br>
/ vtkRenderer *renderer = vtkRenderer ::New();/<br>
<br>
/ vtkMyDerivedProp-> RenderOpaqueGeometry(renderer);/<br>
<br>
/ renderer->AddProp(vtkMyDerivedProp);/<br>
<br>
<br>
*Problem *: vtkMyDerivedProp is used without been defined!<br>
<br>
*Question 1 :* How can I define it ? (vtkMyDerivedProp::New() doesn't work)<br>
<br>
*Question 2 :* RenderOpaqueGeometry has vtkViewPort* in input<br>
but doesn't use it. Is it a problem ?<br>
<br>
How can I fix this?<br>
<br>
Looking forward to hear from you soon,<br>
<br>
Amine**<br>
<br>
<br>
<br>
<br>
<br>
2008/8/14 Utkarsh Ayachit <<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a><br>
<mailto:<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>><br>
<mailto:<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a><br>
<mailto:<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>>>><br>
<br>
iren->Start() results in repeated calls to renWin->Render() on<br>
interaction. This will clear whatever you had drawn. A better<br>
approach is to subclass vtkProp(or one of it's subclasses)<br>
and put<br>
your rendering code in RenderOpaqueGeometry() /<br>
RenderTranslucentPolygonalGeometry()/ RenderOverlay() etc.<br>
depending<br>
upon what pass you want it to be rendered and then add the<br>
prop to<br>
the renderer. That way every time the renderer re-renders,<br>
your code<br>
will be executed.<br>
<br>
<br>
Utkarsh<br>
<br>
Mohammed Amine SAHTARI wrote:<br>
<br>
<br>
I want to add an OpenGl code in an application of VTK.<br>
<br>
For this purpose, I try to draw lines using commands<br>
OpenGL.:<br>
<br>
*1) I add this on the top of the program :*<br>
<br>
#include <GL/gl.h><br>
*2) I place my OpenGL commands after renWin->Render()<br>
but before<br>
iren->Start()** : *<br>
<br>
<br>
renWin->Render();<br>
<br>
glBegin (GL_LINES);<br>
glVertex2f (-2.5, 2.5);<br>
glVertex2f (2.5, -2.5);<br>
glEnd ();<br>
<br>
iren->Start();<br>
<br>
<br>
*But it doesn't appears.*<br>
<br>
did I miss something ? How can I do this work ?<br>
Looking forward to hear from you soon,<br>
<br>
Amine<br>
<br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at:<br>
<a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br>
<br>
<br>
_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at:<br>
<a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br>
</div></div></blockquote><font color="#888888">
<br>
-- <br>
Amy Squillacote Phone: (256) 726-4839<br>
Computer Scientist Fax: (256) 726-4806<br>
CFD Research Corporation Web: <a href="http://www.cfdrc.com" target="_blank">http://www.cfdrc.com</a><br>
215 Wynn Drive, Suite 501<br>
Huntsville, AL 35805<br>
<br>
<br>
</font></blockquote></div><br></div>