[vtk-developers] [ARB?] Plans for the vtkGL2PSExporter class.

Goodwin Lawlor goodwin.lawlor at ucd.ie
Mon Jun 2 16:07:13 EDT 2003


Hi,
Sorry I'm joining this thread late... its was a public holiday in this neck
of the woods. I've a similar class going and have recently upgraded it to
have all the whistles and bells that I need.

Like Prabhu's vtkGL2PSExporter it wraps the gl2ps0.8 library. I've also
subclassed it from vtkExporter but have stuck it in Hybrid (I reckon its an
exporter/writer hybrid and I think the VTK compilation goes more smoothly if
its in there). Its called vtkEPSWriter though...

As Prabhu said earlier text doesn't make it into the opengl feedback
buffer... neither does point size and line width. gl2ps does have methods to
get round these problems though. It means that each actor in a renderer must
be rendered separately into the feedback buffer setting its point size and
line width appropriately.

When you render a vtkTextActor separately into the feedback buffer the text
doesn't make it there but the correct raster position is set. So, you get
the input text, its properties, and use gl2psText... great BUT subclasses of
vtkActor2D encapsulate arrays of vtkActor2D's which vtkEPSWriter has to be
able to get at.

The way around this was if the subclasses of vtkActor2D grant friendship to
vtkEPSWriter, so in the class definition you add:
//BTX
friend class vtkEPSWriter;
//ETX

That's the only change to the VTK source that has to be made (to the
subclasses of vtkActor2D, vtkTextMapper and vtkLabeledDataMapper)

I could ramble on here for ages so I'll post the code, examples etc. to a
web site and send around the link. I have modified vtkOpenGLProperty and
vtkOpenGLPolyDataMapper classes that allow backface culling in wireframe and
points representations.

Here are the facilities of vtkEPSWriter at the moment:
-All text from vtkActor2D subclasses and vtkLabeledDataMapper
-Multiline text (that's why vtkTextMapper has to grant friendship)
-All actors have the own point size and line width
-Mixed raster/vector format where the 3D props are written as a raster image
and 2D props are written as vector images
-Turn on/off PS Level 3 shading of triangles... to enable translation of EPS
to PDF
-Change the sorting algorithms from BSP to simple to off.
-Occlusion culling of actors completely occluded by other actors

Just two caveats:
-4bits per channel is hard coded into the gl2ps raster output... changing
"nbits=4" to "nbits=8" in gl2ps.c improves this.
-vtkSelectVisiblePoints plays havoc with vtkEPSWriter.

That's about it. I'll send around the link later this evening

Goodwin

----- Original Message -----
From: "Prabhu Ramachandran" <prabhu at aero.iitm.ernet.in>
To: "Sebastien BARRE" <sebastien.barre at kitware.com>;
<vtk-developers at public.kitware.com>; "Goodwin Lawlor"
<goodwin.lawlor at ucd.ie>
Sent: Monday, June 02, 2003 6:05 PM
Subject: Re: [vtk-developers] [ARB?] Plans for the vtkGL2PSExporter class.


> Hi,
>
> For some strange reason this mail (which I am replying to) never
> reached me although its there in the archives!
>
> >>>>> "PR" == Prabhu Ramachandran <prabhu at aero.iitm.ernet.in> writes:
>
> [snip]
>
>     PR> When this is turned on gl2psText function calls are made
>     PR> (inside the text mappers) when the mapper is rendering its
>     PR> text.  As soon as gl2ps is finished one can turn it off:
>
>     PR>  vtkTextMapper::GlobalGL2PSOff();
>
>     PR> Or something like that.  Alternatively, I would need to find
>     PR> all active actors in the renderwindow, check if they are text
>     PR> actors, then call gl2psText appropriately.  I am not sure
>     PR> which is the best approach.  I thought that the Global flag
>     PR> was simpler to do.  Finding all active actors and searching
>     PR> for text actors is a possiblility but the code could be more
>     PR> complicated. OTOH if everyone starts using global flags things
>     PR> can get messy.
>
> I thought more about this and poked around with more code and I'm
> beginning to think that it makes more sense to do this in the
> vtkOpenGLFreeTypeTextMapper.  This is because some of the classes that
> use text do not add these actors to the renderwindow and use them
> directly in their Render* methods.  The vtkScalarBarActor and the
> vtkCubeAxesActor2D are good examples.  So finding all renderered
> actors and then calling gl2psText appropriately will not work.
> However adding a few lines to the TextMapper code will do the job just
> fine.  I also will not need a global flag or anything of the sort
> since gl2psText will test to see if gl2ps is initialized.  If it is
> not then it does nothing.  So I think I'll just go ahead with this
> approach and test it out.  If you have any better suggestions please
> do let me know.
>
> Thanks.
> prabhu
>




More information about the vtk-developers mailing list