wxWidgets + OpenCascade = strange behaviour under Linux

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
gk017
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Dec 28, 2008 12:26 pm

wxWidgets + OpenCascade = strange behaviour under Linux

Post by gk017 »

Dear forum members,

I'm developing an application using wxWidgets and OpenCascade (www.opencascade.org, a free geometry kernel). A special OpenCascade-function for importing IGES-files works under Windows, under Linux in a Qt application, but not under Linux in a wxWidgets application. Maybe someone of you has an idea about the reason?

I reduced the interesting code to a minimal sample. The following works as it should do:

Code: Select all

#include <TopoDS_Shape.hxx>
#include <IGESControl_Controller.hxx>
#include <IGESControl_Reader.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <IGESData_IGESModel.hxx>
#include <IGESData_GlobalSection.hxx>

#include <wx/wx.h>

int main(int argc, char* argv[])
{
	cout << "load iges file..." << endl;
	TopoDS_Shape shape;
	IGESControl_Reader reader;
	int status = reader.ReadFile("bearing.igs");	
	if(status == IFSelect_RetDone)
	{
		reader.TransferRoots();
	}
	cout << "... finished" << endl;
    	return true;
}
Embedding the same OpenCascade code in a wxWidgets application works well under Windows, but under Linux I get some OpenCascade error messages, that I'm not able to explain.

Code: Select all

#include <TopoDS_Shape.hxx>
#include <IGESControl_Controller.hxx>
#include <IGESControl_Reader.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <IGESData_IGESModel.hxx>
#include <IGESData_GlobalSection.hxx>

#include <wx/wx.h>

class Application : public wxApp
{
public:
    virtual bool OnInit();
};

DECLARE_APP(Application)

IMPLEMENT_APP(Application)

bool Application::OnInit()
{
	cout << "load iges file..." << endl;
	TopoDS_Shape shape;
	IGESControl_Reader reader;
	int status = reader.ReadFile("bearing.igs");	
	if(status == IFSelect_RetDone)
	{
		reader.TransferRoots();
	}
	cout << "... finished" << endl;
    	return true;
}
I think its not helpful to post the error messages, as you may not know OpenCascade, but is there anyone who can give me some hints where I can search for the reason of this behaviour? Embedding the same code in a Qt application works well, so I think there is something strange in the wxWidgets implementation?

Thanks for any hints,
Gernot
gk017
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Dec 28, 2008 12:26 pm

Post by gk017 »

I just recognized, that if I build the application as X11 application everything works fine. But if I build it as GTK application, I get the errors.

I used the makefiles from /samples/opengl/cube, added the OpenCascade part and adjusted the paths.

How can I find the difference between the X11 and the GTK implementation of the application?

Regards,
Gernot
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

Hi,

maybe you should post the error message anyway, it might contain some hint.

About the code you posted: i do not know the library you use so i may be wrong; it seems to me that this part of code does only file I/O and no graphical display, right?
Jonas Thomas
Knows some wx things
Knows some wx things
Posts: 30
Joined: Sat Dec 27, 2008 1:30 pm
Location: Midwest USA
Contact:

Post by Jonas Thomas »

Auria wrote:Hi,

maybe you should post the error message anyway, it might contain some hint.

About the code you posted: i do not know the library you use so i may be wrong; it seems to me that this part of code does only file I/O and no graphical display, right?
I've dabbled a bit in opencascade and managed to get some code gtkmm code to run the makebottle tutorial. I abandoned my pursuit of gtkmm in favor of wxwidgets which I'm still in the learning along with code::blocks.

Anyway for snick and grins, I couldn't resist plugging the compiler/linker options in C:B with your code in with the following compiler options to see what happen:
Both pieces of code ran fine, without error. (Although I don't have an iges file at hand.

compiler:

Code: Select all

`wx-config --cxxflags`
-I/usr/include/opencascade/ -DHAVE_IOSTREAM -DHAVE_LIMITS
Linker:

Code: Select all

`wx-config --libs`
-Luser/lib -lTKernel -lTKMath -lTKG2d -lTKG3d -lTKGeomBase -lTKBRep -lTKGeomAlgo -lTKTopAlgo \
-lTKPrim -lTKBool -lTKFeat -lTKFillet -lTKOffset -lTKHLR \
-lTKService -lTKV2d -lTKV3d -lTKMesh -lTKPCAF -lTKLCAF -lTKPLCAF -lTKCDF -lTKCAF \
-lPTKernel -lTKIGES -lTKSTEP -lTKSTEPBase -lTKSTEPAttr -lTKSTEP209 -lTKSTL -lTKVRML -lTKShHealing \
-lTKXSBase -lTKPShape -lTKShapeSchema -lTKOpenGl

Code: Select all

Checking for existence: /home/jonas/projects/OCCstuff/igeswkWidget/bin/Debug/igeswkWidget
Executing: xterm -T igeswkWidget -e /usr/bin/cb_console_runner LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. /home/jonas/projects/OCCstuff/igeswkWidget/bin/Debug/igeswkWidget  (in /home/jonas/projects/OCCstuff/igeswkWidget/.)
Unfortunately I don't have any igs files to play with... so this is the output I got.

Code: Select all

jonas@Ubuntu4:~/projects/OCCstuff/igeswkWidget/bin/Debug$ ./igeswkWidget
load iges file...
File not found : bearing.igs
... finished
I'm running Ubuntu 8.04, 32 bit using a opencascade .deb file distribution developed by Adam Powell et all which incorporates Dennis Kraftcheck's (not sure on the spelling here) bug fixes for Linux. Please note.. The file structures for this installation are more Debian'ish... and differ from the java installer version that's on the OCC website.

You basically made my day insofar as I could get this to run on a first try.. (I had a very bad couple of days, being stumped by a kindergarten level kind of bug).

Hope this helps. If you like post a link to your Iges file and I'll it a try.
gk017
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Dec 28, 2008 12:26 pm

Post by gk017 »

@Auria

Sorry for my late reply, I was in holiday.

You are right, the openCascade function does only file i/o and some processing of the file contents, absolutely no graphical interaction. Thats why I'm confused (:

Here is the output (and the error messages) with gtk:
  • load iges file...
    Total number of loaded entities 2932.

    ** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7beb2d9 : Standard_RangeError: TCollection_Array1::Create
    ** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7beb2d9 : Standard_RangeError: TCollection_Array1::CreateWarning: IGESToBRep_IGESBoundary: Deviation = 1.22217
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored
    Warning: IGESToBRep_IGESBoundary: Deviation = 3.03783
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored

    ** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7beb2d9 : Standard_RangeError: TCollection_Array1::Create
    ** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7beb2d9 : Standard_RangeError: TCollection_Array1::Create
    ** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7beb2d9 : Standard_RangeError: TCollection_Array1::Create
    ** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7beb2d9 : Standard_RangeError: TCollection_Array1::Create
    ** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7beb2d9 : Standard_RangeError: TCollection_Array1::CreateWarning: IGESToBRep_IGESBoundary: Deviation = 3.34291
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored
    Warning: IGESToBRep_IGESBoundary: Deviation = 1.51169
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored
    Warning: IGESToBRep_IGESBoundary: Deviation = 3.70707
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored
    Warning: IGESToBRep_IGESBoundary: Deviation = 2.53455
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored
    Warning: IGESToBRep_IGESBoundary: Deviation = 3.34291
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored
    Warning: IGESToBRep_IGESBoundary: Deviation = 3.25912
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored
    Warning: IGESToBRep_IGESBoundary: Deviation = 2.76246
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored

    ** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7beb2d9 : Standard_RangeError: TCollection_Array1::CreateWarning: IGESToBRep_IGESBoundary: Deviation = 3.35718
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored
    Warning: IGESToBRep_IGESBoundary: Deviation = 1.50002
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored

    ** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7beb2d9 : Standard_RangeError: TCollection_Array1::Create
    ** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7beb2d9 : Standard_RangeError: TCollection_Array1::CreateWarning: IGESToBRep_IGESBoundary: Deviation = 1.00001
    Warning: IGESToBRep_IGESBoundary: 3D and 2D curves are inconsistent; 3D is ignored

    ... (some more of this)

    *** BRepTopAdaptor_Fclass2d ** Wire Probablement FAUX **
    *** Le wire echantillonne comporte moins de 3 points
    *** On Branche l ancien classifieur
    Wire no 2 of 2 reversed
    Warning: ShapeFix_Face: All wires on a face have small area; left untouched
    ElSLib.cxx : maxderivative = 0.0
    Warning: ShapeFix_Wire::FixLacking: degenerated edge added
    Warning: ShapeFix_Face: All wires on a face have small area; left untouched
    Warning: BRepTools_ReShape::Replace: shape already recorded
    Warning: BRepTools_ReShape::Replace: shape already recorded
    Warning: ShapeFix_Wire::FixIntersection: Non-adjacent intersection fixed (split-0, cut-0, removed-0)
    Wire was splitted on 2 wires
    Wire no 1 of 2 reversed
    Warning: ShapeFix_Face: All wires on a face have small area; left untouched
    Warning: ShapeFix_Wire::FixIntersection: Non-adjacent intersection fixed (split-1, cut-0, removed-0)
    Wire was splitted on 2 wires
    Warning: ShapeFix_Face: 1 small area wire(s) removed
    Warning: ShapeFix_Face: All wires on a face have small area; left untouched
    SameParameter probleme : tangente nulle aux extremites
    SameParameter probleme : tangente nulle aux extremites
    ... finished
and this is how it should be (with x11):
  • load iges file...
    Total number of loaded entities 2932.
    Info: ShapeProcess_Context: Reload Resource_Manager: -> IGES
    ... finished
gk017
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Dec 28, 2008 12:26 pm

Post by gk017 »

@Jonas Thomas:

my iges-file is included in the openCascade distribution, somewhere in the /samples directory.

The error messages occur during processing of the iges file, so if you do not load a file everything is ok.

regards,
Gernot
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

the only thing i could think of is that the wxWidgets initialization changes the current working directory.

Can you try loading the file with an absolute path and see if it makes any difference?
Use the source, Luke!
Jonas Thomas
Knows some wx things
Knows some wx things
Posts: 30
Joined: Sat Dec 27, 2008 1:30 pm
Location: Midwest USA
Contact:

Post by Jonas Thomas »

gk017 wrote:@Jonas Thomas:

my iges-file is included in the openCascade distribution, somewhere in the /samples directory.

The error messages occur during processing of the iges file, so if you do not load a file everything is ok.

regards,
Gernot
I was searching for bearing.igs which I wasn't able to locate..
I did however have a

Code: Select all

/usr/share/doc/opencascade-examples/data/iges/bearing.iges.gz
I gunzip'd it and moved into the same directories as the executables. Both pieces of code ran fine..

Code: Select all

jonas@Ubuntu4:~/projects/OCCstuff/igeswkWidget/bin/Debug$ ls
bearing.iges  igeswkWidget
jonas@Ubuntu4:~/projects/OCCstuff/igeswkWidget/bin/Debug$ ./igeswkWidget
load iges file...
Total number of loaded entities : 2932.
... finished
.. hello world


Code: Select all

jonas@Ubuntu4:~/projects/OCCstuff/IgeExample1/bin/Debug$ ls
bearing.iges  IgeExample1
jonas@Ubuntu4:~/projects/OCCstuff/IgeExample1/bin/Debug$ ./IgeExample1
load iges file...
Total number of loaded entities : 2932.
... finished
I'm still sort of newb at this stuff... If someone tells me how to run as X11 versus gtk I'll give it a go..
gk017
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Dec 28, 2008 12:26 pm

Post by gk017 »

@doublemax:

it has nothing to do with the path, the file is found and loaded, but the errors occur during openCascade processing of the file contents.

@Jonas Thomas:

your file is the same as mine, the number of iges entities is correct. Are you sure you used wxGTK? Can you please post the results of your 'wx-config --cxxflags' and 'wx-config --libs', just for making sure you use the same wx version...
And thanks for trying!

Gernot
Jonas Thomas
Knows some wx things
Knows some wx things
Posts: 30
Joined: Sat Dec 27, 2008 1:30 pm
Location: Midwest USA
Contact:

Post by Jonas Thomas »

[quote="
@Jonas Thomas:

your file is the same as mine, the number of iges entities is correct. Are you sure you used wxGTK? Can you please post the results of your 'wx-config --cxxflags' and 'wx-config --libs', just for making sure you use the same wx version...
And thanks for trying!

Gernot[/quote]

Here you go...

Code: Select all

jonas@Ubuntu4:~$ wx-config --cxxflags
-I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread
jonas@Ubuntu4:~$ 
jonas@Ubuntu4:~$ 
jonas@Ubuntu4:~$ wx-config --libs
-pthread -Wl,-Bsymbolic-functions  -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8 
jonas@Ubuntu4:~$ 
gk017
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Dec 28, 2008 12:26 pm

Post by gk017 »

It does not works.
I build also an unicode version of wxWidgets, but its always the same: I get openCascade errors when using the gtk version of wxWidgets, with the x11 version or in Windows everything is fine.

I have to use different openCascade cxxflags, your flags dont works.

I have no idea, next I will try to get rid of the wx macros to compare the source code of wx.

thanks so far,
Gernot
Jonas Thomas
Knows some wx things
Knows some wx things
Posts: 30
Joined: Sat Dec 27, 2008 1:30 pm
Location: Midwest USA
Contact:

Post by Jonas Thomas »

gk017 wrote:It does not works.
I build also an unicode version of wxWidgets, but its always the same: I get openCascade errors when using the gtk version of wxWidgets, with the x11 version or in Windows everything is fine.

I have to use different openCascade cxxflags, your flags dont works.

I have no idea, next I will try to get rid of the wx macros to compare the source code of wx.

thanks so far,
Gernot
Are you familar with HeeksCad? It's a cad application written using C++ Opencascade and Wxwidgets. http://code.google.com/p/heekscad/
Perhaps, you can try their code or contact them to see if they have run across this issue.
It's actually on my todo list after I get a little more proficient with Wxwidgets.
gk017
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Dec 28, 2008 12:26 pm

Post by gk017 »

I installed a new Kubuntu 8.04 (in VirtualBox), OpenCascade6.2 from the Adam Powell packages and wxWidgets 2.8 from the ubuntu repositories.

To compile I have to change your cxxflags into "...-DHAVE_LIMITS_H". Now I get a segfault during processing of the iges contents.

@Jonas Thomas: can you please post your complete Makefile and the source file for the sample that works for you?

Gernot
Jonas Thomas
Knows some wx things
Knows some wx things
Posts: 30
Joined: Sat Dec 27, 2008 1:30 pm
Location: Midwest USA
Contact:

Post by Jonas Thomas »

gk017 wrote:I installed a new Kubuntu 8.04 (in VirtualBox), OpenCascade6.2 from the Adam Powell packages and wxWidgets 2.8 from the ubuntu repositories.

To compile I have to change your cxxflags into "...-DHAVE_LIMITS_H". Now I get a segfault during processing of the iges contents.

@Jonas Thomas: can you please post your complete Makefile and the source file for the sample that works for you?

Gernot
I will get that done for you when I get home tonight...
I'm just wondering here.... I'm still run 32 bit Linux, versus 64 bit... I wonder if that has something to do with why mine works...
Have you seen any issues regarding this on the OCC forum??
Did you check out instructions from Heeks cad?? Perhaps there may be some useful information there.
gk017
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Dec 28, 2008 12:26 pm

Post by gk017 »

I have not found anything in the openCascade forum. Only OpenCascade and wxWidgets in Windows, like HeeksCAD. It tooks me some weeks to get the graphical output of OpenCascade to work in Linux/GTK and now I dont like to give up with such a 'little' error ;)

Of course I used the 32-bit Kubuntu version. I would really like to try your working Makefile and source, maybe it gives me a starting point for searching, if it works on my system...
Post Reply