[gl2ps] Problem with BSP printing (reason found)
Christophe Geuzaine
christophe.geuzaine at case.edu
Tue Feb 14 20:16:15 CET 2006
Shahzad MUZAFFAR wrote:
> yes this should be the precision loss. I have tried to change minZ,
> maxZ, rangeZ, scaleZ to double but still results are not correct. cheers,
Sounds good. I have added the two "fixes" in the code. Could you give
this version a try
http://www.geuz.org/gl2ps/src/gl2ps-nightly.tgz
and let me know if it works OK on all your test cases? If it does, I
will release gl2ps 1.2.7 with the corrections.
Thanks again!
Christophe
> --Shahzad
>
> Christophe Geuzaine wrote:
>
>> Shahzad MUZAFFAR wrote:
>>
>>> I have test the fix you have provided and that works but not for
>>> scene graphs which are very far from the camera. I have put the
>>> generated eps file here
>>>
>>> 1) The actual scene.
>>> http://cmsdoc.cern.ch/~muzaffar/gl2ps/actual.eps
>>>
>>> 2) With fix you have provided
>>> http://cmsdoc.cern.ch/~muzaffar/gl2ps/with_fix_from_C.Geuzaine.eps
>>> If you zoom in a lot (zoom 64x64) using the ghostview then you will
>>> noticed that some triangles should not be seen.
>>>
>>> - With fix you have provided + limiting the scaleZ to be max of 100000
>>>
>>> http://cmsdoc.cern.ch/~muzaffar/gl2ps/with_fix_from_C.Geuzaine_AndscaleZ100000.eps
>>>
>>> And here if you zoom in then scene looks the actual one.
>>
>> I see. I'm not sure I fully understand, though: do you think it's
>> simply due to the precision loss from using floats (instead of double
>> precision)?
>>
>>
>>> Cheers,
>>> --Shahzad
>>>
>>> Christophe Geuzaine wrote:
>>>
>>>> Shahzad MUZAFFAR wrote:
>>>>
>>>>> Hello,
>>>>> I have already mentioned (in one of my previous email) about the
>>>>> problem with BSP printing not working properly in 1.2.3 and up
>>>>> releases (i.e. printing in reverse order). I think I have found the
>>>>> reason. The problem is in the gl2psRescaleAndOffset() method. The
>>>>> problem occurs when the scaleZ becomes > 100000. Because at scaleZ
>>>>>> 100000 the z-coordinates of all primitive become > 100000 which
>>>>> is above the EYE set in the gl2psPrintPrimitives() method. Thats
>>>>> why we see eps/pdf files printed in reverse order.
>>>>>
>>>>> I have added this line in gl2psRescaleAndOffset() method
>>>>>
>>>>> if (scaleZ > 100000.F) scaleZ=100000;
>>>>>
>>>>> to force the Z scaling. And now printing works properly. Cheers,
>>>>
>>>> I see... The root of the problem is that I forgot to subtract the
>>>> minZ coordinate in the rescaling! I think the "real" fix should thus
>>>> be to replace
>>>>
>>>> prim->verts[j].xyz[2] = prim->verts[j].xyz[2] * scaleZ;
>>>>
>>>> with
>>>>
>>>> prim->verts[j].xyz[2] = (prim->verts[j].xyz[2] - minZ) * scaleZ;
>>>>
>>>> This way the z-buffer coordinate will be in [0, GL2PS_ZSCALE]
>>>> (that's what was intended). Could you try this alternative fix and
>>>> tell me if it also fixes the bug?
>>>>
>>>> Many thanks!
>>>>
>>>> Christophe
>>>>
>>>>
>>>>> --Shahzad Muzaffar
>>>>> _______________________________________________
>>>>> gl2ps mailing list
>>>>> gl2ps at geuz.org
>>>>> http://www.geuz.org/mailman/listinfo/gl2ps
>>>>>
>>> _______________________________________________
>>> gl2ps mailing list
>>> gl2ps at geuz.org
>>> http://www.geuz.org/mailman/listinfo/gl2ps
>>>
>>
> _______________________________________________
> gl2ps mailing list
> gl2ps at geuz.org
> http://www.geuz.org/mailman/listinfo/gl2ps
>
--
Christophe Geuzaine
Assistant Professor, Case Western Reserve University, Mathematics
http://www.case.edu/artsci/math/geuzaine