Dimension Reference Corruption

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
wandererfan
Veteran
Posts: 6270
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Dimension Reference Corruption

Post by wandererfan »

There will be a proof of concept for issue #8878 available in the next day or two. I will be asking for testing help.

The general approach of the proof of concept is outlined in the issue. Feedback is welcome.

Thanks.
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: Dimension Reference Corruption

Post by aapo »

wandererfan wrote: Wed Mar 15, 2023 12:39 pm There will be a proof of concept for issue #8878 available in the next day or two. I will be asking for testing help.

The general approach of the proof of concept is outlined in the issue. Feedback is welcome.

Thanks.

I read your proposal, and it sounds wonderful to me! I've also thought about implementing a similar mechanism in the past, but I've failed to come up with a decent edge/vertex comparison algorithm for the feature even in the abstract idea level when the model is edited (i.e. the stuff where you refer to computer vision algorithm). Thus, the lack of a good algorithm and the expected difficulties with an even very basic implementation has kept me at bay for this kind of functionality; but it's great to hear that you've already managed to design and implement some parts of the functionality.

In practice, I'm suspecting that the main problem will be the "superfluous geometry" that the OCC algorithms sometimes produces. Every now and then, OCC produces multiple edges that are partly or fully overlapping, and sometimes these extra edges are thrown out by OCC. If two edges happen to have exactly the same geometry, it's obviously impossible to detect which one is which. Thus, there would need to be a mechanism to get rid of fully overlapping edges before any other processing is done to the drawing, but I'm afraid this kind of function is missing from TD (or OCC).
user1234
Veteran
Posts: 3349
Joined: Mon Jul 11, 2016 5:08 pm

Re: Dimension Reference Corruption

Post by user1234 »

wandererfan wrote: Wed Mar 15, 2023 12:39 pm Feedback is welcome.
When it gets to testing (i can compile), ping me.

Greetings
user1234
User avatar
wandererfan
Veteran
Posts: 6270
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Dimension Reference Corruption

Post by wandererfan »

user1234 wrote: Thu Mar 16, 2023 1:17 pm When it gets to testing (i can compile), ping me.
Wonderful, thanks! https://github.com/WandererFan/FreeCAD/ ... toCorrect3

A simple first test is to open cubeWithHole, make a dimension on the top edge, then go to PartDesign and make a fillet on the bottom edge. All the edge numbers will change and if autocorrect is turned on, the new top edge will be substituted. If auto-correct is off, you'll get a message in the report view and an X on the dimension value.
AutoCorrectDimRefs.png
AutoCorrectDimRefs.png (93.77 KiB) Viewed 1132 times
Attachments
cubeWithHole.FCStd
(13.1 KiB) Downloaded 27 times
user1234
Veteran
Posts: 3349
Joined: Mon Jul 11, 2016 5:08 pm

Re: Dimension Reference Corruption

Post by user1234 »

wandererfan wrote: Thu Mar 16, 2023 7:15 pm A simple first test is to open cubeWithHole, make a dimension on the top edge, then go to PartDesign and make a fillet on the bottom edge. All the edge numbers will change and if autocorrect is turned on, the new top edge will be substituted. If auto-correct is off, you'll get a message in the report view and an X on the dimension value.
Works.

As i understand, it compares shapes from before the change. But there is an issue, see an simple test.

master behavior:
master.webm
(91.36 KiB) Downloaded 29 times


LTNPAutoCorrect3 behavior, independent of the autocorrect setting
LTNPAutoCorrect3.webm
(116.53 KiB) Downloaded 30 times


If the references move while changes, it seems not to work. This is why suggested to reference dimensions while creating to 3D through their 3D coordinates while creating, because 2D references are moving (or better running and through TNP through hlr mutable) objects. I will test tomorrow, when only one reference move, ran out of time now.


tested with

Code: Select all

OS: Debian GNU/Linux 11 (bullseye) (X-Cinnamon/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.21.0.32330 (Git)
Build type: Release
Branch: LTNPAutoCorrect3
Hash: 49f473962287fefdff04578027f126c5dc8adf6b
Python 3.9.2, Qt 5.15.2, Coin 4.0.0, Vtk 9.0.1, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods: 
  * QuickMeasure 2022.10.28
  * CurvedShapes 1.0.4
  * Curves 0.6.6

Greetings
user1234
User avatar
wandererfan
Veteran
Posts: 6270
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Dimension Reference Corruption

Post by wandererfan »

user1234 wrote: Fri Mar 17, 2023 12:06 am If the references move while changes, it seems not to work. This is why suggested to reference dimensions while creating to 3D through their 3D coordinates while creating, because 2D references are moving (or better running and through TNP through hlr mutable) objects. I will test tomorrow, when only one reference move, ran out of time now.
Good catch, thanks. Nothing to do with 2d or 3d in this case.

The code was exiting as soon as the geometry matching failed. What it should be doing is invoking stage 2 of the matching process - that's the clever bit that determines that an edge is still the "top left front" edge even if the edge has changed length or position or whatever. We don't have a stage 2 yet, so the branch has been updated to accept a no exact match condition as a legitimate change to the geometry and not a naming issue.
user1234
Veteran
Posts: 3349
Joined: Mon Jul 11, 2016 5:08 pm

Re: Dimension Reference Corruption

Post by user1234 »

wandererfan wrote: Fri Mar 17, 2023 2:08 pm What it should be doing is invoking stage 2 of the matching process - that's the clever bit that determines that an edge is still the "top left front" edge even if the edge has changed length or position or whatever. We don't have a stage 2 yet, so the branch has been updated to accept a no exact match condition as a legitimate change to the geometry and not a naming issue.
OK, i am too dumb for that. Anyway, i have recompiled it and it works now much better. Even compared to the master, it is now much more stable. But there are still some issues when you change the size.

examples

here i add only fillets, it works (master do not work, so it is an improvement!):
fillets_only.webm
(365.17 KiB) Downloaded 25 times


here i add fillets and change the size, it does not work:
fillets_and_size.webm
(496.84 KiB) Downloaded 28 times



similar here, a cutout, it works when the points (not the line, it is case senitive, make sense here) are selected:
cutout_only.webm
(409.54 KiB) Downloaded 24 times

while a cutout and change the site, does not work:
cutout_and_size.webm
(584.94 KiB) Downloaded 27 times


Anyway, good work, many thanks!

Greetings
user1234

edit: version

Code: Select all

OS: Debian GNU/Linux 11 (bullseye) (X-Cinnamon/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.21.0.32346 (Git)
Build type: Release
Branch: LTNPAutoCorrect3
Hash: 0f1350db998a26865b2f3043a4c2708f21a27521
Python 3.9.2, Qt 5.15.2, Coin 4.0.0, Vtk 9.0.1, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods: 
  * QuickMeasure 2022.10.28
  * CurvedShapes 1.0.4
  * Curves 0.6.8
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: Dimension Reference Corruption

Post by aapo »

I am also very excited by this new feature, and have tested it a little. So far, it seems to work as advertised, and it has a graceful fallback. E.g., if I make a dimension for the fillet height, and remove the fillet afterwards, it seems that all the other dimensions are transformed back into the correct positions, and the "impossible" dimension does not disappear but is moved to some random place, which is completely reasonable and acceptable. I mean, impossible situations are not expected to be solved. :lol: So, everything I've tried with a simple case works very well, congratulations!

For missing geometry I got the following in the report window, which is good information for the user, and I guess that's going to be the starting point for the stage 2 algorithm you're planning.

Code: Select all

20:38:56  DVD::handleNoExactMatch()
20:38:56  Dimension003 - referenced geometry has changed
I'll try to test more complicated models later, but at this point I should say this first stage should probably be merged to the master branch, because this is a very useful and important feature, and the current stage 1 algorithm already makes TD much much more usable for an average user. So, I'd suggest that merge this existing stage 1 version to master fairly soon so that it gets broader testing, after which you'd have time to add the stage 2 with more complicated logic for detecting edge movements, scaling and other more difficult scenarios. I'd assume that this more complicated stage 2 algorithm to handle unknown edges can be later cleanly added to stage 1 simple logic of "exactly the same edge" without any disruption.

Thanks for this, it's going to be a gamechanger for TechDraw! :D


EDIT: Please remember to make "Auto Correct Dimension Refs" activated by default in the Preferences for new users, if it isn't already.

20230317_LTNPAutoCorrect3_test-pic01.png
20230317_LTNPAutoCorrect3_test-pic01.png (122.04 KiB) Viewed 926 times

Code: Select all

OS: Debian GNU/Linux 12 (bookworm) (KDE/plasma)
Word size of FreeCAD: 64-bit
Version: 0.21.0.32343 +3 (Git)
Build type: Release
Branch: LTNPAutoCorrect3
Hash: 0f1350db998a26865b2f3043a4c2708f21a27521
Python 3.11.2, Qt 5.15.8, Coin 4.0.0, Vtk 7.1.1, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods: 
  * Assembly4
  * Render
  * fasteners
  * FCGear
  * Manipulator
  * Curves
  * sheetmetal
User avatar
wandererfan
Veteran
Posts: 6270
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Dimension Reference Corruption

Post by wandererfan »

user1234 wrote: Fri Mar 17, 2023 3:50 pm here i add fillets and change the size, it does not work:
Took me a while to notice that you had turned "keep updated" off while making changes to the model.

If I do the same changes to the model with "keep updated" on, it works.

The script for for your test with commentary:
We set keep updated off.
We add the fillets, which changes the edge name. (A)
We change the constraint, which changes the edge geometry. (B)
We set keep updated on.
The edge geometry does not match the saved geometry - because of (A).
We look for an exact match, which we can not find because of (B).
Edge0 points to the fillet edge at bottom right, which gives a 0.0 horizontal dimension.

At this point we will eventually try to find a edge that is "sufficiently similar" to Edge0.

I'm leaning towards saying stage 1 is working and makes things better, not worse!
user1234
Veteran
Posts: 3349
Joined: Mon Jul 11, 2016 5:08 pm

Re: Dimension Reference Corruption

Post by user1234 »

Sorry for late reply, i was tied up.
wandererfan wrote: Sat Mar 18, 2023 2:13 pm Took me a while to notice that you had turned "keep updated" off while making changes to the model.

If I do the same changes to the model with "keep updated" on, it works.

Yes, this was intended, because of reasons:

- in one change operation, more then one shapes can change; example: like in sketcher, add a fillet in it and change the geometry size and close it, for geometry change it is one step (except auto update in sketcher is activated)

- on very big models and assemblies, normally you switch off recompute automatic, because recomputing consumes time (even when now FreeCAD does not block)

- the drawing (TechDraw Page) can be in an other file then the 3D model, after a reopen it can be changed massively

- similar to the point above, in companies you often work with states and revisions of drawings (and models). When revision a drawing, the models can be different in more then one point


wandererfan wrote: Sat Mar 18, 2023 2:13 pm I'm leaning towards saying stage 1 is working and makes things better, not worse!
Yes, of course! (As i said above, sorry when it was not clear enough, that i really appreciate the changes and work you made, it was just a test, nothing more).


Greetings
user1234
Post Reply