Archived issue #0022337
V3d_View::Print crashes in OCCT 6.5.0
Description
Additional information
Documentation remark, added by apl 2011-05-26 17:43:39:
Improvements:
The printing operation under Windows has been completely redesigned.
Now it uses the off-screen buffer (frame buffer object) for rendering that makes
the result independent from the current 3D view dimensions.
The new option has been added to the print method. It is possible now to
choose between two print algorithms that define how the 3D scene is mapped to
the print area when the maximum dimensions of the frame buffer are smaller than
the dimensions of the print area.
One option is to use the newly implemented TileSplit algorithm.
This algorithm allows you to cover the whole printing area by rendering
multiple parts of the viewer. Theoretically, this means that any printing
resolution could be achieved without stretching, to avoid image quality loss.
This algorithm prints parts of the 3D scene in maximum possible resolution into
an off-screen buffer, and when copies them to the printing area, covering it by
a sort of tiling.
Another option is to draw the 3D scene using maximum supported frame buffer size
and then stretch the image to the whole printing area.
The stretching functionality provided by FreeImage is applied with the bicubic
interpolation.
If print method was used in the code of your application, you might need to
revise it to take into account the ability to choose between print algorithms.
The stretching will be selected by default when porting your application.
The new printing approach has been tested with A4 paper size and resolution of
1200 dpi (180 lpi).
Changes:
There are following changes in packages:
OpenGl package:
1) The call_togl_print function has been modified, now it uses the off-screen
buffer for rendering the viewer’s content. Two print algorithms have been
implemented: stretch algorithm and the tile algorithm. Stretch algorithm prints
the viewer’s content into off-screen buffer and then stretches the result if its
size smaller than printing area. Tile algorithm covers the whole printing area
by rendering parts of the viewer in a maximum possible resolution. New parameter
has been added to call_togl_print: const int printmode.
This method now returns true/false to indicate if the print data has been successfully sent to the printer or not.
2) The new class OpenGl_PrinterContext has been implemented. This class provides
the specific printing information to the OpenGl redraw procedure. The instance
of this class can be created only in call_togl_print method and can be obtained
by the OpenGl_PrinterContext::GetPrinterContext() method. The printer context is
associated with the OpenGL rendering context for better robustness.
3) TelSetViewIndex, call_togl_redraw_layer2d, OpenGl_TextRender::RenderText
function (methods) have been modified to use printing information provided by
OpenGl_PrinterContext instance.
4) The new parameter has been added to OpenGl_GraphicDriver::Print method: const
Aspect_PrintAlgo printAlgorithm. This parameters allows to select print
algorithm. Additional parameter has been added: theScaleFactor - it is internally used to provide scaling information that is selected in print parameters dialog. This method now returns Standard_True/Standard_False to indicate is the print data has been successfully sent to the printer.
Aspect package:
1) The new enumeration has been added: Aspect_PrintAlgo. This enumeration
defines the print algorithms.
Graphic3d package:
1) The new parameter has been added to Graphic3d_GraphicDriver::Print method:
const Aspect_PrintAlgo printAlgorithm. This parameters allows to select print
algorithm. Additional parameter has been added: theScaleFactor - it is internally used to provide scaling information that is selected in print parameters dialog. This method now returns Standard_True/Standard_False to indicate is the print data has been successfully sent to the printer.
Visual3d package:
1) The new parameter has been added to Visual3d_View::Print method: const
Aspect_PrintAlgo printAlgorithm. This parameters allows to select print
algorithm. Additional parameter has been added: theScaleFactor - it is internally used to provide scaling information that is selected in print parameters dialog. This method now returns Standard_True/Standard_False to indicate is the print data has been successfully sent to the printer.
V3d package:
1) The new parameter has been added to V3d_View::Print method: const
Aspect_PrintAlgo printAlgorithm. This parameters allows to select print
algorithm. This method now returns Standard_True/Standard_False to indicate is the print data has been successfully sent to the printer.
ViewerTest package:
1) The new draw command has been added to test print algorithms:
vprintview width height filename [mode=0]
- Width and height parameters specify the dimensions of the image buffer that
is treated like a usual printing area.
- Filename is the output file for saving the results. Mode parameters specify
the print algorithm: 0 - stretch, 1 - tile.
Modified entities:
Aspect_PrintAlgo.hxx / Aspect.cdl – the new enumeration has been added.
Graphic3d_GraphicDriver.cdl – new parameters has been added to the Print method, method returns Standard_Boolean.
OpenGl_GraphicDriver.cdl – new parameters has been added to the Print method, method returns Standard_Boolean.
V3d_View.cdl – new parameters has been added to the Print method, method returns Standard_Boolean.
Visual3d_View.cdl – new parameters has been added to both Print methods.
Improvements:
The printing operation under Windows has been completely redesigned.
Now it uses the off-screen buffer (frame buffer object) for rendering that makes
the result independent from the current 3D view dimensions.
The new option has been added to the print method. It is possible now to
choose between two print algorithms that define how the 3D scene is mapped to
the print area when the maximum dimensions of the frame buffer are smaller than
the dimensions of the print area.
One option is to use the newly implemented TileSplit algorithm.
This algorithm allows you to cover the whole printing area by rendering
multiple parts of the viewer. Theoretically, this means that any printing
resolution could be achieved without stretching, to avoid image quality loss.
This algorithm prints parts of the 3D scene in maximum possible resolution into
an off-screen buffer, and when copies them to the printing area, covering it by
a sort of tiling.
Another option is to draw the 3D scene using maximum supported frame buffer size
and then stretch the image to the whole printing area.
The stretching functionality provided by FreeImage is applied with the bicubic
interpolation.
If print method was used in the code of your application, you might need to
revise it to take into account the ability to choose between print algorithms.
The stretching will be selected by default when porting your application.
The new printing approach has been tested with A4 paper size and resolution of
1200 dpi (180 lpi).
Changes:
There are following changes in packages:
OpenGl package:
1) The call_togl_print function has been modified, now it uses the off-screen
buffer for rendering the viewer’s content. Two print algorithms have been
implemented: stretch algorithm and the tile algorithm. Stretch algorithm prints
the viewer’s content into off-screen buffer and then stretches the result if its
size smaller than printing area. Tile algorithm covers the whole printing area
by rendering parts of the viewer in a maximum possible resolution. New parameter
has been added to call_togl_print: const int printmode.
This method now returns true/false to indicate if the print data has been successfully sent to the printer or not.
2) The new class OpenGl_PrinterContext has been implemented. This class provides
the specific printing information to the OpenGl redraw procedure. The instance
of this class can be created only in call_togl_print method and can be obtained
by the OpenGl_PrinterContext::GetPrinterContext() method. The printer context is
associated with the OpenGL rendering context for better robustness.
3) TelSetViewIndex, call_togl_redraw_layer2d, OpenGl_TextRender::RenderText
function (methods) have been modified to use printing information provided by
OpenGl_PrinterContext instance.
4) The new parameter has been added to OpenGl_GraphicDriver::Print method: const
Aspect_PrintAlgo printAlgorithm. This parameters allows to select print
algorithm. Additional parameter has been added: theScaleFactor - it is internally used to provide scaling information that is selected in print parameters dialog. This method now returns Standard_True/Standard_False to indicate is the print data has been successfully sent to the printer.
Aspect package:
1) The new enumeration has been added: Aspect_PrintAlgo. This enumeration
defines the print algorithms.
Graphic3d package:
1) The new parameter has been added to Graphic3d_GraphicDriver::Print method:
const Aspect_PrintAlgo printAlgorithm. This parameters allows to select print
algorithm. Additional parameter has been added: theScaleFactor - it is internally used to provide scaling information that is selected in print parameters dialog. This method now returns Standard_True/Standard_False to indicate is the print data has been successfully sent to the printer.
Visual3d package:
1) The new parameter has been added to Visual3d_View::Print method: const
Aspect_PrintAlgo printAlgorithm. This parameters allows to select print
algorithm. Additional parameter has been added: theScaleFactor - it is internally used to provide scaling information that is selected in print parameters dialog. This method now returns Standard_True/Standard_False to indicate is the print data has been successfully sent to the printer.
V3d package:
1) The new parameter has been added to V3d_View::Print method: const
Aspect_PrintAlgo printAlgorithm. This parameters allows to select print
algorithm. This method now returns Standard_True/Standard_False to indicate is the print data has been successfully sent to the printer.
ViewerTest package:
1) The new draw command has been added to test print algorithms:
vprintview width height filename [mode=0]
- Width and height parameters specify the dimensions of the image buffer that
is treated like a usual printing area.
- Filename is the output file for saving the results. Mode parameters specify
the print algorithm: 0 - stretch, 1 - tile.
Modified entities:
Aspect_PrintAlgo.hxx / Aspect.cdl – the new enumeration has been added.
Graphic3d_GraphicDriver.cdl – new parameters has been added to the Print method, method returns Standard_Boolean.
OpenGl_GraphicDriver.cdl – new parameters has been added to the Print method, method returns Standard_Boolean.
V3d_View.cdl – new parameters has been added to the Print method, method returns Standard_Boolean.
Visual3d_View.cdl – new parameters has been added to both Print methods.
Public activity
11 archived notes
Participants are labeled by their role within this record.
Dear Anton,
Provide the test script for this bug.
--
[signature removed]
Mike
Provide the test script for this bug.
--
[signature removed]
Mike
Dear Mikhail,
You can use test script in attachement "Attachment 5 (GZ)"
You can use test script in attachement "Attachment 5 (GZ)"
Dear Commenter 1,
Please stop tests and integration of this solution.
The DRAW command "vprintview" should be verified and corrected to always return right status (or notification message) when the command fails. (case of lack of RAM memory)
Please stop tests and integration of this solution.
The DRAW command "vprintview" should be verified and corrected to always return right status (or notification message) when the command fails. (case of lack of RAM memory)
Dear Commenter 1,
SVN branch http://svn/svn/occt/branches/OCC22337 has been corrected
The DRAW command "vprintview" now always returns correct result, even if the data hasn't been sent to the printer (but prepared for this operation) due to insufficient memory for print operation.
SVN branch http://svn/svn/occt/branches/OCC22337 has been corrected
The DRAW command "vprintview" now always returns correct result, even if the data hasn't been sent to the printer (but prepared for this operation) due to insufficient memory for print operation.
Dear Sergey,
Could you please review the modifications to the branch:
SVN branch http://svn/svn/occt/branches/OCC22337 and write all your remarks
Could you please review the modifications to the branch:
SVN branch http://svn/svn/occt/branches/OCC22337 and write all your remarks
Dear Anton,
Please change the status to resolved.
Please change the status to resolved.
Hello Anton,
I have some minor remarks all of "Code style" or "Comment" type.
If you have some time to take them into account quickly (01.09.2011 morning), I would appreciate this.
Otherwise, please simply turn the issue status to "reviewed".
1. OpenGl_GraphicDriver.cdl, v3d_View.cdl
I recommend using standard OpenGL terminology when describing something based on OpenGL features. In particular, "frame buffer" mentioned several times in CDL files might be misleading. "Frame buffer object" or simply "FBO" looks clearer to me.
2. V3d_View.cdl
A similar issue: "Aspect_PA_STRETCH, Aspect_PA_TILE" would be more informative than "stretch, tile" in V3d_View.cdl - do not forget that we document API here, so we should tend to express everything in terms of API namespaces to facilitate work for application developers.
3. V3d_View.cdl - just a question: why not use more accurate Aspect_PA_TILE printing algo by default?
Well, probably I can answer myself...PA_STRETCH is more reliable and will work on any hardware...Is this worth mentioning in CDL documentation?
I would explain this in Aspect.cdl in PA_STRETCH documentation.
4. V3d_View_Print.cxx line 112:
Standard_Real aScaleFactor = (Standard_Real) aMode->dmScale / 100.0;
Usage of "100.0" magic number is not explained here.
5. V3d_View_Print.cxx lines 110 - 115: indentation settings differ from the rest of the file (spaces used instead of tabs), it would be nice to "untabify" the whole file using appropriate tab size to obtain nice-looking indentation as the result.
6. Aspect.cdl: documentation for PA_STRETCH enumeration item could have a reference to FreeImage library, otherwise it might not be clear why PA_STRETCH produces images of different quality when OCCT is built without FreeImage support. I suggest the following wording:
-- 1) PA_STRETCH - stretch offscreen printing frame
-- if its dimensions are smaller than
-- the printer's printing area dimensions.
-- Stretching is performed using bicubic
-- interpolation algorithm from
-- FreeImage library if OCCT is built
-- with FreeImage support, otherwise
-- Windows API StretchBlt() function in
-- STRETCH_HALFTONE mode is used.
7. OpenGL_TextRender.cxx lines 395 - 396:
aPrinterContext->GetScale( aTextScalex, aTextScaley );
glScalef( aTextScaley, aTextScaley, aTextScaley );
Why aTextScalex is not used here? Is it needed at all?
At least a comment could help...
8. OpenGl_togl_begin_layer_mode.cxx lines 303 - 322:
Adding a comment that explains how additional transformations are applied during printing would be helpful.
9. OpenGl_togl_print.cxx
initBufferStretch() - theViewRatio local variable should have "a" prefix instead of "the"
I have some minor remarks all of "Code style" or "Comment" type.
If you have some time to take them into account quickly (01.09.2011 morning), I would appreciate this.
Otherwise, please simply turn the issue status to "reviewed".
1. OpenGl_GraphicDriver.cdl, v3d_View.cdl
I recommend using standard OpenGL terminology when describing something based on OpenGL features. In particular, "frame buffer" mentioned several times in CDL files might be misleading. "Frame buffer object" or simply "FBO" looks clearer to me.
2. V3d_View.cdl
A similar issue: "Aspect_PA_STRETCH, Aspect_PA_TILE" would be more informative than "stretch, tile" in V3d_View.cdl - do not forget that we document API here, so we should tend to express everything in terms of API namespaces to facilitate work for application developers.
3. V3d_View.cdl - just a question: why not use more accurate Aspect_PA_TILE printing algo by default?
Well, probably I can answer myself...PA_STRETCH is more reliable and will work on any hardware...Is this worth mentioning in CDL documentation?
I would explain this in Aspect.cdl in PA_STRETCH documentation.
4. V3d_View_Print.cxx line 112:
Standard_Real aScaleFactor = (Standard_Real) aMode->dmScale / 100.0;
Usage of "100.0" magic number is not explained here.
5. V3d_View_Print.cxx lines 110 - 115: indentation settings differ from the rest of the file (spaces used instead of tabs), it would be nice to "untabify" the whole file using appropriate tab size to obtain nice-looking indentation as the result.
6. Aspect.cdl: documentation for PA_STRETCH enumeration item could have a reference to FreeImage library, otherwise it might not be clear why PA_STRETCH produces images of different quality when OCCT is built without FreeImage support. I suggest the following wording:
-- 1) PA_STRETCH - stretch offscreen printing frame
-- if its dimensions are smaller than
-- the printer's printing area dimensions.
-- Stretching is performed using bicubic
-- interpolation algorithm from
-- FreeImage library if OCCT is built
-- with FreeImage support, otherwise
-- Windows API StretchBlt() function in
-- STRETCH_HALFTONE mode is used.
7. OpenGL_TextRender.cxx lines 395 - 396:
aPrinterContext->GetScale( aTextScalex, aTextScaley );
glScalef( aTextScaley, aTextScaley, aTextScaley );
Why aTextScalex is not used here? Is it needed at all?
At least a comment could help...
8. OpenGl_togl_begin_layer_mode.cxx lines 303 - 322:
Adding a comment that explains how additional transformations are applied during printing would be helpful.
9. OpenGl_togl_print.cxx
initBufferStretch() - theViewRatio local variable should have "a" prefix instead of "the"
Dear Commenter 1,
All remarks from SAN has been corrected and branch has been updated
SVN branch http://svn/svn/occt/branches/OCC22337 is ready for testing
All remarks from SAN has been corrected and branch has been updated
SVN branch http://svn/svn/occt/branches/OCC22337 is ready for testing
Dear Commenter 1,
SVN branch ( http://svn/svn/occt/branches/OCC22337 ) was
testing, test results were compared with KAS:dev:products-20110810-opt
There are not regressions in SVN branch ( http://svn/svn/occt/branches/OCC22337 ) regarding to
KAS:dev:products-20110810-opt
See results in /QADisk/occttests/results/KAS/dev/ycy-products-2_01092011/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20110810-opt_11082011/lin
See test cases in /QADisk/occttests/tests/ED
N.B. In order to launch testing case you can make use the following instructions
http://doc/doku.php?id=occt:certification [^]
SVN branch ( http://svn/svn/occt/branches/OCC22337 ) was
testing, test results were compared with KAS:dev:products-20110810-opt
There are not regressions in SVN branch ( http://svn/svn/occt/branches/OCC22337 ) regarding to
KAS:dev:products-20110810-opt
See results in /QADisk/occttests/results/KAS/dev/ycy-products-2_01092011/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20110810-opt_11082011/lin
See test cases in /QADisk/occttests/tests/ED
N.B. In order to launch testing case you can make use the following instructions
http://doc/doku.php?id=occt:certification [^]
Integration into trunk of occt repository
Date: 2011-09-07 11:16:18 +0400 (Wed, 07 Sep 2011)
New Revision: 8970
Added:
trunk/src/OpenGl/OpenGl_PrinterContext.cxx
trunk/src/OpenGl/OpenGl_PrinterContext.hxx
Modified:
trunk/src/Aspect/Aspect.cdl
trunk/src/Graphic3d/Graphic3d_GraphicDriver.cdl
trunk/src/Graphic3d/Graphic3d_GraphicDriver_Print.cxx
trunk/src/OpenGl/FILES
trunk/src/OpenGl/OpenGl_GraphicDriver.cdl
trunk/src/OpenGl/OpenGl_GraphicDriver_print.cxx
trunk/src/OpenGl/OpenGl_TextRender.cxx
trunk/src/OpenGl/OpenGl_tgl_funcs.hxx
trunk/src/OpenGl/OpenGl_togl_begin_layer_mode.cxx
trunk/src/OpenGl/OpenGl_togl_print.cxx
trunk/src/OpenGl/OpenGl_view.cxx
trunk/src/V3d/V3d_View.cdl
trunk/src/V3d/V3d_View_Print.cxx
trunk/src/ViewerTest/ViewerTest_ViewerCommands.cxx
trunk/src/Visual3d/Visual3d_View.cdl
trunk/src/Visual3d/Visual3d_View_Print.cxx
Date: 2011-09-07 11:16:18 +0400 (Wed, 07 Sep 2011)
New Revision: 8970
Added:
trunk/src/OpenGl/OpenGl_PrinterContext.cxx
trunk/src/OpenGl/OpenGl_PrinterContext.hxx
Modified:
trunk/src/Aspect/Aspect.cdl
trunk/src/Graphic3d/Graphic3d_GraphicDriver.cdl
trunk/src/Graphic3d/Graphic3d_GraphicDriver_Print.cxx
trunk/src/OpenGl/FILES
trunk/src/OpenGl/OpenGl_GraphicDriver.cdl
trunk/src/OpenGl/OpenGl_GraphicDriver_print.cxx
trunk/src/OpenGl/OpenGl_TextRender.cxx
trunk/src/OpenGl/OpenGl_tgl_funcs.hxx
trunk/src/OpenGl/OpenGl_togl_begin_layer_mode.cxx
trunk/src/OpenGl/OpenGl_togl_print.cxx
trunk/src/OpenGl/OpenGl_view.cxx
trunk/src/V3d/V3d_View.cdl
trunk/src/V3d/V3d_View_Print.cxx
trunk/src/ViewerTest/ViewerTest_ViewerCommands.cxx
trunk/src/Visual3d/Visual3d_View.cdl
trunk/src/Visual3d/Visual3d_View_Print.cxx
*RESTORED*
2011-12-12 08:09 san Relationship added related to 0022696
2011-12-12 08:09 san Relationship added related to 0022696
Related records
- #0022520 · related to · closedUpdate Visualization Users Guide
- #0022582 · related to · closedVisualization - provide an API for dumping a sub-region of the viewport
- #0022696 · related to · closedVisualization - Image dump of 3D Viewer is limited to Video hardware limits
- #0022782 · related to · closedUninitialized global variable used in conditionals in OpenGl package
- #0023001 · related to · closedMistake in OpenGl_FrameBuffer::IsValidDepthBuffer