LinkStage3 branch and TechDraw Module Test Results

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
wandererfan
Posts: 3075
Joined: Tue Nov 06, 2012 5:42 pm

LinkStage3 branch and TechDraw Module Test Results

Postby wandererfan » Sat Aug 18, 2018 2:08 pm

I'm not happy to be writing this, but LinkStage3 seems to have significant issues, at least as far as TechDraw (and presumably other built-ins, add-ons and macros) goes. Merging into master at this time does not seem appropriate.

I used "FreeCAD-asm3-20180811-aee619a0-a2a5d69.glibc2.17-x86_64.AppImage" for this testing. I did not use asm3 python functionality directly.

OS: Linux Mint 18.3 Sylvia
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.5235 (Git shallow) AppImage
Build type: None
Branch: LinkStage3
Hash: ccaa87e12aaadbd3106607fc503542a863b742da
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Canada (en_CA)

Results are based on test files asm3Test.fcstd and Basic_TechDraw_Tutorial.fcstd (attached)

TechDraw handling of LinkStage3 constructs in "asm3Test.fcstd":
The top two levels of the assembly cannot be printed by TechDraw. They are "Part::Features", so TD expects to find a Shape property which it can draw. Assembly and Parts objects claim to be Part::Features, but their Shape property is Null.

TechDraw will recursively hunt for Shapes to draw by tranversing the children of App::GroupExtension objects. Assembly and Parts have a Group property, but don't appear to be GroupExtensions. Neither LS3 object has methods "hasExtension", "isDerivedFrom" or "getTypeId" methods, so it is difficult to be sure.

The "Angle" object is a "PartDesign::Body" and is printed correctly.

LS3 impact on TD function using "Basic_TechDraw_Tutorial.fcstd"
On loading Basic_TechDraw_Tutorial into LS3, I received a string of messages in the form:
<PropShape> PropertyTopoShape.cpp(316): auto generate element map: Body
<PropShape> PropertyTopoShape.cpp(316): auto generate element map: Sketch
<PropShape> PropertyTopoShape.cpp(316): auto generate element map: Pad
...

Selection is broken in TD under LS3. Items highlight in QGraphicsView and Tree correctly, but appears that subobjects (edges, vertices, faces) are no longer returned by getSelectionEx().

This behaviour is also found in Python macros using getSelectionEx.

The selection issue also has some impact on the 3D window. After encountering selection issues on the TD Page, I was unable to select edges or vertices in the 3D window.

At various points while using Selection, I received the following messages:
Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Shape index out of bound
This message seems to accompany damage to pieces of the 3D model with objects being marked as "inError" in the Tree.

At one point, while attempting to apply Dimensions to an edge, I received these message:
Updating geometry: Error build geometry(1): Both points are equal
Invalid solution from DogLeg solver.

At this point the tutorial object morphed into a different shape;
Original Shape:
BasicTDTutShape.png
BasicTDTutShape.png (7.93 KiB) Viewed 963 times
Morphed Shape:
MorphedTutorialShape.png
MorphedTutorialShape.png (14.45 KiB) Viewed 963 times
No amount of recomputing would bring back the original tutorial shape.

Save/Reload resulted in these messages and the same(?) deformed object.:
Reading failed from embedded file: PartShape16.brp (35853 bytes, 5948 bytes compressed)
Rebuilding Views for: Page/Page
<App::Document> Document.cpp(2276): 'deformedBTDTutorial' failed to restore object 'Dimension002': Shape index out of bound
Rebuilding Views for: Page001/Page001
Lines are parallel
Lines are parallel
Traceback (most recent call last):
File "<string>", line 1, in <module>
<type 'exceptions.IOError'>: Shape index out of bound

At this point, disillusionment set in and I stopped my testing.

wf

Other messages received during testing:
I also received a number of messages that I did not investigate further:

Coin error in SoEventManager::processEvent(): Recursive invocation detected. Delay processing event until the current event is finished processing. (32 repeats)
- can't use 3d window after this. just starts repeating as soon as cursor enters 3D window.

With Assembly selected and Visibility changed (via spacebar):
<asm3.main> 393.798875 - mover.py(291): exception when moving part
Traceback (most recent call last):
File "/tmp/.mount_FreeCADy7CMh/usr/lib/freecad-daily/Ext/freecad/asm3/FCADLogger.py", line 83, in _catch
return func(*args,**kargs)
File "/tmp/.mount_FreeCADy7CMh/usr/lib/freecad-daily/Ext/freecad/asm3/mover.py", line 243, in getMovingElementInfo
raise RuntimeError('no sub-object in selection')
RuntimeError: no sub-object in selection


<asm3.main> 264.373876 - mover.py(291): exception when moving part
Traceback (most recent call last):
File "/tmp/.mount_FreeCAGZmwfM/usr/lib/freecad-daily/Ext/freecad/asm3/FCADLogger.py", line 83, in _catch
return func(*args,**kargs)
File "/tmp/.mount_FreeCAGZmwfM/usr/lib/freecad-daily/Ext/freecad/asm3/mover.py", line 243, in getMovingElementInfo
raise RuntimeError('no sub-object in selection')
RuntimeError: no sub-object in selection

During initialization the error No module named matplotlib occurred in /home/huxster/.FreeCAD/Mod/animation/InitGui.py
Please look into the log file for further information
Attachments
Basic_TechDraw_Tutorial.fcstd
(69.96 KiB) Downloaded 11 times
asm3Test.fcstd
(73.35 KiB) Downloaded 11 times
realthunder
Posts: 1204
Joined: Tue Jan 03, 2017 10:55 am

Re: LinkStage3 branch and TechDraw Module Test Results

Postby realthunder » Sun Aug 19, 2018 4:05 am

wandererfan wrote:
Sat Aug 18, 2018 2:08 pm
I'm not happy to be writing this, but LinkStage3 seems to have significant issues, at least as far as TechDraw (and presumably other built-ins, add-ons and macros) goes. Merging into master at this time does not seem appropriate.
Thanks for the lengthy report.

TechDraw handling of LinkStage3 constructs in "asm3Test.fcstd":
The top two levels of the assembly cannot be printed by TechDraw. They are "Part::Features", so TD expects to find a Shape property which it can draw. Assembly and Parts objects claim to be Part::Features, but their Shape property is Null.
This is by design, for quick assembly solver recomputation. The user can control at which level to generate the shape, by `BuildShape` property in the assembly container. Set it to compound and TechDraw will be happy.

TechDraw will recursively hunt for Shapes to draw by tranversing the children of App::GroupExtension objects. Assembly and Parts have a Group property, but don't appear to be GroupExtensions. Neither LS3 object has methods "hasExtension", "isDerivedFrom" or "getTypeId" methods, so it is difficult to be sure.
Assembly does not use GroupExtension. There is a more powerful utility function Part::Feature::getTopoShape() to retrieve the shape from any object, include group, link, and of course the assembly container. I didn't modify TechDraw WB to use it because I am not that familiar with this WB yet.

LS3 impact on TD function using "Basic_TechDraw_Tutorial.fcstd"
On loading Basic_TechDraw_Tutorial into LS3, I received a string of messages in the form:
<PropShape> PropertyTopoShape.cpp(316): auto generate element map: Body
...
My branch include a new feature called Topological Naming. For testing purpose, the default setting is to auto generate new topological names for legacy model. You can turn this off by create and set the parameter 'BaseApp/Preferences/Mod/Part/General/AutoElemenetMap' to false, and restart FC.

Selection is broken in TD under LS3. Items highlight in QGraphicsView and Tree correctly, but appears that subobjects (edges, vertices, faces) are no longer returned by getSelectionEx().
This is a bug, and has been fixed already. Please try the latest release
At various points while using Selection, I received the following messages:
Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Shape index out of bound
This message seems to accompany damage to pieces of the 3D model with objects being marked as "inError" in the Tree.

At one point, while attempting to apply Dimensions to an edge, I received these message:
Updating geometry: Error build geometry(1): Both points are equal
Invalid solution from DogLeg solver.
The error is exposed by the whole document recomputation for generating the new topological names. However, the new topo name is not the cause of the problem. It is in fact a defect (or compatibility issue) of OCCT 7.3. This problem does not occur for OCCT 7.1. I didn't try 7.2. You can verify this by open the file in upstream 0.18 AppImage, mark the document for recomputation, and recompute it. You'll get the same broken shape. This is in fact a dangerous bug, potentially breaking legacy models with no obvious reason. I'll investigate it further.

I suspect the many of the following errors are caused by the broken shape.

Other messages received during testing:
I also received a number of messages that I did not investigate further:

Coin error in SoEventManager::processEvent(): Recursive invocation detected. Delay processing event until the current event is finished processing. (32 repeats)
- can't use 3d window after this. just starts repeating as soon as cursor enters 3D window.
Can't think of the cause of this. But I do experience this behavior occasionally in the past. It is usually triggered by some unexpected exception (e.g. Unhandled Base::Exception caught in GUIApplication::notify) during coin nodes traversal.

With Assembly selected and Visibility changed (via spacebar):
<asm3.main> 393.798875 - mover.py(291): exception when moving part
Traceback (most recent call last):
File "/tmp/.mount_FreeCADy7CMh/usr/lib/freecad-daily/Ext/freecad/asm3/FCADLogger.py", line 83, in _catch
return func(*args,**kargs)
File "/tmp/.mount_FreeCADy7CMh/usr/lib/freecad-daily/Ext/freecad/asm3/mover.py", line 243, in getMovingElementInfo
raise RuntimeError('no sub-object in selection')
RuntimeError: no sub-object in selection
I am not sure how you trigger this problem. I do fix the double clicking behavior of assembly container, which produce similar error. Please try again with the new version.

During initialization the error No module named matplotlib occurred in /home/huxster/.FreeCAD/Mod/animation/InitGui.py
Please look into the log file for further information
'animation' is a third party workbench. ASAFIK, AppImage can't use your system's python package, and matplotlib is not bundled within.
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
wandererfan
Posts: 3075
Joined: Tue Nov 06, 2012 5:42 pm

Re: LinkStage3 branch and TechDraw Module Test Results

Postby wandererfan » Mon Aug 20, 2018 12:00 am

Using Part::Feature::getTopoShape makes things a lot better:
TDPageFromLS3.png
TDPageFromLS3.png (229.38 KiB) Viewed 816 times
Still some sort of problem with the Dimension object. In the tree it is labelled "Unnamed" but in the property editor it is labelled "Dimension" as it should be.

I couldn't figure out how to make a pull request against your repo, so here is the change in .../TechDraw/App/DrawViewPart.cpp:

Code: Select all

std::vector<TopoDS_Shape> DrawViewPart::getShapesFromObject(App::DocumentObject* docObj) const
{
    std::vector<TopoDS_Shape> result;
    App::GroupExtension* gex = dynamic_cast<App::GroupExtension*>(docObj);
    if (docObj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
        Part::Feature* pf = static_cast<Part::Feature*>(docObj);
        Part::TopoShape ts = Part::Feature::getTopoShape(pf); 
        if (!ts.isNull()) {
            ts.setPlacement(pf->globalPlacement());
            result.push_back(ts.getShape());
        }
        ...
User avatar
fosselius
Posts: 344
Joined: Sat Apr 23, 2016 10:03 am

Re: LinkStage3 branch and TechDraw Module Test Results

Postby fosselius » Mon Aug 20, 2018 4:34 am

I can create the pull request if realthunder have not yet added your fix.
Here is a guide on how to create pull requests: https://help.github.com/articles/creati ... l-request/

Basically, you go to https://github.com/realthunder/FreeCAD press "fork", you will get a copy of realthunders repo in your namespace, then you check it out, make changes, commit, push, then in the github interface on your copy of the project you press "make pull request", select branches etc.
realthunder
Posts: 1204
Joined: Tue Jan 03, 2017 10:55 am

Re: LinkStage3 branch and TechDraw Module Test Results

Postby realthunder » Mon Aug 20, 2018 4:38 am

wandererfan wrote:
Mon Aug 20, 2018 12:00 am
Using Part::Feature::getTopoShape makes things a lot better:
Thanks for trying. I will modify your patch a bit before applying, to support objects other that Part::Feature.
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
wandererfan
Posts: 3075
Joined: Tue Nov 06, 2012 5:42 pm

Re: LinkStage3 branch and TechDraw Module Test Results

Postby wandererfan » Mon Aug 20, 2018 12:21 pm

fosselius wrote:
Mon Aug 20, 2018 4:34 am
Basically, you go to https://github.com/realthunder/FreeCAD press "fork", you will get a copy of realthunders repo in your namespace, then you check it out, make changes, commit, push, then in the github interface on your copy of the project you press "make pull request", select branches etc.
Thanks, that was the first thing I tried, but apparently having 2 forks of the same repo (FreeCAD/FreeCAD) in 1 Github account is frowned upon. I also tried the work around of creating an empty repo on github and pushing from my local repo. That made the repo, but I couldn't get the Base and Head values correct when trying to make a PR.

Will have to sort that out if I find myself contributing on a more regular basis.
triplus
Posts: 8748
Joined: Mon Dec 12, 2011 4:45 pm

Re: LinkStage3 branch and TechDraw Module Test Results

Postby triplus » Mon Aug 20, 2018 9:33 pm

wandererfan wrote:
Sat Aug 18, 2018 2:08 pm
During initialization the error No module named matplotlib occurred in /home/huxster/.FreeCAD/Mod/animation/InitGui.py
Please look into the log file for further information
realthunder wrote:
Sun Aug 19, 2018 4:05 am
animation' is a third party workbench. ASAFIK, AppImage can't use your system's python package, and matplotlib is not bundled within.
Matplotlib is added to the AppImage but it isn't being used.

https://github.com/AppImage/AppImages/pull/339
realthunder
Posts: 1204
Joined: Tue Jan 03, 2017 10:55 am

Re: LinkStage3 branch and TechDraw Module Test Results

Postby realthunder » Tue Aug 21, 2018 1:28 pm

triplus wrote:
Mon Aug 20, 2018 9:33 pm
Matplotlib is added to the AppImage but it isn't being used.

https://github.com/AppImage/AppImages/pull/339
Thanks, I'll update the recipe in next release.

wandererfan wrote:
Mon Aug 20, 2018 12:21 pm
Will have to sort that out if I find myself contributing on a more regular basis.
Hi wandererfan, I have just update LinkStage3, and its lastest commit is to add Link and SubObject support to TechDraw. Please check. I have relaxed selection object type requirement to TechDraw, and rely on Part::Feature::getShape() to obtain shape and sub-shape. With Link, one can now put the drawing in a separate file, and use Link to externally link to the geometry model. And SubObject support allows one to link to a geometry element of a child object in an external group.

Image
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
wandererfan
Posts: 3075
Joined: Tue Nov 06, 2012 5:42 pm

Re: LinkStage3 branch and TechDraw Module Test Results

Postby wandererfan » Tue Aug 21, 2018 11:19 pm

realthunder wrote:
Tue Aug 21, 2018 1:28 pm
I have just update LinkStage3, and its lastest commit is to add Link and SubObject support to TechDraw. Please check.
Basic drawing and dimensioning work fine. Still has the "auto generate" messages. It blows up when trying to make a hatched area, but the BT looks like the failure is in Dimensioning.

Code: Select all

<PropShape> PropertyTopoShape.cpp(316): auto generate element map: DatumPlane001
<PropShape> PropertyTopoShape.cpp(316): auto generate element map: Pocket001
<PropShape> PropertyTopoShape.cpp(316): auto generate element map: Pocket001
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 31 (X_GrabKeyboard)
  Resource id:  0x0
Rebuilding Views for: Page/Page
Rebuilding Views for: Page001/Page001
Updating geometry: Error build geometry(1): Both points are equal
Invalid solution from DogLeg solver.
<Part> PartFeature.cpp(186): 16Standard_Failure Shape index out of bound: Pocket001.Vertex31
Program received signal SIGSEGV, Segmentation fault.
#0  /lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7fa3f812b4b0]
#1  0x7fa3bff256dc in TopoDS_Shape::ShapeType() const from /home/huxster/Target/asm3-build/Mod/TechDraw/TechDraw.so+0x18
#2  0x7fa3bfaba1ff in Measure::Measurement::getType() from /home/huxster/Target/asm3-build/Mod/Measure/Measure.so+0x1af
#3  0x7fa3bfab9fa1 in Measure::Measurement::addReference3D(App::DocumentObject*, char const*) from /home/huxster/Target/asm3-build/Mod/Measure/Measure.so+0x119
#4  0x7fa3bfab9e86 in Measure::Measurement::addReference3D(App::DocumentObject*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) from /home/huxster/Target/asm3-build/Mod/Measure/Measure.so+0x36
#5  0x7fa3bffed3bd in TechDraw::DrawViewDimension::setAll3DMeasurement() from /home/huxster/Target/asm3-build/Mod/TechDraw/TechDraw.so+0xb3
#6  0x7fa3bffe92ef in TechDraw::DrawViewDimension::onChanged(App::Property const*) from /home/huxster/Target/asm3-build/Mod/TechDraw/TechDraw.so+0x129
#7  0x7fa3fae69e93 in App::Property::touch() from /home/huxster/Target/asm3-build/lib/libFreeCADApp.so+0x41
#8  0x7fa3fae93542 in App::PropertyLinkSubList::updateElementReference(App::DocumentObject*, bool) from /home/huxster/Target/asm3-build/lib/libFreeCADApp.so+0x320
#9  0x7fa3fae88933 in App::PropertyLinkBase::updateElementReferences(App::DocumentObject*, bool) from /home/huxster/Target/asm3-build/lib/libFreeCADApp.so+0x269
#10  0x7fa3fae0ad30 in App::GeoFeature::updateElementReference() from /home/huxster/Target/asm3-build/lib/libFreeCADApp.so+0x1c6
#11  0x7fa3fae0adf6 in App::GeoFeature::onChanged(App::Property const*) from /home/huxster/Target/asm3-build/lib/libFreeCADApp.so+0x5e
#12  0x7fa3d830ed76 in Part::Feature::onChanged(App::Property const*) from /home/huxster/Target/asm3-build/Mod/Part/Part.so+0x27c
#13  0x7fa3b3af3a9e in PartDesign::ProfileBased::onChanged(App::Property const*) from /home/huxster/Target/asm3-build/Mod/PartDesign/_PartDesign.so+0x68
#14  0x7fa3fae69f5d in App::Property::hasSetValue() from /home/huxster/Target/asm3-build/lib/libFreeCADApp.so+0x41
#15  0x7fa3d8338e7e in Part::PropertyPartShape::setValue(Part::TopoShape const&) from /home/huxster/Target/asm3-build/Mod/Part/Part.so+0x176
realthunder
Posts: 1204
Joined: Tue Jan 03, 2017 10:55 am

Re: LinkStage3 branch and TechDraw Module Test Results

Postby realthunder » Tue Aug 21, 2018 11:49 pm

wandererfan wrote:
Tue Aug 21, 2018 11:19 pm
Basic drawing and dimensioning work fine. Still has the "auto generate" messages. It blows up when trying to make a hatched area, but the BT looks like the failure is in Dimensioning.
oops, forgot to test for null shape. Fixed.
Updating geometry: Error build geometry(1): Both points are equal
Invalid solution from DogLeg solver.
Are you testing the Basic_TechDraw_Tutorial.fcstd? I haven't figure out the root cause of the recomputation failure yet. I'll work on it.
Try Assembly3 (latest version 0.10.2) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal