wxWidgets (Linux/GTK), OpenCascade and IGES import

Dear forum members,

I am developing an application using wxWidgets (the GTK version) in Linux and have a strange problem with IGES import.

This minimal program works fine:

int main(int argc, char* argv[])
{
cout IGESControl_Reader reader;
int status = reader.ReadFile("bearing.igs");
if(status == IFSelect_RetDone)
{
reader.TransferRoots();
}
cout return true;
}

Now I put the same code in a wxWidgets environment:

#include

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

int main(int argc, char* argv[])
{
wxApp::SetInstance(new Application());
return wxEntry(argc, argv);
}

bool Application::OnInit()
{
cout IGESControl_Reader reader;
int status = reader.ReadFile("bearing.igs");
if(status == IFSelect_RetDone)
{
reader.TransferRoots();
}
cout return true;
}

This sample works fine too in Windows and in Linux using the X11 version of wxWidgets. But if I use the GTK version of wxWidgets in Linux, I get this error messages from reader.TransferRoots():

load iges file...
Total number of loaded entities 2932.

** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7c512d9 : Standard_RangeError: TCollection_Array1::Create
** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7c512d9 : 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 : 0xb7c512d9 : Standard_RangeError: TCollection_Array1::Create
** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7c512d9 : Standard_RangeError: TCollection_Array1::Create
** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7c512d9 : Standard_RangeError: TCollection_Array1::Create
** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7c512d9 : Standard_RangeError: TCollection_Array1::Create
** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7c512d9 : 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

... (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

The resulting shape is completely broken, I can see some shaded triangles, but nothing that looks like the real geometry in the IGES file.

Does anybody has an idea about the reason for this behaviour? I also asked in the wxWidgets forum, but up to now without results...

Thanks,
Gernot

Roman Lygin's picture

Hi gk,

Try to debug. The message
** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : 0xb7c512d9 : Standard_RangeError: TCollection_Array1::Create
means the exception was raised from TCollection_Array1 (rather its instantiation), see TCollection_Array1.gxx:

TCollection_Array1::TCollection_Array1 (const Standard_Integer Low,
const Standard_Integer Up) :
myLowerBound(Low),
myUpperBound(Up),
isAllocated(Standard_True)
{
Standard_RangeError_Raise_if(Up < Low,"TCollection_Array1::Create");
...

This and other messages mean you are using a debug version of Open CASCADE. So set a break-point into Standard_Failure::ReRaise() and unwind a stack from TCollection_Array1. Note the values that are used in its call. Then use debugger for your working version to see what is different. By the way, do you also use OCC debug version in your working version ?

Hope this helps.

Roman

---
opencascade.blogspot.com - blog on Open CASCADE
Join the Open CASCADE Group at LinkedIn

gernot's picture

Hi Roman,
thank you for your reply.
Unfortunately I'm not very familiar with the kdevelop debugger, it tooks me the full day to find something in the opencascade sources, that is definitely different when compiled with the x11 version of wxWidgets than with the gtk version: (in both cases the same code, as listed above)

in IGESToBRep_Actor.cxx, line 154: eps=mymodel->GlobalSection().Resolution();
compiled with x11 is eps==0.001, compiled with GTK is eps==0.0

The error messages obtained with GTK makes me think of a problem with tolerances. But why does the resolution value is different? On wednesday I will try to find the part of the code that fills mymodel with the resolution value. Or can you tell me where this happens? Or even better, do you have an idea about the reason for this behaviour?

Gernot

Roman Lygin's picture

Hi Gernot,
Sorry for a late response - busy week. Did you progress on your issue ?
I've look at IGESToBRep_Actor.cxx. The only possible guess is that you somewhere redefine a value of read.precision.mode (e.g. with Interface_Static::SetValue(...)) Can this be in some initialization code that differs for your Gtk and wxWidgets code ? To check if it's a wrong assumption check with the debugger that Ival==0 on line 153. If in both cases it's so, then you should go upstream into IGESData_GlobalSection.cxx and set breakpoints (especially at lines 218 and 854 where theResolution field is set).

Good luck.
Roman
---
opencascade.blogspot.com - blog on Open CASCADE
Join the Open CASCADE Group at LinkedIn