-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
"multi-file" file loading API could be moved to F3D application #597
Comments
I've been thinking about this and starting to like the idea, especially in regards to #127. Here is what we could do:
wdyt @snoyer @Meakk @nermolov @SamuelTallet ? |
FYI @GitCodeBoy |
"Multi files mode" option is a good idea! 🙂 |
These points all feel orthogonal to one another. The "folder view" sounds like an alternative way to render/navigate, independently of the multi-file stuff (ie. the folder view could be implemented with the current file loading as an alternative to left/right arrows if I'm undertanding correctly). I think the general multi-file case should be somehow allowing to group filenames instead of treating them individually. Now how to provide options to group files is another question... I'd argue there's a whole lot of cases between viewing "each files individually" and "all files together" Consider the following list of files passed to F3D:
Could we somehow come up with (preferably flexible and user-configurable) mechanism that would let us batch the files as:
Maybe a regular expression, or a simpler glob pattern? |
From libf3d perspective, instead of loader::addGeometry(std::string file)
loader::resetScene()
loader::loadFullScene(std::string file) On the application side, I like @snoyer approach of a glob pattern, maybe something like: |
Indeed, sounds good.
Fair enough
This may work but may also be confusing to users. Does it work in all shells ? |
I don't think we're responsible for user knowledge on shells. We need to provide a solution that makes sense, and we can document it. This is an advanced feature anyway for shell power users. |
To rephrase/elaborate: I'd like to have a grouping function
It would then be irrelevant where the filenames came from (shell expansion or not, drag-and-dropped into the window, ...), adding files incrementally would also be supported. In my previous example just replacing |
dirty python POC using regex capture groups: from collections import defaultdict
import re
filenames = [
'~/3dp/first-simple-object.stl',
'~/3dp/second-simple-object.stl',
'~/3dp/first-complex-object_part1of3.stl',
'~/3dp/first-complex-object_part2of3.stl',
'~/3dp/first-complex-object_part3of3.stl',
'~/3dp/first-complex-object_part1of3.step',
'~/3dp/first-complex-object_part2of3.step',
'~/3dp/first-complex-object_part3of3.step',
'~/3dp/second-complex-object_part1of2.stl',
'~/3dp/second-complex-object_part2of2.stl',
'~/3dp/third-complex-object.1.stl',
'~/3dp/third-complex-object.2.stl',
'~/3d-models/bunny.obj',
'~/3d-models/dragon.ply',
]
patterns = {
'no grouping': r'(.*)',
'by "_part*.ext"': r'(.+)_part.+(\..+)',
'by ".*.ext"': r'(.+?)(?:\..+)*(\..+)',
'by "_part*.ext" and ".*.ext"': r'(.+)_part.+(\..+)|(.+?)(?:\..+)*(\..+)',
'by folder': r'(.+/)*.+',
}
for desc, pattern in patterns.items():
def g(fn):
match = re.match(pattern, fn)
return match.groups() if match else fn
groups = defaultdict(list)
for filename in filenames:
groups[g(filename)].append(filename)
print(f'### {desc} (with pattern `{pattern}`)')
for i,vs in enumerate(groups.values()):
print(f'{i+1}.', ", ".join(f'`{v}`' for v in vs))
print() no grouping (with pattern
|
@snoyer How do you envision that in terms of command lines options ? |
From command line you could do something like But realistically you'd want the Opening each file individually should still be the default, opening all files at once should have a simple argument like I'm not fully clear on all the different use cases so I'm not claiming to have the perfect solution here, but regardless of what the user-facing system ends up being I believe the backend should be able to handle groups of one or more files where it handles individual files currently |
Great, I'll think about it. |
First step here: #634 |
With @Meakk we discussed the future of F3D in regards to loading multiple files, full scene and default scene, which is loosely related to this issue. We will open an issue to track these future changes. In the meantime, I may not implement everything that was discussed here but keep it simple. |
I've added a simple --group-geometries option for now. |
Fix: #597 Fix: #417 New Loader API looks like this: ``` /** * Load a geometry from a provided file to the scene. * Reset the scene before loading if a full scene was loaded previously or if reset is set to false, * do not reset if only loaded geometries previously. * Geometries loader using this method will be available in a default scene and use all default * scene related options. * Throw a load_failure_exception on failure. */ virtual loader& loadGeometry(const std::string& filePath, bool reset = false) = 0; /** * Reset scene and load a full scene from provided file. * Please note default scene related options are not taken into account when loading a full scene. * Throw a load_failure_exception on failure. */ virtual loader& loadScene(const std::string& filePath) = 0; /** * Return true if the loader has a scene reader for the providen file, false otherwise. */ virtual bool hasSceneReader(const std::string& filePath) = 0; /** * Return true if the loader has a geometry reader for the providen file, false otherwise. */ virtual bool hasGeometryReader(const std::string& filePath) = 0; ``` A new command line option has been added to F3D: `"group-geometries", "", "When opening multiple files, show them all in the same scene. Force geometry-only. The configuration file for the first file will be loaded."`
@snoyer @GitCodeBoy Let me know what you think. |
Fix: #597 Fix: #417 New Loader API looks like this: ``` /** * Load a geometry from a provided file to the scene. * Reset the scene before loading if a full scene was loaded previously or if reset is set to false, * do not reset if only loaded geometries previously. * Geometries loader using this method will be available in a default scene and use all default * scene related options. * Throw a load_failure_exception on failure. */ virtual loader& loadGeometry(const std::string& filePath, bool reset = false) = 0; /** * Reset scene and load a full scene from provided file. * Please note default scene related options are not taken into account when loading a full scene. * Throw a load_failure_exception on failure. */ virtual loader& loadScene(const std::string& filePath) = 0; /** * Return true if the loader has a scene reader for the providen file, false otherwise. */ virtual bool hasSceneReader(const std::string& filePath) = 0; /** * Return true if the loader has a geometry reader for the providen file, false otherwise. */ virtual bool hasGeometryReader(const std::string& filePath) = 0; ``` A new command line option has been added to F3D: `"group-geometries", "", "When opening multiple files, show them all in the same scene. Force geometry-only. The configuration file for the first file will be loaded."`
Fix: f3d-app#597 Fix: f3d-app#417 New Loader API looks like this: ``` /** * Load a geometry from a provided file to the scene. * Reset the scene before loading if a full scene was loaded previously or if reset is set to false, * do not reset if only loaded geometries previously. * Geometries loader using this method will be available in a default scene and use all default * scene related options. * Throw a load_failure_exception on failure. */ virtual loader& loadGeometry(const std::string& filePath, bool reset = false) = 0; /** * Reset scene and load a full scene from provided file. * Please note default scene related options are not taken into account when loading a full scene. * Throw a load_failure_exception on failure. */ virtual loader& loadScene(const std::string& filePath) = 0; /** * Return true if the loader has a scene reader for the providen file, false otherwise. */ virtual bool hasSceneReader(const std::string& filePath) = 0; /** * Return true if the loader has a geometry reader for the providen file, false otherwise. */ virtual bool hasGeometryReader(const std::string& filePath) = 0; ``` A new command line option has been added to F3D: `"group-geometries", "", "When opening multiple files, show them all in the same scene. Force geometry-only. The configuration file for the first file will be loaded."`
The multi-file part of the loader API is quite specific to F3D application so it could make sens to move it there and provide a simpler API in libf3d. eg:
The loading API could be reduced to:
The text was updated successfully, but these errors were encountered: