Subtractive primitive, broken mesh and crash in FixOrientation.

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Premik
Posts: 10
Joined: Sat Aug 19, 2017 9:50 am

Subtractive primitive, broken mesh and crash in FixOrientation.

Post by Premik »

  • Open the attached file.
  • Set the Bar/Box001/Attachement/Position/x to:
  • -13mm => The result body is corrupted. There are some gaps probably and something with the normals.
  • -23mm => SIGSEGV
Image

Code: Select all

Thread 1 "FreeCAD" received signal SIGSEGV, Segmentation fault.
0x00007fffbda89ca8 in ShapeFix_Face::FixOrientation(TopTools_DataMapOfShapeListOfShape&) () from /opt/oce/lib/libTKShHealing.so.11
(gdb) bt
#0  0x00007fffbda89ca8 in ShapeFix_Face::FixOrientation(TopTools_DataMapOfShapeListOfShape&) () from /opt/oce/lib/libTKShHealing.so.11
#1  0x00007fffbda97e95 in ShapeFix_Face::Perform() () from /opt/oce/lib/libTKShHealing.so.11
#2  0x00007fffc2fbdf4d in fixFace (f=...) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Mod/Part/App/modelRefine.cpp:488
#3  0x00007fffc2fbea0d in ModelRefine::FaceTypedCylinder::buildFace (this=<optimized out>, faces=std::vector of length 39054179, capacity -1954638342119 = {...}) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Mod/Part/App/modelRefine.cpp:673
#4  0x00007fffc2fbf94e in ModelRefine::FaceUniter::process (this=this@entry=0x7fffffffb8d0) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Mod/Part/App/modelRefine.cpp:1023
#5  0x00007fffc2fc16ce in Part::BRepBuilderAPI_RefineModel::Build (this=this@entry=0x7fffffffba90) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Mod/Part/App/modelRefine.cpp:1172
#6  0x00007fffc2fc1b59 in Part::BRepBuilderAPI_RefineModel::BRepBuilderAPI_RefineModel (this=0x7fffffffba90, shape=...) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Mod/Part/App/modelRefine.cpp:1157
#7  0x00007fffb6cef4eb in PartDesign::FeaturePrimitive::refineShapeIfActive (this=this@entry=0x55555863b700, oldShape=...) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Mod/PartDesign/App/FeaturePrimitive.cpp:79
#8  0x00007fffb6cf2ac2 in PartDesign::FeaturePrimitive::execute (this=this@entry=0x55555863b700, primitiveShape=...) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Mod/PartDesign/App/FeaturePrimitive.cpp:143
#9  0x00007fffb6cf3131 in PartDesign::Box::execute (this=0x55555863b700) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Mod/PartDesign/App/FeaturePrimitive.cpp:212
#10 0x00007ffff6c71c44 in App::DocumentObject::recompute (this=0x55555863b700) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/App/DocumentObject.cpp:84
#11 0x00007fffc2de79ec in Part::Feature::recompute (this=<optimized out>) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Mod/Part/App/PartFeature.cpp:83
#12 0x00007ffff6c3b6fc in App::Document::_recomputeFeature (this=this@entry=0x5555579b0190, Feat=0x55555863b700) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/App/Document.cpp:2441
#13 0x00007ffff6c40997 in App::Document::recompute (this=this@entry=0x5555579b0190) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/App/Document.cpp:2227
#14 0x00007ffff7516f36 in Gui::PropertyEditor::PropertyEditor::closeEditor (this=0x555555acf6d0, editor=0x55555811bfe0, hint=QAbstractItemDelegate::SubmitModelCache) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Gui/propertyeditor/PropertyEditor.cpp:104
#15 0x00007ffff5ecaf36 in ?? () from /usr/lib/libQt5Widgets.so.5
#16 0x00007ffff56e4a06 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/libQt5Core.so.5
#17 0x00007ffff5ee4dc1 in QAbstractItemDelegate::closeEditor(QWidget*, QAbstractItemDelegate::EndEditHint) () from /usr/lib/libQt5Widgets.so.5
#18 0x00007ffff5ee5bf8 in ?? () from /usr/lib/libQt5Widgets.so.5
#19 0x00007ffff56e5452 in QObject::event(QEvent*) () from /usr/lib/libQt5Core.so.5
#20 0x00007ffff5c6fe3c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#21 0x00007ffff5c77816 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#22 0x00007ffff7347219 in Gui::GUIApplication::notify (this=0x7fffffffd040, receiver=0x555555b31580, event=0x7fffdc009020) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Gui/GuiApplication.cpp:91
#23 0x00007ffff56b41e0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#24 0x00007ffff56b6e46 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQt5Core.so.5
#25 0x00007ffff57110a4 in ?? () from /usr/lib/libQt5Core.so.5
#26 0x00007fffee161270 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#27 0x00007fffee162f69 in ?? () from /usr/lib/libglib-2.0.so.0
#28 0x00007fffee162fae in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#29 0x00007ffff5710691 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#30 0x00007fffe4fd3282 in ?? () from /usr/lib/libQt5XcbQpa.so.5
#31 0x00007ffff56b282b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#32 0x00007ffff56bbb18 in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
#33 0x00007ffff72f8d3a in Gui::Application::runApplication () at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Gui/Application.cpp:1902
#34 0x000055555555722c in main (argc=<optimized out>, argv=<optimized out>) at /tmp/makepkg/freecad-qt5-git/src/freecad-qt5-git/src/Main/MainGui.cpp:261

Code: Select all

OS: "Arch Linux"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12960 (Git)
Build type: Debug
Branch: master
Hash: b6304d16a77f65f94aa5ec79f69688be61a42961
Python version: 2.7.14
Qt version: 5.10.0
Coin version: 3.1.3
OCC version: 6.9.1.oce-0.18
Locale: English/UnitedStates (en_US)
Attachments
1.png
1.png (20.77 KiB) Viewed 1602 times
Subst.fcstd
(56.04 KiB) Downloaded 52 times
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Subtractive primitive, broken mesh and crash in FixOrientation.

Post by DeepSOIC »

The crash is in shape refinement (removal of redundant edges). You can disable automatic refinement in preferences.
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: Subtractive primitive, broken mesh and crash in FixOrientation.

Post by tanderson69 »

When I move the box, I get a broken model also. However when I do a full recompute the corruption goes away, so that tells me that you may have a bug in your occt version. My occt version is 7.2. Unfortunately model refine still corrupts the model, but doesn't crash and the corruption takes place at the same place that bopalgo is complaining of "too small edge". As a side note, I ran that model through ShapeUpgrade_UnifySameDomain and it didn't corrupt the model, but the bopalgo errors were still there. All that being said, There are some problems with your modelling approach.

short story: You have curves in 2 different sketches that are supposed to represent the same face. This a bad practice and you should try to avoid it when possible. IMHO: you should extrude the outside to full thickness then pocket the inside to establish your 'floor'.

long story: For whatever reason, sketch geometry doesn't always end up exactly where you would expect. Probably has to do with how it is constrained. Look at the following picture. I used the measure tool and measured between 2 points on 2 different sketches. This is the area that the bopalgo check was complaining about. Now look at the text output from the measure tool that I pasted below the picture. This text is output to the report view and the terminal. Notice the 'DeltaX' number. When greater than 1.0e-07 occt starts to consider geometry distinct. So when you extrude these different sketches and fuse them, I am hypothesizing because of the bopalgo error, there is an edge that is 5.093400332611964e-07 in length. This tiny edge can be a source of problems for any modelling kernel.


measure.png
measure.png (17.43 KiB) Viewed 1576 times

Code: Select all

distance = 6.000000000000022mm    unit distance = 6.00 mm
solution count: 1
   solution 1:
      point1 -61.99999999998141   -85   0
      point2 -61.99999949064138   -85   -6
      DeltaX 5.093400332611964e-07
      DeltaY 0
      DeltaZ 6
      shape type on object1 is: Vertex
      shape type on object2 is: Vertex
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Subtractive primitive, broken mesh and crash in FixOrientation.

Post by NormandC »

tanderson69 wrote: Wed Jan 17, 2018 2:53 pm For whatever reason, sketch geometry doesn't always end up exactly where you would expect. Probably has to do with how it is constrained.
I don't have the time to check the file ATM, but your screenshot shows the 2 points to be the connection between an arc and a line. There is a known issue where adding a point-to-point constraint as well as a tangent constraint between the arc and the line creates a precision issue. The proper method is to apply a single point-to-point constraint. https://www.freecadweb.org/wiki/Constra ... angency.29

See also issue #3299

I took the time to check. BottomSk doesn't even have a tangent constraint there. SidesSk does have a point-to-point constraint. Maybe this is the source of the issue.

In any case, sorry for being blunt but these sketches are badly/poorly constrained. BottomSk has a completely useless construction circle overlapping the arc.
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Subtractive primitive, broken mesh and crash in FixOrientation.

Post by NormandC »

I was right.

Bad constraining in BottomSk and SidesSk was causing the issue. I agree that no crash should happen, but if I understand tanderson69 correctly, it's an OCCT issue. Mine is 7.1.0 and I too get the crash at -23mm.

With both sketches properly constrained, there is no more crash, and no more failed model, with Box001 at either X -13 or -23mm. This is with automatic refine options enabled in Preferences/Part Design.

Note that SidesSk is still not fully constrained; also, I agree with tanderson69 about your modelling method.

OS: Ubuntu 16.04.3 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13042 (Git)
Build type: None
Branch: master
Hash: 9a215440b8a0140dbc2e8778e66cf63feeac7114
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: French/Canada (fr_CA)
Attachments
Subst_normandc1.fcstd
(74.52 KiB) Downloaded 50 times
Premik
Posts: 10
Joined: Sat Aug 19, 2017 9:50 am

Re: Subtractive primitive, broken mesh and crash in FixOrientation.

Post by Premik »

Thank you guys for your time and valuable input. I've retrofitted the body to have the extrude and pocket as was suggested. It works great.

Indeed disabling the refinement as a workaround helps too.

And I'll try to avoid unconstrained geometry next time I have any problem as a first thing.
Post Reply