POV-Ray : Newsgroups : povray.binaries.utilities : postscript/pdf to POVRay prism Server Time
31 Oct 2024 12:16:56 EDT (-0400)
  postscript/pdf to POVRay prism (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Ross Martin
Subject: postscript/pdf to POVRay prism
Date: 7 Mar 2003 15:53:21
Message: <3e6906c1@news.povray.org>
Hi Everyone,

I wrote the attached utility to convert vector-type (not bitmapped)
postscript/pdf files into POVRay prisms.  It works under Linux.
The first step is to "flatten" the postscript to a standard form
using the pstoedit package (available separately).  Then you run my
perl script to convert the "flattened" postscript into Prism statements.

A demonstration is included to show each step.  It converts some
postscript demo files and a latex document into prisms and renders
them.  The demo image is attached.

There are two options for textures -- either the original postscript
colors can be applied, or the prisms can be left untextured so that
a uniform texture can be applied later.

Since most two-dimensional things can be converted to postscript
by printing to a file, this utility should make it possible to convert
most 2-dimensional objects into POVRay prisms.

This package works for the few examples I tried. It may still need
improvement to deal with more complicated files.

I hope you find it useful!

Ross


Post a reply to this message


Attachments:
Download 'eps2pov.tgz.gz' (126 KB) Download 'main.jpg' (27 KB)

Preview of image 'main.jpg'
main.jpg


 

From: Tek
Subject: Re: postscript/pdf to POVRay prism
Date: 9 Mar 2003 10:30:48
Message: <3e6b5e28@news.povray.org>
Ross Martin <jun### [at] rossinterwrxcom> wrote in message
news:3e6906c1@news.povray.org...
>
> Hi Everyone,
>
> I wrote the attached utility to convert vector-type (not bitmapped)
> postscript/pdf files into POVRay prisms.  It works under Linux.

That looks really cool! Any chance of a Windows version for us non-linux users?
:)

--
Tek
http://www.evilsuperbrain.com


Post a reply to this message

From: Ross Martin
Subject: Re: postscript/pdf to POVRay prism
Date: 9 Mar 2003 22:37:02
Message: <3E6C085B.7070202@ross.interwrx.com>
Hi Tek,

You might be able to make it work under Windows.  The part I wrote is
just a Perl script, and I'd imagine something can be found to run
Perl scripts under Windows.  I believe there is a ghostscript version
that runs under Windows, and ghostscript is the power behind pstoedit,
so perhaps pstoedit can be made to work also.

You would have to do some work to put it all together, but I imagine
it's possible.  I have no need for such a thing, so I won't be working
on it personally.

Ross


Tek wrote:
> Ross Martin <jun### [at] rossinterwrxcom> wrote in message
> news:3e6906c1@news.povray.org...
> 
>>Hi Everyone,
>>
>>I wrote the attached utility to convert vector-type (not bitmapped)
>>postscript/pdf files into POVRay prisms.  It works under Linux.
> 
> 
> That looks really cool! Any chance of a Windows version for us non-linux users?
> :)
> 
> --
> Tek
> http://www.evilsuperbrain.com
> 
> 
> 
> 
>


Post a reply to this message

From: Will W
Subject: Re: postscript/pdf to POVRay prism
Date: 10 Mar 2003 09:51:20
Message: <3e6ca668@news.povray.org>
"Tek" <tek### [at] evilsuperbraincom> wrote in message
news:3e6b5e28@news.povray.org...
> Ross Martin <jun### [at] rossinterwrxcom> wrote in message
> news:3e6906c1@news.povray.org...
> >
> > Hi Everyone,
> >
> > I wrote the attached utility to convert vector-type (not bitmapped)
> > postscript/pdf files into POVRay prisms.  It works under Linux.
>
> That looks really cool! Any chance of a Windows version for us non-linux
users?
> :)

http://www.activestate.com/Products/ActivePerl/ ActiveState provides Perl
for Windows free (as in beer) (and in freedom, sort of). Install it, and
you'll be able to run more than 90% of the perl scripts out there without
modification. You'd also be able to write cross-platform code, too.


--
Will Woodhull
Thornhenge, SW Oregon, USA
willl.at.thornhenge.net


Post a reply to this message

From: Tek
Subject: Re: postscript/pdf to POVRay prism
Date: 10 Mar 2003 19:51:02
Message: <3e6d32f6@news.povray.org>
Cool, it sounds like I can probably make it work...
Now all I need is to think of something to use it on! :)

Thanks
--
Tek
http://www.evilsuperbrain.com


Ross Martin <jun### [at] rossinterwrxcom> wrote in message
news:3E6### [at] rossinterwrxcom...
>
> Hi Tek,
>
> You might be able to make it work under Windows.  The part I wrote is
> just a Perl script, and I'd imagine something can be found to run
> Perl scripts under Windows.  I believe there is a ghostscript version
> that runs under Windows, and ghostscript is the power behind pstoedit,
> so perhaps pstoedit can be made to work also.
>
> You would have to do some work to put it all together, but I imagine
> it's possible.  I have no need for such a thing, so I won't be working
> on it personally.
>
> Ross
>
>
> Tek wrote:
> > Ross Martin <jun### [at] rossinterwrxcom> wrote in message
> > news:3e6906c1@news.povray.org...
> >
> >>Hi Everyone,
> >>
> >>I wrote the attached utility to convert vector-type (not bitmapped)
> >>postscript/pdf files into POVRay prisms.  It works under Linux.
> >
> >
> > That looks really cool! Any chance of a Windows version for us non-linux
users?
> > :)
> >
> > --
> > Tek
> > http://www.evilsuperbrain.com
> >
> >
> >
> >
> >
>


Post a reply to this message

From: Mark Weyer
Subject: Re: postscript/pdf to POVRay prism
Date: 18 Mar 2003 05:32:14
Message: <3E76F8D6.9010702@informatik.uni-freiburg.de>
> I wrote the attached utility to convert vector-type (not bitmapped)
> postscript/pdf files into POVRay prisms.  It works under Linux.
> The first step is to "flatten" the postscript to a standard form
> using the pstoedit package (available separately).  Then you run my
> perl script to convert the "flattened" postscript into Prism statements.
 > [...]
> I hope you find it useful!

I deem it very useful. So far I used bitmaps for importing LaTeX into
povray. I would gladly convert to eps2pov, but there are problems:
  - I would need polygons instead of prisms.
  - I put an outline around the text using intermediate processing of
    bitmaps. Is it possible to amend your script with an option to
    follow the vector image with some distance?
Unfortunately I know neither perl nor the flattened postscript.


-- 
merge{#local i=-11;#while(i<11)#local
i=i+.1;sphere{<i*(i*i*(.05-i*i*(4e-7*i*i+3e-4))-3)10*sin(i)30>.5}#end
pigment{rgbt 1}interior{media{emission x}}hollow}//  Mark Weyer


Post a reply to this message

From: Ross Martin
Subject: Re: postscript/pdf to POVRay prism
Date: 19 Mar 2003 00:17:36
Message: <3E77FD38.5060104@ross.interwrx.com>
Hmmm.  I'm not sure I understand, but I'll answer what I think
you're asking.  One of the main reasons I made this code was
to allow LaTeX-generated text in POVRay.

First, a "prism" is a generalization of a polygon that allows
curves (not just straight sides) and is extruded into the third
dimension.  So I think this is what you want when you say you want
a "polygon".

Second, I'm not sure what you mean by an "outline".  You mean you
add something surrounding the text?  If it is just straight lines, you
could create it in LaTeX using the \hrule and \vrule or other commands,
and then this should appear in the PDF produced by pdflatex, and it
should then appear in the final POV file.  If it is a more complicated
"outline", you could perhaps create it in xfig, do your latex text in
xfig, export in pstex and pstex_t format, and then process through
pdflatex to achieve the desired result.  You could also get the same
effect by writing just your text in pdflatex and then adding a
"outline" directly in the povray source after the conversion.

If by "outline" you mean that you do something that looks like a
modification of the font, how you would do that would depend entirely on
the modification.  I think "outline fonts" is a name for fonts with a 3D
effect.  Of course, with POVRay you actually have 3D, so simulated 3D
using outlining would seem to be a bit strange when you have much
better real 3D available.

The code I made only converts objects that are actually drawn in the
postscript.  There is no way to add hints for how the object dimensions
should affect placement of other objects.  Perhaps something like this
could be added and might be a good idea.  Perhaps not.  I'd have to
think about it.  Don't expect anything soon.

I hope I've answered some of your questions, but if not please ask again
with more detail and perhaps an example.

Ross


Mark Weyer wrote:
>> I wrote the attached utility to convert vector-type (not bitmapped)
>> postscript/pdf files into POVRay prisms.  It works under Linux.
>> The first step is to "flatten" the postscript to a standard form
>> using the pstoedit package (available separately).  Then you run my
>> perl script to convert the "flattened" postscript into Prism statements.
> 
>  > [...]
> 
>> I hope you find it useful!
> 
> 
> I deem it very useful. So far I used bitmaps for importing LaTeX into
> povray. I would gladly convert to eps2pov, but there are problems:
>  - I would need polygons instead of prisms.
>  - I put an outline around the text using intermediate processing of
>    bitmaps. Is it possible to amend your script with an option to
>    follow the vector image with some distance?
> Unfortunately I know neither perl nor the flattened postscript.
> 
>


Post a reply to this message

From: Mark Weyer
Subject: Re: postscript/pdf to POVRay prism
Date: 19 Mar 2003 06:02:09
Message: <3E78515A.2000907@informatik.uni-freiburg.de>
> First, a "prism" is a generalization of a polygon that allows
> curves (not just straight sides) and is extruded into the third
> dimension.  So I think this is what you want when you say you want
> a "polygon".

My mistake. I assumed polygons could have the same spline types as prisms.
Now I would approximate polygons by thin prisms.

> Second, I'm not sure what you mean by an "outline".

I will shortly post an example in p.b.i

 > You mean you
> add something surrounding the text?  If it is just straight lines,

Yes. No. I want it to follow the line type of the text. If the text
uses a straight line, the outline should also. If the text uses a
curve, the outline should also. It should be the same prism with
everything moved "outwards" by some constant.

> The code I made only converts objects that are actually drawn in the
> postscript.  There is no way to add hints for how the object dimensions
> should affect placement of other objects.  Perhaps something like this
> could be added and might be a good idea.  Perhaps not.  I'd have to
> think about it.  Don't expect anything soon.

Assumption: It is determinable whether the polygon points are aranged
clockwise or counter-clockwise.

Now if we know the former, i.e. the polygon is always to our right hand
side as we walk around it, I would suggest the following:
For every polygon point determine the directions of the two curves that
meet there. Calculate the intermediate direction (choose the one to the
left). Displace the polygon point by the outline distance in that
direction.

How can we establish the assumption? Let us first consider the case
that all shapes are simply connected (have no holes). Then take two
neighboured polygon points, and move from one halfway to the other
and then just a tiny bit to the right. From that point calculate the
polygon's winding number. If it is zero, then you are outside of the
polygon, so it runs counterclockwise.
Now for not simply connected shapes. What I could read from your code
suggests that those are presented as a difference of a simply connected
one and a union of simply connected one. Then it is easy again.

Have you looked at the ps2edit source code?


-- 
merge{#local i=-11;#while(i<11)#local
i=i+.1;sphere{<i*(i*i*(.05-i*i*(4e-7*i*i+3e-4))-3)10*sin(i)30>.5}#end
pigment{rgbt 1}interior{media{emission x}}hollow}//  Mark Weyer


Post a reply to this message

From: Ross Martin
Subject: Re: postscript/pdf to POVRay prism
Date: 19 Mar 2003 17:19:43
Message: <3E78ECC8.3040704@ross.interwrx.com>
I see what you're trying to do now.  You have stuff behind the text,
so you want a non-transparent black area surrounding the text to make
the text more visible by blocking view of this other stuff.

It could certainly be done in some way similar to that you describe.
I did something a little similar in order to get stroked paths with
finite widths to work in my conversion.  These must be converted into
prisms, so I have to move the points on the line in either direction
to give the desired width and make a prism out of the result.  I don't
need this, but you are certainly welcome to modify the code to do it.

It could also be done (less efficiently) by taking the text, moving it
back slightly, making it black, and then taking the CSG union of it
being moved slightly in different directions.  If you take enough
different directions, it would have the effect of enlarging the text
into a background for the text as you describe.

Ross


Mark Weyer wrote:
>> First, a "prism" is a generalization of a polygon that allows
>> curves (not just straight sides) and is extruded into the third
>> dimension.  So I think this is what you want when you say you want
>> a "polygon".
> 
> 
> My mistake. I assumed polygons could have the same spline types as prisms.
> Now I would approximate polygons by thin prisms.
> 
>> Second, I'm not sure what you mean by an "outline".
> 
> 
> I will shortly post an example in p.b.i
> 
>  > You mean you
> 
>> add something surrounding the text?  If it is just straight lines,
> 
> 
> Yes. No. I want it to follow the line type of the text. If the text
> uses a straight line, the outline should also. If the text uses a
> curve, the outline should also. It should be the same prism with
> everything moved "outwards" by some constant.
> 
>> The code I made only converts objects that are actually drawn in the
>> postscript.  There is no way to add hints for how the object dimensions
>> should affect placement of other objects.  Perhaps something like this
>> could be added and might be a good idea.  Perhaps not.  I'd have to
>> think about it.  Don't expect anything soon.
> 
> 
> Assumption: It is determinable whether the polygon points are aranged
> clockwise or counter-clockwise.
> 
> Now if we know the former, i.e. the polygon is always to our right hand
> side as we walk around it, I would suggest the following:
> For every polygon point determine the directions of the two curves that
> meet there. Calculate the intermediate direction (choose the one to the
> left). Displace the polygon point by the outline distance in that
> direction.
> 
> How can we establish the assumption? Let us first consider the case
> that all shapes are simply connected (have no holes). Then take two
> neighboured polygon points, and move from one halfway to the other
> and then just a tiny bit to the right. From that point calculate the
> polygon's winding number. If it is zero, then you are outside of the
> polygon, so it runs counterclockwise.
> Now for not simply connected shapes. What I could read from your code
> suggests that those are presented as a difference of a simply connected
> one and a union of simply connected one. Then it is easy again.
> 
> Have you looked at the ps2edit source code?
> 
>


Post a reply to this message

From: Mark Weyer
Subject: Re: postscript/pdf to POVRay prism
Date: 20 Mar 2003 03:48:44
Message: <3E798397.4060003@informatik.uni-freiburg.de>
> I don't
> need this, but you are certainly welcome to modify the code to do it.

Can you give me some hint as to which parts of your code I am likely
to want to change? How does it work anyway? What kind of data do you
get from pstoedit?

> It could also be done (less efficiently) by taking the text, moving it
> back slightly, making it black, and then taking the CSG union of it
> being moved slightly in different directions.  If you take enough
> different directions, it would have the effect of enlarging the text
> into a background for the text as you describe.

That's what I do now on a bitmap basis. Doing so with vector data
would lose the latter's benefit of infinite precision.


-- 
merge{#local i=-11;#while(i<11)#local
i=i+.1;sphere{<i*(i*i*(.05-i*i*(4e-7*i*i+3e-4))-3)10*sin(i)30>.5}#end
pigment{rgbt 1}interior{media{emission x}}hollow}//  Mark Weyer


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.