-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Start: create thumbnails using f3d #19489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start: create thumbnails using f3d #19489
Conversation
@andesfreedesign my version of |
@adrianinsaval could you check this out and make sure it does not freeze up your system when it's generating a lot of previews? I'm just using |
31dc7c1
to
943cc17
Compare
It didn't even occur to me that this might work on Windows! Definitely didn't test that. |
@benj5378 what am I supposed to be doing with all these |
Maybe - I had to remove that because on my Ubuntu 22.04 test system the installed version of |
As far as I can tell from https://forum.freecad.org/viewtopic.php?t=65560 and https://github.com/KDE/clazy/blob/master/docs/checks/README-qstring-allocations.md , then the idea behind using However, QString and QLatin1Strnig are different classes, so constructing a QString s = QStringLiteral("foo"); // No allocation
QString s = QLatin1String("foo"); // Allocates, use QStringLiteral("foo") instead
s == QLatin1String("foo") // No allocation
s == QStringLiteral("foo") // No allocation
So what should you do? You get the warning because you construct a |
Sorry, but I was on vacation... |
does |
[
{
"options":
{
"anti-aliasing": true,
"camera-direction": "-1,-0.5,-1",
"hdri-ambient": true,
"max-size":100,
"no-background": true,
"verbose": "quiet",
"tone-mapping": true,
"translucency-support": true
}
}
]
[
{
"match": ".*(step|stp|iges|igs|brep|xbf)",
"options":
{
"scalar-coloring": true,
"load-plugins": "occt",
"up": "+Z",
"ambient-occlusion": true,
"coloring-component": "-2",
"coloring-by-cells": true,
"camera-direction": "-1,1,-0.5"
}
}
] while this is what is used normally:
[
{
"options":
{
"axis": true,
"tone-mapping": true,
"grid": true,
"loading-progress": true,
"anti-aliasing": true,
"filename": true,
"camera-direction": "-1,-0.5,-1",
"hdri-ambient": true,
"translucency-support": true,
"animation-progress": true
}
}
]
[
{
"match": ".*(step|stp|iges|igs|brep|xbf)",
"options":
{
"scalar-coloring": true,
"load-plugins": "occt",
"up": "+Z",
"ambient-occlusion": true,
"coloring-component": "-2",
"coloring-by-cells": true,
"camera-direction": "-1,1,-0.5"
}
}
] we could also consider enabling |
Thanks, @adrianinsaval -- can you add that as a GitHub |
I just tested a 600mb file, freecad doesn't freeze but I eventually get this warning: |
|
what where you testing on before? I don't think we need to support every single feature in 22.04 IMO it's okay to ask for a higher minimum f3d version for this non critical QoL feature. So perhaps it makes sense to have a version check before attempting to run f3d. On the other hand I don't know if the |
I needed the |
OK: the documentation for pre-2.0 releases is pretty sketchy, and it looks like I can write support for 2.x and 3.x, so I will add a bit of code to do a version check, and cut off at 2.0 as the oldest we support. That was only two years ago, but this software is undergoing quite rapid development. |
753f642
to
dccaec5
Compare
@FreeCAD/code-quality-working-group could you please take a look at ThumbnailSource.*? Particularly to make sure I'm thread-safe there, but anything else that catches your eye as well. Thanks! |
dccaec5
to
197aad7
Compare
@pieterhijma your comment about the timeout reminded me that we don't actually properly handle that case, so I've added the code to do so (the timeout doesn't actually kill the process, but the code assumed that after the |
8e5b568
to
34d6363
Compare
|
||
// uint64_t can't express numbers higher than the EB range (< 20 EB) | ||
constexpr std::array units {"B", "kB", "MB", "GB", "TB", "PB", "EB"}; | ||
constexpr double unitFactor = 1000.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FreeCAD is going to show different file size than Windows File Explorer, Gnome Nautilus, MacOS Finder, etc. Is there particular reason for this behaviour?
More about this imlementation in separate #17817 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember this comment? #17817 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how does it answer the above question, so again: why should FreeCAD display different numbers (for sizes up to 1000B numbers would be the same) than each and every file manager ever used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On your question
Is there particular reason for this behaviour?
The comment answers why it was done like that before
I originally went with the 1000 divisor because I personally prefer the MB to MiB etc. -- the MiB always felt overly pedantic to me (and they are awkward to pronounce :) ). But that is pure personal preference, I'm not going to hold this PR up for that.
I don't think anyone would mind much if you like it to be 1024 and still use MB etc. instead - like in Finder etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not what I would like, it is common practice. FreeCAD is just showing different size than everything else. I'm not aware about any software using 1000 base. To make it clear, I would of course like it to be denoted according to IEC 80000-13 (kiB, MiB...), just for a fun of educating users, but using kB for 1024, MB for 1024×1024, etc. as semiconductor memory industry does for ages seems appropriate. The key point is to avoid question like why does FreeCAD shows different file size than my file manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like I'm wrong, sorry.
Finder does use 1000, not 1024 (since 10.8). The same thing applies for all software on mac which uses the foundation framework for converting number of bytes to a string and doesn't explicitly specify to use 1024: https://developer.apple.com/documentation/foundation/bytecountformatter/countstyle (it always uses MB never MiB)
According to IEC 80000-13, MB and KB is valid to use when using 1000 as factor (look at the examples). It does specify that if 1024 is used, it should be named KiB, MiB etc.
By your arguments (follow standard + consistency with os file explorer), I suppose the current version actually is preferred on macOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch! I wasn't aware Apple changed to SI standard in 10.8. Anyway, IEC 80000-13 states in the second paragraph The following referenced documents are indispensable for the application of this document but, duh!, referenced ISO-IEC-2382-16 is no longer valid and I have not purchased current norm.
So indeed, current implementation matches current MacOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.iso.org/standard/7259.html has been replaced by https://www.iso.org/standard/63598.html which is available for free ($0 but need to go though the checkout process) or accessed from the online platform: https://www.iso.org/obp/ui/en/#!iso:std:63598:en
34d6363
to
3abc17e
Compare
Sorry for the delay on this, it turned out that I had an error in the logic about when the new thumbnail signal was emitted. I fixed that, and also added the code to correctly emit the |
@chennes could you take a look at the CI fails? |
3abc17e
to
a35198b
Compare
Hi, F3D maintainers here! Do not hesitate to ping me if you need explanation about our options or our doc :) |
The f3d gallery is pretty impressive! OCCT is in the process of adding support to representing animations in their data structures (Open-Cascade-SAS/OCCT#492), which will eventually feed into being able to export animations via glTF or other formats. I can see further integration of f3d to generate renders of assemblies, exploded parts, and animations. |
^ @FEA-eng @marioalexis84 heads up for FEM animations and @mfasano727 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me.
Just one little thing but I'm nitpicking now: For concurrent code, I would always like to see 1) a motivation for the locking mechanism and 2) a comment on the granularity of the locking. The latter is not in this code, whereas setupF3D()
is only called when a cached thumbnail is not available, therefore limiting the contention on the lock. I think this is interesting to note here (and educational for anyone who takes a look at this code), but if too much trouble, I'm fine with how it is.
@pieterhijma maybe use the "suggestion" feature here to show what you mean, and I can just merge it in? |
I think it is no longer necessary with the presence of the module FreeCAD#19489
Co-authored-by: Pieter Hijma <[email protected]>
This is based on, and a replacement for, #17069 -- it extends the work in that PR to shift the processing into a set of workers running from the
QThreadPool
and returning their data as it arrives.It also adds Start to the C++ test suite, and adds a couple of tests.