
Thu, 03/01/2018 - 16:59
Forums:
Hi, I am fresh new using Open Cascade Technologies, as the topic says, I am trying to display an Image in an Open Cascade viewer using Qt. I have tried using the AIS_TexturedShape and other functions, unsuccessfully. My code is below, if anyone has any hint, comment, anything to help, it would be great.
Code:
QString fileName = QFileDialog::getOpenFileName(this,tr("Open File"),"/home","Images (*.png *.jpg)");
//QImage *anImage = new QImage(fileName);
TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(5.0, 60.0, 0.0), gp_Pnt(10.0, 60.0, 0.0));
TopoDS_Shape aPrismEdge = BRepPrimAPI_MakePrism(anEdge, gp_Vec(0.0, 0.0, 5.0));
Handle(AIS_Shape) anAisPrismEdge = new AIS_Shape(aPrismEdge);
Handle (AIS_TexturedShape) anAisTexturePrismEdge = new AIS_TexturedShape(aPrismEdge);
TCollection_AsciiString *asciiStringFile = new TCollection_AsciiString(fileName.toStdString().c_str());
Handle(Image_AlienPixMap) myAlienPixMap = new Image_AlienPixMap();
/*myAlienPixMap->Load(*asciiStringFile);
anAisTexturePrismEdge->SetTexturePixMap(myAlienPixMap);*/
// myOccView->getContext()->SetDisplayMode(anAisTexturePrismEdge,3,Standard_True);
anAisTexturePrismEdge->SetTextureFileName(*asciiStringFile);
myOccView->getContext()->Display(anAisTexturePrismEdge,3);
myOccView->getContext()->UpdateCurrentViewer();
myOccView->fitAll();
}
Mon, 03/05/2018 - 17:22
Do you see any errors in console, or have some crashes?
Have you built Open CASCADE Technology with FreeImage library enabled?
Have you checked if vtexture command works for you in Draw Harness?
Note that you don't have to use AIS_TexturedShape for displaying shape with a texture.
AIS_Shape is enough, but will need configuring presentation attributes in different way (see vtexture command implementation).
P.S.: don't use new for objects, which have not been declared as Handle() - these pointers will lead to memory leaks (like TCollection_AsciiString* in your sample).
Tue, 03/06/2018 - 17:45
The application runs without any crash or error, not even warnings !! It displays a Surface in yellow color (color by default). If I may use an AIS_Shape, how can I modify its attributes ??, I see that the method "SetAttributes()" receives an AIS_Drawer, but an AIS_Drawer dont have any method that receives an AsciiString "FileName" for the surface mapping. As a I am very new using this libraries I am searching in the Documentation for functions and classes which can help me so I don't know how or where I can use "vtexture" commands, and also I do not use FreeImage library on Open Cascade Technology, I am currently using the version 7.1. Thanks for the warning about the pointer use without Handle, I'll take it in count.
Wed, 03/07/2018 - 14:43
There is no class AIS_Drawer at least since OCCT 6.9.0 release.
You will not be able loading and storing images without FreeImage being enabled.
Playing with Draw Harness is a good way to learn OCCT interactively (through it is implying entering commands into console or writing Tcl script).
Anyway - the source code of Draw Harness commands is a good way to know how to use particular functionality of OCCT.
Just grep "vtexture" through source code to find the command implementation.
OCCT 7.1 is an old release, it's AIS_Shape have no interface for setting textures - only AIS_TexturedShape does in old OCCT releases.
It is not recommended using old OCCT releases.
Sat, 03/07/2020 - 12:39
You are so nice.
I met the Similar problem when i test the 7.4.0
1 When using AIS_TexturedShape to display a picture, a piece of black is displayed
2 When testing the 7.4.0 version of the sample program viewer3d, the textured bottle is displayed, and the display is also black.
3 Set the background image, invalid,
After the above three problems occur, use the draw test harness to test the vbackground and vtexture interfaces. The following problems occur
Draw [4]> vbackground -imageFile D: \\ TEST.jpg
TKOpenGl | Type: Portability | ID: 0 | Severity: High | Message:
Warning: generating mipmaps requires GL_ARB_framebuffer_object extension which
is missing.
Draw [7]> vtexture a 2
TKOpenGl | Type: Portability | ID: 0 | Severity: High | Message:
Warning: generating mipmaps requires GL_ARB_framebuffer_object extension which
is missing.
Does this tell me that the device supports the opengl FBO feature to use the opencascade 7.4.0 visualization module?
It seems that this is not mentioned in the release notes of opencascade7.4.0. Is there any way to avoid this limitation?
thank you very much.
Sat, 03/07/2020 - 13:12
I'm pretty sure this is not the first message from TKOpenGl in your log.
Most likely, there are some graphics driver issues.
Try printing OpenGL information via vglinfo command.
Sat, 03/07/2020 - 15:30
Have been studying, researching, and using opencascade for some time. But this is the first time asking questions to the community, but you immediately answered, which surprised and delighted me. Thank you very much.
1. I checked with AIDA64. My PC is older and does not support FBO.
2. In addition, after I opened draw test harness and entered vinit, I got this error:
Draw [6]> vinit
TKOpenGl | Type: Error | ID: 0 | Severity: High | Message:
Error! Main FBO 409x409 @ 0 initialization has failed
After this error, execute the vtexture vbackground command, and the previous error appears.
3. According to the vglinfo you mentioned, after entering the vglinfo instruction in the draw test harness, the following message appears
Draw [11]> vglinfo
OpenGL info:
GLvendor: Intel
GLdevice: Intel (R) G41 Express Chipset
GLversion: 2.1.0-Build 8.15.10.2869
GLSLversion: 1.20-Intel Build 8.15.10.2869
Max texture size: 4096
Max FBO dump size: 4096x4096
Max combined texture units: 16
Max MSAA samples: 0
Viewport: 409x409
ResolutionRatio: 1
Don't know what this means?
4 Before I upgraded to 7.4.0, I used 7.1.0. The texture bottle of the viewer3d sample program can be displayed normally. I don't know what the reason
Sat, 03/07/2020 - 18:18
Your hardware is coming from 2007-2008 design (almost 13 years old), known to be very basic and obsolete even at the days, when it was launched, compared to GeForce and Radeon GPUs.
First of all, you may check hardware requirements within OCCT release:
https://dev.opencascade.org/doc/overview/html/index.html#overview_req_libs
Which specifies OpenGL 3.3+ requirement. This wasn't introduced with OCCT 7.4.0 release, though - it is like that since OCCT 7.0.0 release.
Thus, your hardware is no more supported since OCCT 7.0.0 release.
This doesn't mean, however, that OCCT viewer will completely fail on such configurations - it still provides fallback rendering passes for OpenGL 1.1 / 2.1, with limited capabilities and no full coverage testing.
You may also check the current OCCT development branch in hope that some old compatibility issue has been fixed.
Sun, 03/08/2020 - 03:10
OK!Thank you very much.