Could not load saved file

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
bene42

Could not load saved file

Post by bene42 »

Hi,
I am the guy filling, who filed http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=559846.
Saw Revision 2711 should fix the problem. Build r2717, but I still see the bug. Maybe
someone can enlight me, whats going wrong here. (Also a "works here" would help me)

Thx,
Bene42
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Could not load saved file

Post by yorik »

Hi, I just tested here with a file of mine and the file you submitted with the bug report, but here there is no problem, the file opens fine and the cpu usage doesn't go unusually high...
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Could not load saved file

Post by wmayer »

Hi Benedikt,

I wanted to answer on the Debian mailing list shortly. The one bug with the missing slash was easy to fix. While fixing it, however, it showed me another bug in the drawing module which is also fixed now.

The bug we're talking about here I wasn't able to reproduce it. I got an e-Mail from Adam who does the uploading and some maintaining of the freecad package from Debian-side. He told me that he couldn't reproduce this error either. We both could load the attached project file without problems.

Basically, I can think of two cases:

1. In fact, it can happen that the meshing of shapes could take quite some time. But this only happened to me when choosing a very tough maximum deviation error for tessellation of shapes (e.g. <= 0.05) and if the shapes are rather complex. You'll find this value under Preferences > Part Design > Shape view which is set to 0.5 by default.

2. The other possible problem is the loading of the data.


So, to narrow down the problem there are a few things you can check:

1. Start the command line version of FreeCAD with 'freecadcmd'. This opens a Python interpreter for you where you should enter
App.openDocument("test2.fcstd")

2. Start the GUI version of FreeCAD. Now create again your shapes. Instead of using the Save As command use the Export command. First select your shape, invoke the Export command and choose CAD formats in the list of file types. Maybe you can export the data using all three file formats STEP, IGES, BREP. Once you're done try to load the shapes again via Open or Import.

Regards,
Werner
ariane_tux
Posts: 8
Joined: Thu Dec 10, 2009 9:35 pm

Re: Could not load saved file

Post by ariane_tux »

yorikvanhavre wrote:Hi, I just tested here with a file of mine and the file you submitted with the bug report, but here there is no problem, the file opens fine and the cpu usage doesn't go unusually high...
Thats sounds good. Can you tell me the revision, you use, also which OS and in case of linux the distro you use?
That would be great.
ariane_tux
Posts: 8
Joined: Thu Dec 10, 2009 9:35 pm

Re: Could not load saved file

Post by ariane_tux »

Hi Werner
wmayer wrote: I wanted to answer on the Debian mailing list shortly. The one bug with the missing slash was easy to fix. While fixing it, however, it showed me another bug in the drawing module which is also fixed now.
:-)
wmayer wrote: The bug we're talking about here I wasn't able to reproduce it. I got an e-Mail from Adam who does the uploading and some maintaining of the freecad package from Debian-side. He told me that he couldn't reproduce this error either. We both could load the attached project file without problems.
Hm, thats sounds bad for me. I did some work and send it to a frind of mine, he was the first, recognize the error. After that I tied it on different machines (x86 and x86_86) and it failed. The test feature on all machines run fine. All machines ar on sid.
wmayer wrote: Basically, I can think of two cases:

1. In fact, it can happen that the meshing of shapes could take quite some time. But this only happened to me when choosing a very tough maximum deviation error for tessellation of shapes (e.g. <= 0.05) and if the shapes are rather complex. You'll find this value under Preferences > Part Design > Shape view which is set to 0.5 by default.
the parameter "shape view" ist set to 0.5

$ freecadcmd
FreeCAD 0.9, Libs: 0.9R2646
(c) Juergen Riegel, Werner Mayer 2001-2009
##### #### ### ####
# # # # # #
# ## #### #### # # # # #
#### # # # # # # # ##### # #
# # #### #### # # # # #
# # # # # # # # # ## ## ##
# # #### #### ### # # #### ## ## ##

[FreeCAD Console mode <Use Ctrl-D (i.e. EOF) to exit.>]
>>> App.openDocument("test2.fcstd")
Importing project files......
<Document object at 0x10a1970> (100.0 %)
>>>

2. The other possible problem is the loading of the data.


So, to narrow down the problem there are a few things you can check:

1. Start the command line version of FreeCAD with 'freecadcmd'. This opens a Python interpreter for you where you should enter
App.openDocument("test2.fcstd")
$ freecadcmd
FreeCAD 0.9, Libs: 0.9R2646
(c) Juergen Riegel, Werner Mayer 2001-2009
##### #### ### ####
# # # # # #
# ## #### #### # # # # #
#### # # # # # # # ##### # #
# # #### #### # # # # #
# # # # # # # # # ## ## ##
# # #### #### ### # # #### ## ## ##

[FreeCAD Console mode <Use Ctrl-D (i.e. EOF) to exit.>]
>>> App.openDocument("test2.fcstd")
Importing project files......
<Document object at 0x10a1970> (100.0 %)
>>>
wmayer wrote: 2. Start the GUI version of FreeCAD. Now create again your shapes. Instead of using the Save As command use the Export command. First select your shape, invoke the Export command and choose CAD formats in the list of file types. Maybe you can export the data using all three file formats STEP, IGES, BREP. Once you're done try to load the shapes again via Open or Import.
load file => 100%CPU
import iges =>
*** glibc detected *** freecad: free(): invalid pointer: 0x0000000020048928 ***
======= Backtrace: =========
/lib/libc.so.6[0x7f835aefed56]
/lib/libc.so.6(cfree+0x6c)[0x7f835af039bc]
/usr/lib/libTKMath-6.3.0.so(_ZN18TColgp_Array2OfPnt7DestroyEv+0x38)[0x7f834df28858]
/usr/lib/libTKIGES-6.3.0.so(_ZN23IGESToBRep_BasicSurface22TransferBSplineSurfaceERK30Handle_IGESGeom_BSplineSurface+0x10e6)[0x7f834d740fc6]
/usr/lib/libTKIGES-6.3.0.so(_ZN23IGESToBRep_BasicSurface20TransferBasicSurfaceERK26Handle_IGESData_IGESEntity+0x1b4)[0x7f834d742184]
/usr/lib/libTKIGES-6.3.0.so(_ZN22IGESToBRep_TopoSurface24TransferTopoBasicSurfaceERK26Handle_IGESData_IGESEntity+0xc5)[0x7f834d7555c5]
/usr/lib/libTKIGES-6.3.0.so(_ZN22IGESToBRep_TopoSurface19TransferTopoSurfaceERK26Handle_IGESData_IGESEntity+0x136)[0x7f834d75aba6]
/usr/lib/libTKIGES-6.3.0.so(_ZN22IGESToBRep_TopoSurface12ParamSurfaceERK26Handle_IGESData_IGESEntityR9gp_Trsf2dRd+0x60)[0x7f834d75afc0]
/usr/lib/libTKIGES-6.3.0.so(_ZN22IGESToBRep_TopoSurface22TransferTrimmedSurfaceERK30Handle_IGESGeom_TrimmedSurface+0x264)[0x7f834d75d3a4]
/usr/lib/libTKIGES-6.3.0.so(_ZN22IGESToBRep_TopoSurface19TransferTopoSurfaceERK26Handle_IGESData_IGESEntity+0xa2)[0x7f834d75ab12]
/usr/lib/libTKIGES-6.3.0.so(_ZN26IGESToBRep_CurveAndSurface23TransferCurveAndSurfaceERK26Handle_IGESData_IGESEntity+0xd3)[0x7f834d743963]
/usr/lib/libTKIGES-6.3.0.so(_ZN26IGESToBRep_CurveAndSurface16TransferGeometryERK26Handle_IGESData_IGESEntity+0x18d)[0x7f834d743f7d]
/usr/lib/libTKIGES-6.3.0.so(_ZN26IGESToBRep_CurveAndSurface16TransferGeometryERK26Handle_IGESData_IGESEntity+0x14bf)[0x7f834d7452af]
/usr/lib/libTKIGES-6.3.0.so(_ZN16IGESToBRep_Actor8TransferERK25Handle_Standard_TransientRK32Handle_Transfer_TransientProcess+0x24b)[0x7f834d72ffeb]
/usr/lib/libTKXSBase-6.3.0.so(_ZN32Transfer_ActorOfTransientProcess12TransferringERK25Handle_Standard_TransientRK35Handle_Transfer_ProcessForTransient+0x47)[0x7f834cd88917]
/usr/lib/libTKXSBase-6.3.0.so(_ZN28Transfer_ProcessForTransient15TransferProductERK25Handle_Standard_Transient+0x9f)[0x7f834cca37ff]
/usr/lib/libTKXSBase-6.3.0.so(_ZN28Transfer_ProcessForTransient12TransferringERK25Handle_Standard_Transient+0x198)[0x7f834cca6dc8]
/usr/lib/libTKXSBase-6.3.0.so(_ZN28Transfer_ProcessForTransient8TransferERK25Handle_Standard_Transient+0x1c)[0x7f834cca758c]
/usr/lib/libTKXSBase-6.3.0.so(_ZN24XSControl_TransferReader11TransferOneERK25Handle_Standard_Transientj+0x2fc)[0x7f834cdb55fc]
/usr/lib/libTKXSBase-6.3.0.so(_ZN16XSControl_Reader13TransferRootsEv+0x15d)[0x7f834cdb0add]
/usr/lib/freecad/Mod/Part/libPart.so.2(_ZN4Part9TopoShape10importIgesEPKc+0x145)[0x7f834a47d905]
/usr/lib/freecad/Mod/Part/libPart.so.2(_ZN4Part10ImportIges7executeEv+0x16b)[0x7f834a46541b]
/usr/lib/freecad/lib/libFreeCADApp.so.2(_ZN3App14DocumentObject9recomputeEv+0x12)[0x7f835c1c6d32]
/usr/lib/freecad/lib/libFreeCADApp.so.2(_ZN3App8Document17_recomputeFeatureEPNS_14DocumentObjectE+0x39)[0x7f835c1b8019]
/usr/lib/freecad/lib/libFreeCADApp.so.2(_ZN3App8Document9recomputeEv+0xbc8)[0x7f835c1bc1b8]
/usr/lib/freecad/Mod/Part/libPart.so.2[0x7f834a3f63c3]
/usr/lib/libpython2.5.so.1.0(PyEval_EvalFrameEx+0x499b)[0x7f835c7da66b]
/usr/lib/libpython2.5.so.1.0(PyEval_EvalCodeEx+0x6b5)[0x7f835c7dbb65]
/usr/lib/libpython2.5.so.1.0(PyEval_EvalCode+0x32)[0x7f835c7dbd52]
/usr/lib/libpython2.5.so.1.0(PyRun_StringFlags+0x8c)[0x7f835c7f918c]
/usr/lib/freecad/lib/libFreeCADBase.so.2(_ZN4Base20InterpreterSingleton9runStringEPKc+0x62)[0x7f835c4a2d42]
/usr/lib/freecad/lib/libFreeCADGui.so.2(_ZN3Gui7Command9doCommandENS0_10DoCmd_TypeEPKcz+0xfa)[0x7f835bb61bea]
/usr/lib/freecad/lib/libFreeCADGui.so.2(_ZN3Gui11Application4openEPKcS2_+0xb6)[0x7f835bb3f256]
/usr/lib/freecad/lib/libFreeCADGui.so.2(_ZN10StdCmdOpen9activatedEi+0x4d2)[0x7f835bb66e62]
/usr/lib/freecad/lib/libFreeCADGui.so.2(_ZN3Gui7Command6invokeEi+0x6d)[0x7f835bb6007d]
/usr/lib/freecad/lib/libFreeCADGui.so.2(_ZN3Gui6Action11qt_metacallEN11QMetaObject4CallEiPPv+0x70)[0x7f835bb36a30]
/usr/lib/libQtCore.so.4(_ZN11QMetaObject8activateEP7QObjectiiPPv+0x262)[0x7f83607ebdf2]
/usr/lib/libQtGui.so.4(_ZN7QAction9triggeredEb+0x37)[0x7f835fc4a147]
/usr/lib/libQtGui.so.4(_ZN7QAction8activateENS_11ActionEventE+0xb0)[0x7f835fc4b5c0]
/usr/lib/libQtGui.so.4[0x7f836004615d]
/usr/lib/libQtGui.so.4[0x7f836004c08f]
/usr/lib/libQtGui.so.4(_ZN7QWidget5eventEP6QEvent+0x7df)[0x7f835fca037f]
/usr/lib/libQtGui.so.4(_ZN5QMenu5eventEP6QEvent+0xcb)[0x7f836004e7eb]
/usr/lib/libQtGui.so.4(_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent+0xad)[0x7f835fc5001d]
/usr/lib/libQtGui.so.4(_ZN12QApplication6notifyEP7QObjectP6QEvent+0x7ea)[0x7f835fc587ca]
/usr/lib/freecad/lib/libFreeCADGui.so.2(_ZN3Gui14GUIApplication6notifyEP7QObjectP6QEvent+0x48)[0x7f835bb49468]
/usr/lib/libQtCore.so.4(_ZN16QCoreApplication14notifyInternalEP7QObjectP6QEvent+0x8c)[0x7f83607d6c9c]
/usr/lib/libQtGui.so.4(_ZN19QApplicationPrivate14sendMouseEventEP7QWidgetP11QMouseEventS1_S1_PS1_R8QPointerIS0_E+0x108)[0x7f835fc57a78]
/usr/lib/libQtGui.so.4[0x7f835fcc0814]
/usr/lib/libQtGui.so.4(_ZN12QApplication15x11ProcessEventEP7_XEvent+0x102f)[0x7f835fcbf40f]
/usr/lib/libQtGui.so.4[0x7f835fce776c]
/lib/libglib-2.0.so.0(g_main_context_dispatch+0x24a)[0x7f835a5e113a]
/lib/libglib-2.0.so.0[0x7f835a5e4998]
/lib/libglib-2.0.so.0(g_main_context_iteration+0x6c)[0x7f835a5e4b4c]
/usr/lib/libQtCore.so.4(_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x5c)[0x7f83607ff39c]
/usr/lib/libQtGui.so.4[0x7f835fce6f1f]
/usr/lib/libQtCore.so.4(_ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE+0x32)[0x7f83607d5562]
/usr/lib/libQtCore.so.4(_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE+0xd4)[0x7f83607d5934]
/usr/lib/libQtCore.so.4(_ZN16QCoreApplication4execEv+0xc4)[0x7f83607d7ba4]
/usr/lib/freecad/lib/libFreeCADGui.so.2(_ZN3Gui11Application14runApplicationEv+0x8a9)[0x7f835bb47f39]
freecad[0x403933]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7f835aeacabd]
freecad[0x402b69]
======= Memory map: ========
00400000-0043a000 r-xp 00000000 08:03 828425957 /usr/lib/freecad/bin/FreeCAD
00639000-0063a000 rw-p 00039000 08:03 828425957 /usr/lib/freecad/bin/FreeCAD
01213000-03556000 rw-p 00000000 00:00 0 [heap]
20000000-203e8000 rw-p 00000000 00:0d 1298 /dev/zero
40112000-40197000 rw-p 00000000 00:0d 1298 /dev/zero
40899000-4089b000 rwxp 00000000 00:0d 1298 /dev/zero
7f8338000000-7f8338046000 rw-p 00000000 00:00 0
7f8338046000-7f833c000000 ---p 00000000 00:00 0
7f833de77000-7f833deb7000 rw-s e7d3a000 00:0d 6336 /dev/nvidia0
7f833deb7000-7f833dfb7000 rw-s 51107000 00:0d 6336 /dev/nvidia0
7f833dfb7000-7f833dfb8000 rw-s fbc02000 00:0d 6336 /dev/nvidia0
7f833dfb8000-7f833e0b8000 rw-s 97b87000 00:0d 6336 /dev/nvidia0
7f833e0b8000-7f833e5fe000 rw-s e0000000 00:0d 6336 /dev/nvidia0
7f833e5fe000-7f833e601000 r-xp 00000000 08:03 537786846 /usr/lib/python2.5/lib-dynload/fcntl.so
7f833e601000-7f833e800000 ---p 00003000 08:03 537786846 /usr/lib/python2.5/lib-dynload/fcntl.so
7f833e800000-7f833e802000 rw-p 00002000 08:03 537786846 /usr/lib/python2.5/lib-dynload/fcntl.so
7f833e802000-7f833e805000 r-xp 00000000 08:03 537431593 /usr/lib/python2.5/lib-dynload/_random.so
7f833e805000-7f833ea04000 ---p 00003000 08:03 537431593 /usr/lib/python2.5/lib-dynload/_random.so
7f833ea04000-7f833ea05000 rw-p 00002000 08:03 537431593 /usr/lib/python2.5/lib-dynload/_random.so
7f833ea05000-7f833ea0a000 r-xp 00000000 08:03 537786839 /usr/lib/python2.5/lib-dynload/binascii.so
7f833ea0a000-7f833ec09000 ---p 00005000 08:03 537786839 /usr/lib/python2.5/lib-dynload/binascii.so
7f833ec09000-7f833ec0a000 rw-p 00004000 08:03 537786839 /usr/lib/python2.5/lib-dynload/binascii.so
7f833ec0a000-7f833ec10000 r-xp 00000000 08:03 537786880 /usr/lib/python2.5/lib-dynload/_struct.so
7f833ec10000-7f833ee10000 ---p 00006000 08:03 537786880 /usr/lib/python2.5/lib-dynload/_struct.so
7f833ee10000-7f833ee12000 rw-p 00006000 08:03 537786880 /usr/lib/python2.5/lib-dynload/_struct.so
7f833ee12000-7f833ee2b000 r-xp 00000000 08:03 538837535 /usr/lib/python2.5/lib-dynload/_ctypes.so
7f833ee2b000-7f833f02a000 ---p 00019000 08:03 538837535 /usr/lib/python2.5/lib-dynload/_ctypes.so
7f833f02a000-7f833f02e000 rw-p 00018000 08:03 538837535 /usr/lib/python2.5/lib-dynload/_ctypes.so
7f833f02e000-7f833f02f000 ---p 00000000 00:00 0
7f833f02f000-7f833f82f000 rwxp 00000000 00:00 0
7f833f82f000-7f833f830000 ---p 00000000 00:00 0
7f833f830000-7f8340030000 rwxp 00000000 00:00 0
7f8340030000-7f8340070000 rw-p 00000000 00:00 0
7f834007d000-7f8340115000 r--p 00000000 08:03 809000016 /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf
7f8340115000-7f8340129000 r--p 00000000 08:03 809000278 /usr/share/fonts/type1/gsfonts/n019003l.pfb
7f8340129000-7f834015c000 r--p 00000000 08:03 545876542 /usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf
7f834015c000-7f83401a2000 r--p 00000000 08:03 545876543 /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf
7f83401a2000-7f83401c1000 r--p 00000000 08:03 545876527 /usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS.ttf
7f83401c1000-7f83401e0000 r--p 00000000 08:03 545877384 /usr/share/fonts/truetype/msttcorefonts/Trebuchet_MS_Bold.ttf
7f83401e0000-7f8340200000 rw-p 00000000 00:00 0
7f8340203000-7f8340613000 rw-p 00000000 00:00 0
7f8340613000-7f834063a000 r-xp 00000000 08:03 5072469 /usr/lib/qt4/plugins/codecs/libqtwcodecs.so
7f834063a000-7f8340839000 ---p 00027000 08:03 5072469 /usr/lib/qt4/plugins/codecs/libqtwcodecs.so
7f8340839000-7f834083a000 rw-p 00026000 08:03 5072469 /usr/lib/qt4/plugins/codecs/libqtwcodecs.so
7f834083a000-7f834084d000 r-xp 00000000 08:03 5072468 /usr/lib/qt4/plugins/codecs/libqkrcodecs.so
7f834084d000-7f8340a4c000 ---p 00013000 08:03 5072468 /usr/lib/qt4/plugins/codecs/libqkrcodecs.so
7f8340a4c000-7f8340a4d000 rw-p 00012000 08:03 5072468 /usr/lib/qt4/plugins/codecs/libqkrcodecs.so
7f8340a4d000-7f8340a78000 r-xp 00000000 08:03 5072465 /usr/lib/qt4/plugins/codecs/libqjpcodecs.so
7f8340a78000-7f8340c78000 ---p 0002b000 08:03 5072465 /usr/lib/qt4/plugins/codecs/libqjpcodecs.so
7f8340c78000-7f8340c7a000 rw-p 0002b000 08:03 5072465 /usr/lib/qt4/plugins/codecs/libqjpcodecs.so
7f8340c7a000-7f8340c9d000 r-xp 00000000 08:03 5072466 /usr/lib/qt4/plugins/codecs/libqcncodecs.so
7f8340c9d000-7f8340e9d000 ---p 00023000 08:03 5072466 /usr/lib/qt4/plugins/codecs/libqcncodecs.so
7f8340e9d000-7f8340e9e000 rw-p 00023000 08:03 5072466 /usr/lib/qt4/plugins/codecs/libqcncodecs.so
7f8340e9e000-7f8340ea3000 r-xp 00000000 08:03 995284069 /lib/libnss_dns-2.10.2.so
7f8340ea3000-7f83410a2000 ---p 00005000 08:03 995284069 /lib/libnss_dns-2.10.2.so
7f83410a2000-7f83410a3000 r--p 00004000 08:03 995284069 /lib/libnss_dns-2.10.2.so
7f83410a3000-7f83410a4000 rw-p 00005000 08:03 995284069 /lib/libnss_dns-2.10.2.so
7f83410a4000-7f83410a6000 r-xp 00000000 08:03 805524697 /lib/libnss_mdns4_minimal.so.2
7f83410a6000-7f83412a5000 ---p 00002000 08:03 805524697 /lib/libnss_mdns4_minimal.so.2
7f83412a5000-7f83412a6000 rw-p 00001000 08:03 805524697 /lib/libnss_mdns4_minimal.so.2
7f83412a6000-7f83412b9000 r-xp 00000000 08:03 809448104 /lib/libresolv-2.10.2.so
7f83412b9000-7f83414b8000 ---p 00013000 08:03 809448104 /lib/libresolv-2.10.2.soAbnormal program termination...
Getötet
$

Hm...

Regards Bene

PS: I tried it with (x86_64:NVIDIA/x86:Radeon/x86:Intel)
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Could not load saved file

Post by wmayer »

Hi Bene,

as far as I can see this is an issue with the OpenCascade library. It tries to load a B-Spline surface from an IGES file and crashes then. Does this also happen when saving your test shape as STEP or BREP? If you only create a simple box (which definitely has no B-Splines) does this work for you?

BTW, what platform are you using 32-bit or 64-bit?

Cheers,
Werner
bene42

Re: Could not load saved file

Post by bene42 »

Hi Werner,
wmayer wrote: as far as I can see this is an issue with the OpenCascade library.
I feared somethink like that...
wmayer wrote: Does this also happen when saving your test shape as STEP or BREP? If you only create a simple box (which definitely has no B-Splines) does this work for you?
GNARRR!
Maybe I am to dull, but loading STEP or BREP result in a empty sheet or a sheet with only a part of a pie...
wmayer wrote: BTW, what platform are you using 32-bit or 64-bit?
64-bit at the moment.
32-bit results follow tomorrow morning

Bene
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Could not load saved file

Post by wmayer »

Hi Bene,

this is a very lightweight demo application to check whether loading is working or not.

Code: Select all


#include <IGESControl_Controller.hxx>
#include <IGESControl_Writer.hxx>
#include <IGESControl_Reader.hxx>
#include <STEPControl_Writer.hxx>
#include <STEPControl_Reader.hxx>
#include <TopoDS_Shape.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <iostream>

TopoDS_Shape importIges(const char* FileName)
{
	// read iges file
	IGESControl_Reader aReader;
	if (aReader.ReadFile((const Standard_CString)FileName) != IFSelect_RetDone) {
		std::cout << "Error in reading IGES" << std::endl;
		return TopoDS_Shape();
	}

	// make brep
	aReader.ClearShapes();
	aReader.TransferRoots();
	// one shape that contains all subshapes
	return aReader.OneShape();
}

TopoDS_Shape importStep(const char *FileName)
{
    STEPControl_Reader aReader;
	if (aReader.ReadFile((const Standard_CString)FileName) != IFSelect_RetDone) {
		std::cout << "Error in reading STEP" << std::endl;
		return TopoDS_Shape();
	}

    // Root transfers
    aReader.TransferRoots();
    // one shape that contains all subshapes
    return aReader.OneShape();
}

TopoDS_Shape importBrep(const char *FileName)
{
    // read brep-file
    BRep_Builder aBuilder;
    TopoDS_Shape aShape;
    BRepTools::Read(aShape,(const Standard_CString)FileName,aBuilder);
    return aShape;
}

int main (int argc, char* argv[])
{
	if (argc < 2) {
		std::cout << "No file name specified" << std::endl;
		return 0;
	}

	const char* FileName = argv[1];

	try {
		//TopoDS_Shape shape = importIges(FileName);
		TopoDS_Shape shape = importStep(FileName);
		//TopoDS_Shape shape = importBrep(FileName);
		if (shape.IsNull())
			std::cout << "The loaded shape is empty" << std::endl;
    }
	catch (Standard_Failure) {
		Handle(Standard_Failure) aFail = Standard_Failure::Caught();
		std::cout << aFail->GetMessageString() << std::endl;
	}
	return 0;
}


You can compile it with: g++ main.cpp -I/usr/include/opencascade -L/usr/lib -lTKSTEP -lTKIGES -lTKBRep

Cheers,
Werner
bene42

Re: Could not load saved file

Post by bene42 »

Hi Werner,
wmayer wrote: this is a very lightweight demo application to check whether loading is working or not.
here are the results:

step:
$ ./test_freecad ../CAD/testa.step > error.step
Speicherzugriffsfehler
$
error.step findet sich hier http://www.spranger.biz/~bene/error.step
iges:
$ ./test_freecad ../CAD/testa.iges
Report : 19 unknown entities
Total number of loaded entities : 311.
*** glibc detected *** ./test_freecad: free(): invalid pointer: 0x2004145c ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6[0xb75e7824]
/lib/i686/cmov/libc.so.6[0xb75e90b3]
/lib/i686/cmov/libc.so.6(cfree+0x6d)[0xb75ec0ad]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb77bdcc1]
/usr/lib/libstdc++.so.6(_ZdaPv+0x1d)[0xb77bdd1d]
/usr/lib/libTKMath-6.3.0.so(_ZN18TColgp_Array2OfPnt7DestroyEv+0x40)[0xb6f90e60]
/usr/lib/libTKIGES-6.3.0.so(_ZN23IGESToBRep_BasicSurface22TransferBSplineSurfaceERK30Handle_IGESGeom_BSplineSurface+0x111c)[0xb7ba57cc]
/usr/lib/libTKIGES-6.3.0.so(_ZN23IGESToBRep_BasicSurface20TransferBasicSurfaceERK26Handle_IGESData_IGESEntity+0x1b6)[0xb7ba7ed6]
/usr/lib/libTKIGES-6.3.0.so(_ZN22IGESToBRep_TopoSurface24TransferTopoBasicSurfaceERK26Handle_IGESData_IGESEntity+0x92)[0xb7bbbd22]
/usr/lib/libTKIGES-6.3.0.so(_ZN22IGESToBRep_TopoSurface19TransferTopoSurfaceERK26Handle_IGESData_IGESEntity+0x11e)[0xb7bc140e]
/usr/lib/libTKIGES-6.3.0.so(_ZN22IGESToBRep_TopoSurface12ParamSurfaceERK26Handle_IGESData_IGESEntityR9gp_Trsf2dRd+0x4d)[0xb7bc19ad]
/usr/lib/libTKIGES-6.3.0.so(_ZN22IGESToBRep_TopoSurface22TransferTrimmedSurfaceERK30Handle_IGESGeom_TrimmedSurface+0x229)[0xb7bc3e79]
/usr/lib/libTKIGES-6.3.0.so(_ZN22IGESToBRep_TopoSurface19TransferTopoSurfaceERK26Handle_IGESData_IGESEntity+0x98)[0xb7bc1388]
/usr/lib/libTKIGES-6.3.0.so(_ZN26IGESToBRep_CurveAndSurface23TransferCurveAndSurfaceERK26Handle_IGESData_IGESEntity+0xcc)[0xb7ba969c]
/usr/lib/libTKIGES-6.3.0.so(_ZN26IGESToBRep_CurveAndSurface16TransferGeometryERK26Handle_IGESData_IGESEntity+0x16d)[0xb7ba9d5d]
/usr/lib/libTKIGES-6.3.0.so(_ZN26IGESToBRep_CurveAndSurface16TransferGeometryERK26Handle_IGESData_IGESEntity+0x1360)[0xb7baaf50]
/usr/lib/libTKIGES-6.3.0.so(_ZN26IGESToBRep_CurveAndSurface16TransferGeometryERK26Handle_IGESData_IGESEntity+0x1360)[0xb7baaf50]
/usr/lib/libTKIGES-6.3.0.so(_ZN16IGESToBRep_Actor8TransferERK25Handle_Standard_TransientRK32Handle_Transfer_TransientProcess+0x24f)[0xb7b95d2f]
/usr/lib/libTKXSBase-6.3.0.so(_ZN32Transfer_ActorOfTransientProcess12TransferringERK25Handle_Standard_TransientRK35Handle_Transfer_ProcessForTransient+0x52)[0xb725ae12]
/usr/lib/libTKXSBase-6.3.0.so(_ZN28Transfer_ProcessForTransient15TransferProductERK25Handle_Standard_Transient+0x7f)[0xb715d59f]
/usr/lib/libTKXSBase-6.3.0.so(_ZN28Transfer_ProcessForTransient12TransferringERK25Handle_Standard_Transient+0x18f)[0xb716112f]
/usr/lib/libTKXSBase-6.3.0.so(_ZN28Transfer_ProcessForTransient8TransferERK25Handle_Standard_Transient+0x33)[0xb7161883]
/usr/lib/libTKXSBase-6.3.0.so(_ZN23Transfer_TransferOutput8TransferERK25Handle_Standard_Transient+0x4f)[0xb7265f8f]
/usr/lib/libTKXSBase-6.3.0.so(_ZN24XSControl_TransferReader11TransferOneERK25Handle_Standard_Transientj+0x3de)[0xb728ccae]
/usr/lib/libTKXSBase-6.3.0.so(_ZN16XSControl_Reader13TransferRootsEv+0x157)[0xb7287ab7]
./test_freecad[0x804944c]
./test_freecad[0x8049653]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7592b55]
./test_freecad[0x8049341]
======= Memory map: ========
08048000-0804b000 r-xp 00000000 fd:02 410964532 /home/bene/test_freecad/test_freecad
0804b000-0804c000 rw-p 00002000 fd:02 410964532 /home/bene/test_freecad/test_freecad
08371000-084b0000 rw-p 00000000 00:00 0 [heap]
20000000-203e8000 rw-p 00000000 00:0d 1415 /dev/zero
b5000000-b5021000 rw-p 00000000 00:00 0
b5021000-b5100000 ---p 00000000 00:00 0
b51b8000-b51c2000 r-xp 00000000 fd:02 402738534 /lib/i686/cmov/libnss_files-2.10.2.so
b51c2000-b51c3000 r--p 00009000 fd:02 402738534 /lib/i686/cmov/libnss_files-2.10.2.so
b51c3000-b51c4000 rw-p 0000a000 fd:02 402738534 /lib/i686/cmov/libnss_files-2.10.2.so
b51c4000-b51cd000 r-xp 00000000 fd:02 408116494 /lib/i686/cmov/libnss_nis-2.10.2.so
b51cd000-b51ce000 r--p 00008000 fd:02 408116494 /lib/i686/cmov/libnss_nis-2.10.2.so
b51ce000-b51cf000 rw-p 00009000 fd:02 408116494 /lib/i686/cmov/libnss_nis-2.10.2.so
b51cf000-b51e2000 r-xp 00000000 fd:02 408116497 /lib/i686/cmov/libnsl-2.10.2.so
b51e2000-b51e3000 r--p 00012000 fd:02 408116497 /lib/i686/cmov/libnsl-2.10.2.so
b51e3000-b51e4000 rw-p 00013000 fd:02 408116497 /lib/i686/cmov/libnsl-2.10.2.so
b51e4000-b51e6000 rw-p 00000000 00:00 0
b51e6000-b51ec000 r-xp 00000000 fd:02 408116483 /lib/i686/cmov/libnss_compat-2.10.2.so
b51ec000-b51ed000 r--p 00006000 fd:02 408116483 /lib/i686/cmov/libnss_compat-2.10.2.so
b51ed000-b51ee000 rw-p 00007000 fd:02 408116483 /lib/i686/cmov/libnss_compat-2.10.2.so
b51ee000-b51f1000 rw-p 00000000 00:00 0
b51f1000-b53f4000 r-xp 00000000 fd:02 453118666 /usr/lib/libTKFillet-6.3.0.so
b53f4000-b53f9000 rw-p 00202000 fd:02 453118666 /usr/lib/libTKFillet-6.3.0.so
b53f9000-b53fa000 rw-p 00000000 00:00 0
b53fa000-b55b2000 r-xp 00000000 fd:02 453118662 /usr/lib/libTKBO-6.3.0.so
b55b2000-b55b7000 rw-p 001b7000 fd:02 453118662 /usr/lib/libTKBO-6.3.0.so
b55b7000-b55b9000 rw-p 00000000 00:00 0
b55b9000-b55bb000 r-xp 00000000 fd:02 408116492 /lib/i686/cmov/libdl-2.10.2.so
b55bb000-b55bc000 r--p 00001000 fd:02 408116492 /lib/i686/cmov/libdl-2.10.2.so
b55bc000-b55bd000 rw-p 00002000 fd:02 408116492 /lib/i686/cmov/libdl-2.10.2.so
b55bd000-b55be000 rw-p 00000000 00:00 0
b55be000-b560c000 r-xp 00000000 fd:02 438533306 /usr/lib/libTKPrim-6.3.0.so
b560c000-b560e000 rw-p 0004d000 fd:02 438533306 /usr/lib/libTKPrim-6.3.0.so
b560e000-b594b000 r-xp 00000000 fd:02 453118670 /usr/lib/libTKBool-6.3.0.so
b594b000-b5953000 rw-p 0033c000 fd:02 453118670 /usr/lib/libTKBool-6.3.0.so
b5953000-b5955000 rw-p 00000000 00:00 0
b5955000-b5a36000 r-xp 00000000 fd:02 453067406 /usr/lib/libTKOffset-6.3.0.so
b5a36000-b5a39000 rw-p 000e1000 fd:02 453067406 /usr/lib/libTKOffset-6.3.0.so
b5a39000-b5a4e000 r-xp 00000000 fd:02 408116480 /lib/i686/cmov/libpthread-2.10.2.so
b5a4e000-b5a4f000 r--p 00014000 fd:02 408116480 /lib/i686/cmov/libpthread-2.10.2.so
b5a4f000-b5a50000 rw-p 00015000 fd:02 408116480 /lib/i686/cmov/libpthread-2.10.2.so
b5a50000-b5a52000 rw-p 00000000 00:00 0
b5a52000-b5c60000 r-xp 00000000 fd:02 438533307 /usr/lib/libTKTopAlgo-6.3.0.so
b5c60000-b5c65000 rw-p 0020e000 fd:02 438533307 /usr/lib/libTKTopAlgo-6.3.0.so
b5c65000-b5c68000 rw-p 00000000 00:00 0
b5c68000-b60e7000 r-xp 00000000 fd:02 438533304 /usr/lib/libTKGeomAlgo-6.3.0.so
b60e7000-b60ef000 rw-p 0047f000 fd:02 438533304 /usr/lib/libTKGeomAlgo-6.3.0.so
b60ef000-b6329000 rw-p 00000000 00:00 0
b6329000-b672a000 r-xp 00000000 fd:02 453118663 /usr/lib/libTKGeomBase-6.3.0.so
b672a000-b6771000 rw-p 00400000 fd:02 453118663 /usr/lib/libTKGeomBase-6.3.0.so
b6771000-b67c2000 rw-p 00000000 00:00 0
b67c2000-b6888000 r-xp 00000000 fd:02 438533299 /usr/lib/libTKSTEP209-6.3.0.so
b6888000-b688c000 rw-p 000c6000 fd:02 438533299 /usr/lib/libTKSTEP209-6.3.0.so
b688c000-b688e000 rw-p 00000000 00:00 0
b688e000-b6a69000 r-xp 00000000 fd:02 453118669 /usr/lib/libTKShHealing-6.3.0.so
b6a69000-b6a6e000 rw-p 001db000 fd:02 453118669 /usr/lib/libTKShHealing-6.3.0.so
b6a6e000-b6a6f000 rw-p 00000000 00:00 0
b6a6f000-b6ada000 r-xp 00000000 fd:02 453118661 /usr/lib/libTKG2d-6.3.0.so
b6ada000-b6adc000 rw-p 0006a000 fd:02 453118661 /usr/lib/libTKG2d-6.3.0.so
b6adc000-b6ade000 rw-p 00000000 00:00 0
b6ade000-b6be1000 r-xp 00000000 fd:02 437482815 /usr/lib/libTKG3d-6.3.0.so
b6be1000-b6be6000 rw-p 00102000 fd:02 437482815 /usr/lib/libTKG3d-6.3.0.so
b6be6000-b6be7000 rw-p 00000000 00:00 0
b6be7000-b6c93000 r-xp 00000000 fd:02 438533300 /usr/lib/libTKSTEPAttr-6.3.0.so
b6c93000-b6c97000 rw-p 000ab000 fd:02 438533300 /usr/lib/libTKSTEPAttr-6.3.0.so
b6c97000-b6c99000 rw-p 00000000 00:00 0
b6c99000-b6f30000 r-xp 00000000 fd:02 453067405 /usr/lib/libTKSTEPBase-6.3.0.so
b6f30000-b6f3a000 rw-p 00297000 fd:02 453067405 /usr/lib/libTKSTEPBase-6.3.0.so
b6f3a000-b6f44000 rw-p 00000000 00:00 0
b6f44000-b709b000 r-xp 00000000 fd:02 438533296 /usr/lib/libTKMath-6.3.0.so
b709b000-b709f000 rw-p 00156000 fd:02 438533296 /usr/lib/libTKMath-6.3.0.so
b709f000-b70a1000 rw-p 00000000 00:00 0
b70a1000-b7312000 r-xp 00000000 fd:02 453118667 /usr/lib/libTKXSBase-6.3.0.so
b7312000-b731b000 rw-p 00271000 fd:02 453118667 /usr/lib/libTKXSBase-6.3.0.so
b731b000-b7330000 rw-p 00000000 00:00 0
b7330000-b756c000 r-xp 00000000 fd:02 438533291 /usr/lib/libTKernel-6.3.0.so
b756c000-b7573000 rw-p 0023c000 fd:02 438533291 /usr/lib/libTKernel-6.3.0.so
b7573000-b757c000 rw-p 00000000 00:00 0
b757c000-b76bd000 r-xp 00000000 fd:02 408116485 /lib/i686/cmov/libc-2.10.2.so
b76bd000-b76bf000 r--p 00141000 fd:02 408116485 /lib/i686/cmov/libc-2.10.2.so
b76bf000-b76c0000 rw-p 00143000 fd:02 408116485 /lib/i686/cmov/libc-2.10.2.so
b76c0000-b76c3000 rw-p 00000000 00:00 0
b76c3000-b76df000 r-xp 00000000 fd:02 335961708 /lib/libgcc_s.so.1
b76df000-b76e0000 rw-p 0001c000 fd:02 335961708 /lib/libgcc_s.so.1
b76e0000-b7704000 r-xp 00000000 fd:02 408116482 /lib/i686/cmov/libm-2.10.2.so
b7704000-b7705000 r--p 00023000 fd:02 408116482 /lib/i686/cmov/libm-2.10.2.so
b7705000-b7706000 rw-p 00024000 fd:02 408116482 /lib/i686/cmov/libm-2.10.2.so
b7706000-b77eb000 r-xp 00000000 fd:02 436244781 /usr/lib/libstdc++.so.6.0.13
b77eb000-b77ef000 r--p 000e5000 fd:02 436244781 /usr/lib/libstdc++.so.6.0.13
b77ef000-b77f0000 rw-p 000e9000 fd:02 436244781 /usr/lib/libstdc++.so.6.0.13
b77f0000-b77f7000 rw-p 00000000 00:00 0
b77f7000-b78b9000 r-xp 00000000 fd:02 438533288 /usr/lib/libTKBRep-6.3.0.so
b78b9000-b78bd000 rw-p 000c2000 fd:02 438533288 /usr/lib/libTKBRep-6.3.0.so
b78bd000-b78bf000 rw-p 00000000 00:00 0
b78bf000-b7c58000 r-xp 00000000 fd:02 453118664 /usr/lib/libTKIGES-6.3.0.so
b7c58000-b7c65000 rw-p 00398000 fd:02 453118664 /usr/lib/libTKIGES-6.3.0.so
b7c65000-b7c6b000 rw-p 00000000 00:00 0
b7c6b000-b7efc000 r-xp 00000000 fd:02 453118668 /usr/lib/libTKSTEP-6.3.0.so
b7efc000-b7f05000 rw-p 00291000 fd:02 453118668 /usr/lib/libTKSTEP-6.3.0.so
b7f05000-b7f08000 rw-p 00000000 00:00 0
b7f33000-b7f36000 rw-p 00000000 00:00 0
b7f36000-b7f37000 r-xp 00000000 00:00 0 [vdso]
b7f37000-b7f53000 r-xp 00000000 fd:02 346623752 /lib/ld-2.10.2.so
b7f53000-b7f54000 r--p 0001b000 fd:02 346623752 /lib/ld-2.10.2.so
b7f54000-b7f55000 rw-p 0001c000 fd:02 346623752 /lib/ld-2.10.2.so
bf806000-bf81b000 rw-p 00000000 00:00 0 [stack]
Abgebrochen
$

brep:
$ ./test_freecad ../CAD/testa.brep
$

Bis denne
Bene
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Could not load saved file

Post by wmayer »

Hi Bene,

OK the good point is that this is not a bug in FreeCAD, the bad point it's probably a bug in the OpenCascade library.
I guess this bug only appears with the 64-bit but not with 32-bit version because AFAIK all the people who have tested the sample project file have the 32-bit version.

To make this sure you should check that your IGES,STEP, BREP files are not corrupted. If possible it would be best to test this with a 32-bit OpenCascade.

Bis bald
Werner
Post Reply