App::Link: the big merge

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
user1234
Posts: 181
Joined: Mon Jul 11, 2016 5:08 pm

Re: App::Link: the big merge

Postby user1234 » Sun Aug 18, 2019 9:19 pm

Hello!
wmayer wrote:
Sun Aug 18, 2019 5:51 pm
Is the behaviour the same between (old) master and Link3?
Was before and is also now. See here: https://forum.freecadweb.org/viewtopic.php?f=3&t=32251 . There are some screencasts about it with CPU and GPU. When the mouse comes over a big model and you move a this, than the FPS goes down. But when you rotate a big model and the mouse do not touch the model (mouseover), than the FPS are normal.
When you deactivate the preselection, the FPS are always normal.

Greetings
user
realthunder
Posts: 1106
Joined: Tue Jan 03, 2017 10:55 am

Re: App::Link: the big merge

Postby realthunder » Sun Aug 18, 2019 11:51 pm

user1234 wrote:
Sat Aug 17, 2019 3:26 pm
I know that i have unusal settings. Because the preselection in the 3D view FreeCAD always calculates the coordinates of the cursor.

And on (larger) assemblies the CPU struggles with that. When i switch off the preselection, FreeCAD runs on my laptop with larger assemblies (100 parts) quite fluently.
wmayer wrote:
Sun Aug 18, 2019 5:51 pm
Is the behaviour the same between (old) master and Link3?
This should have been improved, because the selection now checks if the pre-selected element is the same as before, and will not trigger redraw if so. This is assuming the graphics is the slow down factor, which is usually the case. Maybe you can also try toggling 'Vertex buffer object' option in Preference->Display, and see if there is any improvement in rendering.
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
ickby
Posts: 2914
Joined: Wed Oct 05, 2011 7:36 am

Re: App::Link: the big merge

Postby ickby » Mon Aug 19, 2019 6:12 am

Congratulations for the merge, a lot of work was put in with remarkable endurance, well done!
realthunder wrote:
Thu Aug 15, 2019 6:42 am
There is not many code that is dedicated to LinkGroup, it's just that App::Link must be group aware (it has special handling when linked to plain group and geo group), and act like group in some situation (e.g. in array mode), so I just expose the group part of the logic as LinkGroup. Both LinkGroup and Link are implemented using LinkBaseExtension. One major difference comparing to App::Part + App::Link is that it can directly hold the containing object, rather than leave it hanging out under the root. While App::Part can also hold the object, it will affect other depending objects.
To be honest I still don't get it exactly :) but I'm not so deep into the details anymore, so that's fine. My point is only that it must be intuitive to use for the user. My fear with LinkGroup is, that having it and Part together is confusing for the user as they only differ for certain use cases. Hence my proposal would be to keep only a single one if possible. I don't care much if my old code gets removed, the principles behind it are rather obsolete now anyway. I hence propose to change App::Part to fit into your framework, as this is already used in 0.18 and a known element, and make it the single global placement oriented grouping feature.

One more thing: I always envisioned the toolbar, which holds the groups, also holding a link button like so:
toolbar.png
toolbar.png (1.87 KiB) Viewed 768 times
I still think this would be a good addition now with your link tools. The idea was to have all "structure" elements in one place so it is convenient and directly understandable for the user.
realthunder
Posts: 1106
Joined: Tue Jan 03, 2017 10:55 am

Re: App::Link: the big merge

Postby realthunder » Mon Aug 19, 2019 7:46 am

ickby wrote:
Mon Aug 19, 2019 6:12 am
To be honest I still don't get it exactly :) but I'm not so deep into the details anymore, so that's fine. My point is only that it must be intuitive to use for the user. My fear with LinkGroup is, that having it and Part together is confusing for the user as they only differ for certain use cases. Hence my proposal would be to keep only a single one if possible. I don't care much if my old code gets removed, the principles behind it are rather obsolete now anyway. I hence propose to change App::Part to fit into your framework, as this is already used in 0.18 and a known element, and make it the single global placement oriented grouping feature.

One more thing: I always envisioned the toolbar, which holds the groups, also holding a link button like so:
toolbar.png
I still think this would be a good addition now with your link tools. The idea was to have all "structure" elements in one place so it is convenient and directly understandable for the user.
Right, my original intention was to make App::Part behave more like what LinkGroup is now (which didn't exist at that time). The link scope enforcement is still desired in some use case, like PartDesign::Body, but should be able to turn off, or better, off by default. I'll think about how to do 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
wmayer
Site Admin
Posts: 14645
Joined: Thu Feb 19, 2009 10:32 am

Re: App::Link: the big merge

Postby wmayer » Mon Aug 19, 2019 9:43 am

realthunder wrote:
Sun Aug 18, 2019 11:51 pm
user1234 wrote:
Sat Aug 17, 2019 3:26 pm
I know that i have unusal settings. Because the preselection in the 3D view FreeCAD always calculates the coordinates of the cursor.

And on (larger) assemblies the CPU struggles with that. When i switch off the preselection, FreeCAD runs on my laptop with larger assemblies (100 parts) quite fluently.
wmayer wrote:
Sun Aug 18, 2019 5:51 pm
Is the behaviour the same between (old) master and Link3?
This should have been improved, because the selection now checks if the pre-selected element is the same as before, and will not trigger redraw if so. This is assuming the graphics is the slow down factor, which is usually the case. Maybe you can also try toggling 'Vertex buffer object' option in Preference->Display, and see if there is any improvement in rendering.
I don't think the redraw is the bottleneck but the fact that the default implementation goes through all triangles to find the intersection point(s) with the ray.

Code: Select all


/*!
  Calculates picked point based on primitives generated by subclasses.
*/
void
SoShape::rayPick(SoRayPickAction * action)
{
  if (this->shouldRayPick(action)) {
    this->computeObjectSpaceRay(action);

    if (!PRIVATE(this)->bboxcache ||
        !PRIVATE(this)->bboxcache->isValid(action->getState()) ||
        soshape_ray_intersect(action, PRIVATE(this)->bboxcache->getProjectedBox())) {
      this->generatePrimitives(action);
    }
  }
}


The method generatePrimitives() is re-implemented in SoBrepFaceSet but it's almost identical to that of SoIndexedFaceSet and this is an expensive function call.
So, for the future I think we need an additional data structure (at least for big shape objects) to speed up the intersection calculation by using e.g. an octree, a grid or a similar data structure.
realthunder
Posts: 1106
Joined: Tue Jan 03, 2017 10:55 am

Re: App::Link: the big merge

Postby realthunder » Mon Aug 19, 2019 10:44 am

wmayer wrote:
Mon Aug 19, 2019 9:43 am
I don't think the redraw is the bottleneck but the fact that the default implementation goes through all triangles to find the intersection point(s) with the ray.
I see. It does fit better with his description in the other thread. I've used boost geometry rtree in Path, it'll be handy in here too.
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
user1234
Posts: 181
Joined: Mon Jul 11, 2016 5:08 pm

Re: App::Link: the big merge

Postby user1234 » Mon Aug 19, 2019 11:38 am

This issue have nothing to do with the links. This was before and is also now. This is in my opinion too much off topic. I will make a new thread about this later.

Greetings
user
user1234
Posts: 181
Joined: Mon Jul 11, 2016 5:08 pm

Re: App::Link: the big merge

Postby user1234 » Mon Aug 19, 2019 8:34 pm

Hello!
ickby wrote:
Mon Aug 19, 2019 6:12 am
One more thing: I always envisioned the toolbar, which holds the groups, also holding a link button like so:
+1
I found another tree issues with link merge. (Should i open a new topic about the issues about the merge in gerneral?)

1. When i make an assembly with links and i do change anything in the assembly - any kind of property - FreeCAD recomputes and retouch all single elements of it. In my assembly, this take around two minutes of every step i take. Is this intention?
_recompute.webm
(413.03 KiB) Downloaded 15 times
2. When i reopen an assembly that have a array link (DraftWB) in it, the reopen of the array fails.
_dead_array.png
_dead_array.png (346.31 KiB) Viewed 559 times

Code: Select all

Traceback (most recent call last):
  File "/home/pc/Programs/FreeCAD/Mod/Draft/Draft.py", line 5734, in onDocumentRestored
    self.linkSetup(obj)
  File "/home/pc/Programs/FreeCAD/Mod/Draft/Draft.py", line 5831, in linkSetup
    _DraftLink.linkSetup(self,obj)
  File "/home/pc/Programs/FreeCAD/Mod/Draft/Draft.py", line 5713, in linkSetup
    obj.configLinkProperty('ShowElement')
<class 'ValueError'>: cannot find property 'ShowElement'
15.7329 <App> Document.cpp(2470): Failed to restore _100_Assembly#Array: cannot find property 'ShowElement'
3. When i recompute the array link (see above), the error still exist, but the sign of the error is away. And when i click on the link of tha array, than i get an selection error. I also get the selection error in TechDrawWB, but is pretty hard to reproduce. I will it post when i find a minimal way to reproduce.
_selection_error.png
_selection_error.png (306.76 KiB) Viewed 559 times

Code: Select all

309.853 Selection.cpp(1558): Sub-object _100_Assembly#Array.Link017. not found
I just want to say that the workflow itself is pretty neat.

Greetings
user
user1234
Posts: 181
Joined: Mon Jul 11, 2016 5:08 pm

Re: App::Link: the big merge

Postby user1234 » Tue Aug 20, 2019 12:22 am

Hello!

Another one. When you make an array link in an assembly (the link exists bofore), then two array are built (Array002 + Array003). I think the second array (Array003) is faulty because, when i delete this, then the array works after reload the assembly.
_array_duplicated.webm
(214.23 KiB) Downloaded 19 times
_after_reload.png
_after_reload.png (548.08 KiB) Viewed 533 times
By the way, nice function this highlighting when you touch the tree element with the mouse.

Greetings
user
realthunder
Posts: 1106
Joined: Tue Jan 03, 2017 10:55 am

Re: App::Link: the big merge

Postby realthunder » Tue Aug 20, 2019 12:43 am

user1234 wrote:
Mon Aug 19, 2019 8:34 pm
I found another tree issues with link merge. (Should i open a new topic about the issues about the merge in gerneral?)
This thread is fine. The merge is done. But I'll continue to fix any related bugs here.
1. When i make an assembly with links and i do change anything in the assembly - any kind of property - FreeCAD recomputes and retouch all single elements of it. In my assembly, this take around two minutes of every step i take. Is this intention?
You video capture seems fall short. It didn't show the part where is touches all elements. If you modified a linked object, then yes, it will touch every link that links to this object. And array element is a link. The recomputation of link itself shouldn't take much time. There maybe other objects to blame. Is it possible to send me your files?
2. When i reopen an assembly that have a array link (DraftWB) in it, the reopen of the array fails.
Please sync my LinkMerge branch and see if it is fixed. The duplicated array problem you mentioned is probably fixed by the last commit as well. The draft link array is created quit early in the development process, there may be more things broken.

I see that you are already making some quite complex assemblies here. It's good to have testers like you.
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