diff --git a/application/F3DStarter.cxx b/application/F3DStarter.cxx index 3356ad6740..a88bdd1a12 100644 --- a/application/F3DStarter.cxx +++ b/application/F3DStarter.cxx @@ -1077,7 +1077,7 @@ void F3DStarter::LoadFileGroup( dynamicOptionsDict, fs::path(), "dynamic options"); // Recover file information - f3d::loader& loader = this->Internals->Engine->getLoader(); + f3d::scene& scene = this->Internals->Engine->getScene(); bool unsupported = false; std::vector localPaths; @@ -1088,7 +1088,7 @@ void F3DStarter::LoadFileGroup( if (clear) { - loader.clear(); + scene.clear(); this->Internals->LoadedFiles.clear(); } @@ -1117,7 +1117,7 @@ void F3DStarter::LoadFileGroup( if (std::find(this->Internals->LoadedFiles.begin(), this->Internals->LoadedFiles.end(), tmpPath) == this->Internals->LoadedFiles.end()) { - if (loader.supports(tmpPath)) + if (scene.supports(tmpPath)) { // Check the size of the file before loading it static constexpr int BYTES_IN_MIB = 1048576; @@ -1143,7 +1143,7 @@ void F3DStarter::LoadFileGroup( if (!localPaths.empty()) { // Add files to the scene - loader.add(localPaths); + scene.add(localPaths); // Update loaded files std::copy( @@ -1151,7 +1151,7 @@ void F3DStarter::LoadFileGroup( } } } - catch (const f3d::loader::load_failure_exception& ex) + catch (const f3d::scene::load_failure_exception& ex) { f3d::log::error("Some of these files could not be loaded: ", ex.what()); for (const fs::path& tmpPath : localPaths) diff --git a/application/F3DStarter.h b/application/F3DStarter.h index f175cf6120..6f1bd17de0 100644 --- a/application/F3DStarter.h +++ b/application/F3DStarter.h @@ -7,16 +7,15 @@ #ifndef F3DStarter_h #define F3DStarter_h -#include "loader.h" - #include #include +#include class F3DStarter { public: /** - * Parse the options and configure a f3d::loader accordingly + * Parse the options and configure a f3d::scene accordingly */ int Start(int argc, char** argv); diff --git a/doc/libf3d/BINDINGS.md b/doc/libf3d/BINDINGS.md index 26ab28a89e..b0432cf2f6 100644 --- a/doc/libf3d/BINDINGS.md +++ b/doc/libf3d/BINDINGS.md @@ -17,7 +17,7 @@ eng.options.update({ "render.grid.enable": True, }) -eng.loader.add("f3d/testing/data/dragon.vtu") +eng.scene.add("f3d/testing/data/dragon.vtu") eng.interactor.start() ``` @@ -40,8 +40,8 @@ public class F3DExample { // Always use try-with-resources idiom to ensure the native engine is released try (Engine engine = new Engine(Window.Type.NATIVE)) { - Loader loader = engine.getLoader(); - loader.add("f3d/testing/data/dragon.vtu"); + Scene scene = engine.getScene(); + scene.add("f3d/testing/data/dragon.vtu"); engine.getWindow().render(); } diff --git a/doc/libf3d/CLASSES.md b/doc/libf3d/CLASSES.md index 1cb39517df..1da14547b5 100644 --- a/doc/libf3d/CLASSES.md +++ b/doc/libf3d/CLASSES.md @@ -5,7 +5,7 @@ For the complete documentation, please consult the [libf3d doxygen documentation ## Engine class -The engine class is the main class that needs to be instantiated. All other classes instance are provided by the engine using getters, `getLoader`, `getWindow`, `getInteractor`, `getOptions`. +The engine class is the main class that needs to be instantiated. All other classes instance are provided by the engine using getters, `getScene`, `getWindow`, `getInteractor`, `getOptions`. The engine constructor lets you choose the type of window in its constructor, `NONE`, `NATIVE`, `NATIVE_OFFSCREEN`, `EXTERNAL`. Default is `NATIVE`. See [Window class](#window-class) documentation for more info. Please note that the engine will not provide a interactor with `NONE` and `EXTERNAL`. @@ -13,10 +13,10 @@ A static function `loadPlugin` can also be called to load reader plugins. It mus If CMake option `F3D_PLUGINS_STATIC_BUILD` is enabled, the plugins listed above are also static just like `native` plugin. All static plugins can be loaded using `f3d::engine::autoloadPlugins()`. -## Loader class +## Scene class -The loader class is responsible to `add` file from the disk into the scene. It supports reading multiple files at the same time and even mesh from memory. -It is possible to `clear` the scene and to check if a file is `supported`. +The scene class is responsible to `add` file from the disk into the scene. It supports reading multiple files at the same time and even mesh from memory. +It is possible to `clear` the scene and to check if the scene `supports` a file. ## Window class diff --git a/doc/libf3d/OVERVIEW.md b/doc/libf3d/OVERVIEW.md index 4f4bcfc74c..12acbd5bcc 100644 --- a/doc/libf3d/OVERVIEW.md +++ b/doc/libf3d/OVERVIEW.md @@ -13,7 +13,7 @@ Rendering a file and starting the interaction is very easy: ```cpp #include #include -#include +#include // Load VTK native readers f3d::engine::autoloadPlugins(); @@ -22,7 +22,7 @@ f3d::engine::autoloadPlugins(); f3d::engine eng(); // Add a file into a scene -eng.getLoader().add("path/to/file.ext"); +eng.getScene().add("path/to/file.ext"); // Start rendering and interacting eng.getInteractor().start(); @@ -33,7 +33,7 @@ As well as loading multiple files: ```cpp #include #include -#include +#include // Load VTK native readers f3d::engine::autoloadPlugins(); @@ -42,7 +42,7 @@ f3d::engine::autoloadPlugins(); f3d::engine eng(); // Load multiples geometries -eng.getLoader().add({"path/to/file.ext", "path/to/file2.ext"}); +eng.getScene().add({"path/to/file.ext", "path/to/file2.ext"}); // Start rendering and interacting eng.getInteractor().start(); @@ -53,7 +53,7 @@ It's also possible to load a geometry from memory buffers: ```cpp #include #include -#include +#include // Create a f3d::engine f3d::engine eng(); @@ -63,7 +63,7 @@ f3d::mesh_t mesh = {}; mesh.points = { 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, 0.f, 0.f }; mesh.face_sides = { 3 }; mesh.face_indices = { 0, 1, 2 }; -eng.getLoader().add(mesh); +eng.getScene().add(mesh); // Start rendering and interacting eng.getInteractor().start(); @@ -74,7 +74,7 @@ Manipulating the window directly can be done this way: ```cpp #include #include -#include +#include #include // Load VTK native readers @@ -84,7 +84,7 @@ f3d::engine::autoloadPlugins(); f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); // Load a geometry -eng.getLoader().add("path/to/file.ext"); +eng.getScene().add("path/to/file.ext"); // Set the window size and render to an image f3d::image img = eng.getWindow().setSize(300, 300).renderToImage(); @@ -99,7 +99,7 @@ Changing some options can be done this way: #include #include #include -#include +#include // Load VTK native readers f3d::engine::autoloadPlugins(); @@ -113,7 +113,7 @@ opt.render.effect.ambient_occlusion = true; opt.render.effect.anti_aliasing = true; // Standard libf3d usage -eng.getLoader().add("path/to/file.ext"); +eng.getScene().add("path/to/file.ext"); eng.getInteractor().start(); ``` Most options are dynamic, some are only taken into account when loading a file. See the [options](OPTIONS.md) documentation. diff --git a/examples/libf3d/cpp/CMakeLists.txt b/examples/libf3d/cpp/CMakeLists.txt index 611d0e12a7..73133952db 100644 --- a/examples/libf3d/cpp/CMakeLists.txt +++ b/examples/libf3d/cpp/CMakeLists.txt @@ -5,7 +5,7 @@ if(BUILD_TESTING) endif() add_subdirectory(check-engine) -add_subdirectory(multi-geom) +add_subdirectory(multi-files) add_subdirectory(render-image) add_subdirectory(render-interact) add_subdirectory(use-options-string) diff --git a/examples/libf3d/cpp/check-engine/main.cxx b/examples/libf3d/cpp/check-engine/main.cxx index e0dca3a6ff..821bbc58f4 100644 --- a/examples/libf3d/cpp/check-engine/main.cxx +++ b/examples/libf3d/cpp/check-engine/main.cxx @@ -4,9 +4,9 @@ #include #include #include -#include #include #include +#include #include #include diff --git a/examples/libf3d/cpp/multi-files/CMakeLists.txt b/examples/libf3d/cpp/multi-files/CMakeLists.txt new file mode 100644 index 0000000000..97158b5b4d --- /dev/null +++ b/examples/libf3d/cpp/multi-files/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.5) + +project(multi-files) + +find_package(f3d REQUIRED COMPONENTS library) + +add_executable(multi-files main.cxx) +target_link_libraries(multi-files f3d::libf3d) +set_target_properties(multi-files PROPERTIES CXX_STANDARD 17) + +if(UNIX AND NOT APPLE) + target_link_libraries(multi-files stdc++fs) +endif() + +# Simple testing +if(BUILD_TESTING) + enable_testing() + add_test(NAME test_multi-files COMMAND "$" "${CMAKE_CURRENT_SOURCE_DIR}/data/") + set_tests_properties(test_multi-files PROPERTIES + PASS_REGULAR_EXPRESSION "Scene bounding box: -0.487464,1,-0.487464,1,-0.5,1") +endif() diff --git a/examples/libf3d/cpp/multi-geom/data/mb_0_0.vtu b/examples/libf3d/cpp/multi-files/data/mb_0_0.vtu similarity index 100% rename from examples/libf3d/cpp/multi-geom/data/mb_0_0.vtu rename to examples/libf3d/cpp/multi-files/data/mb_0_0.vtu diff --git a/examples/libf3d/cpp/multi-geom/data/mb_1_0.vtp b/examples/libf3d/cpp/multi-files/data/mb_1_0.vtp similarity index 100% rename from examples/libf3d/cpp/multi-geom/data/mb_1_0.vtp rename to examples/libf3d/cpp/multi-files/data/mb_1_0.vtp diff --git a/examples/libf3d/cpp/multi-geom/data/mb_2_0.vtp b/examples/libf3d/cpp/multi-files/data/mb_2_0.vtp similarity index 100% rename from examples/libf3d/cpp/multi-geom/data/mb_2_0.vtp rename to examples/libf3d/cpp/multi-files/data/mb_2_0.vtp diff --git a/examples/libf3d/cpp/multi-geom/main.cxx b/examples/libf3d/cpp/multi-files/main.cxx similarity index 86% rename from examples/libf3d/cpp/multi-geom/main.cxx rename to examples/libf3d/cpp/multi-files/main.cxx index 8d783a5141..c83601ca11 100644 --- a/examples/libf3d/cpp/multi-geom/main.cxx +++ b/examples/libf3d/cpp/multi-files/main.cxx @@ -22,11 +22,11 @@ int main(int argc, char** argv) // Create a native window engine f3d::engine eng(f3d::window::Type::NATIVE); - // Load all files from provided directory as geometries - f3d::loader& load = eng.getLoader(); + // Add all files from provided directory + f3d::scene& sce = eng.getScene(); for (auto& entry : std::filesystem::directory_iterator(argv[1])) { - load.add(entry.path().string()); + sce.add(entry.path().string()); } // Render diff --git a/examples/libf3d/cpp/multi-geom/CMakeLists.txt b/examples/libf3d/cpp/multi-geom/CMakeLists.txt deleted file mode 100644 index 16920a15ee..0000000000 --- a/examples/libf3d/cpp/multi-geom/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project(multi-geom) - -find_package(f3d REQUIRED COMPONENTS library) - -add_executable(multi-geom main.cxx) -target_link_libraries(multi-geom f3d::libf3d) -set_target_properties(multi-geom PROPERTIES CXX_STANDARD 17) - -if(UNIX AND NOT APPLE) - target_link_libraries(multi-geom stdc++fs) -endif() - -# Simple testing -if(BUILD_TESTING) - enable_testing() - add_test(NAME test_multi-geom COMMAND "$" "${CMAKE_CURRENT_SOURCE_DIR}/data/") - set_tests_properties(test_multi-geom PROPERTIES - PASS_REGULAR_EXPRESSION "Scene bounding box: -0.487464,1,-0.487464,1,-0.5,1") -endif() diff --git a/examples/libf3d/cpp/render-image/main.cxx b/examples/libf3d/cpp/render-image/main.cxx index 2ea1939e96..c81beb8b44 100644 --- a/examples/libf3d/cpp/render-image/main.cxx +++ b/examples/libf3d/cpp/render-image/main.cxx @@ -21,8 +21,8 @@ int main(int argc, char** argv) // Create a offscreen window engine f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - // Load a model - eng.getLoader().add(std::string(argv[1])); + // add a model + eng.getScene().add(std::string(argv[1])); // Set the window size and render to an image f3d::image img = eng.getWindow().setSize(300, 300).renderToImage(); diff --git a/examples/libf3d/cpp/render-interact/main.cxx b/examples/libf3d/cpp/render-interact/main.cxx index 09fe31ad84..39e859f5ec 100644 --- a/examples/libf3d/cpp/render-interact/main.cxx +++ b/examples/libf3d/cpp/render-interact/main.cxx @@ -20,8 +20,8 @@ int main(int argc, char** argv) // Create a native window engine f3d::engine eng(f3d::window::Type::NATIVE); - // Load a model - const f3d::loader& load = eng.getLoader().add(std::string(argv[1])); + // add a model + eng.getScene().add(std::string(argv[1])); // Render f3d::window& win = eng.getWindow(); diff --git a/examples/libf3d/cpp/use-options-string/main.cxx b/examples/libf3d/cpp/use-options-string/main.cxx index ef2fa71d07..3a881742ae 100644 --- a/examples/libf3d/cpp/use-options-string/main.cxx +++ b/examples/libf3d/cpp/use-options-string/main.cxx @@ -27,8 +27,8 @@ int main(int argc, char** argv) .setAsString("render.line_width", "10") .setAsString("render.grid.enable", "1"); - // Load a model - const f3d::loader& load = eng.getLoader().add(std::string(argv[1])); + // add a model + const f3d::scene& sce = eng.getScene().add(std::string(argv[1])); // Render f3d::window& win = eng.getWindow(); diff --git a/examples/libf3d/cpp/use-options-struct/main.cxx b/examples/libf3d/cpp/use-options-struct/main.cxx index 894ac94f09..a715b8789f 100644 --- a/examples/libf3d/cpp/use-options-struct/main.cxx +++ b/examples/libf3d/cpp/use-options-struct/main.cxx @@ -27,8 +27,8 @@ int main(int argc, char** argv) opt.render.line_width = 10; opt.render.grid.enable = true; - // Load a model - const f3d::loader& load = eng.getLoader().add(std::string(argv[1])); + // Add a model + eng.getScene().add(std::string(argv[1])); // Render f3d::window& win = eng.getWindow(); diff --git a/examples/libf3d/cpp/use-options-variant/main.cxx b/examples/libf3d/cpp/use-options-variant/main.cxx index dad4bc01c9..c6caa9ec73 100644 --- a/examples/libf3d/cpp/use-options-variant/main.cxx +++ b/examples/libf3d/cpp/use-options-variant/main.cxx @@ -25,8 +25,8 @@ int main(int argc, char** argv) f3d::options& opt = eng.getOptions(); opt.set("render.show_edges", true).set("render.line_width", 10.0).set("render.grid.enable", true); - // Load a model - const f3d::loader& load = eng.getLoader().add(std::string(argv[1])); + // ad a model + const f3d::scene& sce = eng.getScene().add(std::string(argv[1])); // Render f3d::window& win = eng.getWindow(); diff --git a/examples/libf3d/python/multi-geom/multi_geom.py b/examples/libf3d/python/multi-files/multi_files.py similarity index 92% rename from examples/libf3d/python/multi-geom/multi_geom.py rename to examples/libf3d/python/multi-files/multi_files.py index ba66e8305b..058a9b55e4 100644 --- a/examples/libf3d/python/multi-geom/multi_geom.py +++ b/examples/libf3d/python/multi-files/multi_files.py @@ -16,7 +16,7 @@ files = [f for f in Path(sys.argv[1]).iterdir() if f.is_file()] for file in files: try: - eng.loader.load_geometry(str(file)) + eng.scene.add(str(file)) except RuntimeError as e: print(e) diff --git a/examples/libf3d/python/render-image/render_image.py b/examples/libf3d/python/render-image/render_image.py index c37abbd61a..08ad50c5a3 100644 --- a/examples/libf3d/python/render-image/render_image.py +++ b/examples/libf3d/python/render-image/render_image.py @@ -9,7 +9,7 @@ f3d.Engine.autoload_plugins() eng = f3d.Engine(f3d.Window.NATIVE_OFFSCREEN) - eng.loader.load_geometry(sys.argv[1]) + eng.scene.add(sys.argv[1]) eng.window.size = 300, 300 img = eng.window.render_to_image() diff --git a/examples/libf3d/python/render-interact/render_interact.py b/examples/libf3d/python/render-interact/render_interact.py index b5fcf1d908..0f6ba065da 100644 --- a/examples/libf3d/python/render-interact/render_interact.py +++ b/examples/libf3d/python/render-interact/render_interact.py @@ -11,9 +11,9 @@ # Create a native window engine eng = f3d.Engine(f3d.Window.NATIVE) - # Load a model + # Add a model try: - eng.loader.load_geometry(sys.argv[1]) + eng.scene.add(sys.argv[1]) except RuntimeError as e: print(e) diff --git a/examples/libf3d/python/render-terminal/render_terminal.py b/examples/libf3d/python/render-terminal/render_terminal.py index f420b3af63..4627a6f767 100644 --- a/examples/libf3d/python/render-terminal/render_terminal.py +++ b/examples/libf3d/python/render-terminal/render_terminal.py @@ -30,7 +30,7 @@ def main(): # setup engine engine = f3d.Engine(f3d.Window.NATIVE_OFFSCREEN) engine.options.update(options) - engine.loader.load_geometry(str(model_path)) + engine.scene.add(str(model_path)) engine.window.size = rows, cols * 2 # fit view to loaded model and grab computed camera position diff --git a/examples/libf3d/python/tkinter/minimal_tkinter.py b/examples/libf3d/python/tkinter/minimal_tkinter.py index 6bfa534320..a2ae8099a0 100644 --- a/examples/libf3d/python/tkinter/minimal_tkinter.py +++ b/examples/libf3d/python/tkinter/minimal_tkinter.py @@ -13,7 +13,7 @@ def __init__(self): # Initialize F3D def initgl(self): self.engine = f3d.Engine(f3d.Window.Type.EXTERNAL) - self.engine.loader.load_geometry( + self.engine.scene.add( f3d.Mesh( points=[0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0], face_sides=[3], diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index db4d47805d..918e02c546 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -11,8 +11,8 @@ endif() set(F3D_JAVA_SOURCES Camera.java Engine.java - Loader.java Options.java + Scene.java Window.java) # Generate JNI headers, and builds a JAR package diff --git a/java/Engine.java b/java/Engine.java index d634ca7334..318786d9cb 100644 --- a/java/Engine.java +++ b/java/Engine.java @@ -8,7 +8,7 @@ public class Engine implements AutoCloseable { public Engine() { mNativeAddress = construct(); // instantiate the native engine - mLoader = new Loader(mNativeAddress); + mScene = new Scene(mNativeAddress); mOptions = new Options(mNativeAddress); mWindow = new Window(mNativeAddress); } @@ -26,14 +26,14 @@ public void close() { static public native void loadPlugin(String plugin); static public native void autoloadPlugins(); - public Loader getLoader() { return mLoader; } + public Scene getScene() { return mScene; } public Options getOptions() { return mOptions; } public Window getWindow() { return mWindow; } private native long construct(); private native void destroy(long nativeAddress); - private Loader mLoader; + private Scene mScene; private Options mOptions; private Window mWindow; diff --git a/java/F3DJavaBindings.cxx b/java/F3DJavaBindings.cxx index ae6bfdb599..40c13723e8 100644 --- a/java/F3DJavaBindings.cxx +++ b/java/F3DJavaBindings.cxx @@ -1,7 +1,7 @@ // Automatically generated headers #include #include -#include +#include #include #include @@ -54,16 +54,16 @@ extern "C" delete reinterpret_cast(ptr); } - // Loader - JNIEXPORT void JAVA_BIND(Loader, add)(JNIEnv* env, jobject self, jstring path) + // Scene + JNIEXPORT void JAVA_BIND(Scene, add)(JNIEnv* env, jobject self, jstring path) { const char* str = env->GetStringUTFChars(path, nullptr); - GetEngine(env, self)->getLoader().add(str); + GetEngine(env, self)->getScene().add(str); env->ReleaseStringUTFChars(path, str); } - JNIEXPORT void JAVA_BIND(Loader, clear)(JNIEnv* env, jobject self) + JNIEXPORT void JAVA_BIND(Scene, clear)(JNIEnv* env, jobject self) { - GetEngine(env, self)->getLoader().clear(); + GetEngine(env, self)->getScene().clear(); } // Window diff --git a/java/Loader.java b/java/Scene.java similarity index 74% rename from java/Loader.java rename to java/Scene.java index 1566d7f0bd..c04fb02de9 100644 --- a/java/Loader.java +++ b/java/Scene.java @@ -1,8 +1,8 @@ package app.f3d.F3D; -public class Loader { +public class Scene { - public Loader(long nativeAddress) { + public Scene(long nativeAddress) { mNativeAddress = nativeAddress; } diff --git a/java/testing/TestJavaBindings.java b/java/testing/TestJavaBindings.java index 4f7d381c1a..57493f5eb2 100644 --- a/java/testing/TestJavaBindings.java +++ b/java/testing/TestJavaBindings.java @@ -28,8 +28,8 @@ public static void main(String[] args) { assert pos[1] == 1.0 : "Position Y is not valid"; assert pos[2] == 2.0 : "Position Z is not valid"; - Loader loader = engine.getLoader(); - loader.add(args[0] + "data/cow.vtp"); + Scene scene = engine.getScene(); + scene.add(args[0] + "data/cow.vtp"); } } } diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index ff1dd1a93a..18f6652204 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -54,9 +54,9 @@ set(F3D_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/interactor.cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/interactor_impl.cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/levenshtein.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/src/loader_impl.cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/log.cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/options.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/src/scene_impl.cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/types.cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/utils.cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/window_impl.cxx @@ -73,8 +73,8 @@ set(F3D_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/public/exception.h ${CMAKE_CURRENT_SOURCE_DIR}/public/image.h ${CMAKE_CURRENT_SOURCE_DIR}/public/interactor.h - ${CMAKE_CURRENT_SOURCE_DIR}/public/loader.h ${CMAKE_CURRENT_SOURCE_DIR}/public/log.h + ${CMAKE_CURRENT_SOURCE_DIR}/public/scene.h ${CMAKE_CURRENT_SOURCE_DIR}/public/types.h ${CMAKE_CURRENT_SOURCE_DIR}/public/utils.h ${CMAKE_CURRENT_SOURCE_DIR}/public/window.h diff --git a/library/private/interactor_impl.h b/library/private/interactor_impl.h index 21833578b7..fc4c47361c 100644 --- a/library/private/interactor_impl.h +++ b/library/private/interactor_impl.h @@ -21,7 +21,7 @@ class options; namespace detail { -class loader_impl; +class scene_impl; class window_impl; class animationManager; @@ -32,7 +32,7 @@ class interactor_impl : public interactor /** * Documented public API */ - interactor_impl(options& options, window_impl& window, loader_impl& loader); + interactor_impl(options& options, window_impl& window, scene_impl& scene); ~interactor_impl() override; interactor& setKeyPressCallBack(std::function callBack) override; @@ -71,7 +71,7 @@ class interactor_impl : public interactor /** * Implementation only API. * Initialize the animation manager using interactor objects. - * This is called by the loader after loading a file. + * This is called by the scene after add a file. */ void InitializeAnimation(vtkImporter* importer); diff --git a/library/private/loader_impl.h b/library/private/loader_impl.h deleted file mode 100644 index 94695bc68e..0000000000 --- a/library/private/loader_impl.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @class loader_impl - * @brief A concrete implementation of loader - * - * A concrete implementation of loader that hides the private API - * See loader.h for the class documentation - */ - -#ifndef f3d_loader_impl_h -#define f3d_loader_impl_h - -#include "loader.h" - -#include - -namespace f3d -{ -class options; - -namespace detail -{ -class interactor_impl; -class window_impl; -class loader_impl : public loader -{ -public: - ///@{ - /** - * Documented public API - */ - loader_impl(const options& options, window_impl& window); - ~loader_impl(); - loader& add(const std::filesystem::path& filePath) override; - loader& add(const std::vector& filePath) override; - loader& add(const std::vector& filePathStrings) override; - loader& add(const mesh_t& mesh) override; - loader& clear() override; - bool supports(const std::filesystem::path& filePath) override; - ///@} - - /** - * Implementation only API. - * Set the interactor to use when interacting and set the AnimationManager on the interactor. - */ - void SetInteractor(interactor_impl* interactor); - -private: - class internals; - std::unique_ptr Internals; -}; -} -} - -#endif diff --git a/library/private/scene_impl.h b/library/private/scene_impl.h new file mode 100644 index 0000000000..496ab33193 --- /dev/null +++ b/library/private/scene_impl.h @@ -0,0 +1,54 @@ +/** + * @class scene_impl + * @brief A concrete implementation of scene + * + * A concrete implementation of scene that hides the private API + * See scene.h for the class documentation + */ + +#ifndef f3d_scene_impl_h +#define f3d_scene_impl_h + +#include "scene.h" + +#include + +namespace f3d +{ +class options; + +namespace detail +{ +class interactor_impl; +class window_impl; +class scene_impl : public scene +{ +public: + ///@{ + /** + * Documented public API + */ + scene_impl(const options& options, window_impl& window); + ~scene_impl(); + scene& add(const std::filesystem::path& filePath) override; + scene& add(const std::vector& filePath) override; + scene& add(const std::vector& filePathStrings) override; + scene& add(const mesh_t& mesh) override; + scene& clear() override; + bool supports(const std::filesystem::path& filePath) override; + ///@} + + /** + * Implementation only API. + * Set the interactor to use when interacting and set the AnimationManager on the interactor. + */ + void SetInteractor(interactor_impl* interactor); + +private: + class internals; + std::unique_ptr Internals; +}; +} +} + +#endif diff --git a/library/private/window_impl.h b/library/private/window_impl.h index 0f62a41187..d941c4cf10 100644 --- a/library/private/window_impl.h +++ b/library/private/window_impl.h @@ -78,9 +78,8 @@ class window_impl : public window * Implementation only API. * Use all the rendering related options to update the configuration of the window * and the rendering stack below. - * This will be called automatically when calling loader::loadFile but can also be called manually - * when needed. This must be called, either manually or automatically, before any render call. - * Return true on success, false otherwise. + * This is called automatically when calling scene::add and window::render but can also be called + * manually when needed. Return true on success, false otherwise. */ void UpdateDynamicOptions(); diff --git a/library/public/engine.h b/library/public/engine.h index db486c065a..de385bf01d 100644 --- a/library/public/engine.h +++ b/library/public/engine.h @@ -4,8 +4,8 @@ #include "exception.h" #include "export.h" #include "interactor.h" -#include "loader.h" #include "options.h" +#include "scene.h" #include "window.h" #include @@ -26,8 +26,8 @@ namespace f3d * * \code{.cpp} * f3d::engine eng(); - * f3d::loader& load = eng.getLoader(); - * load.add({"path/to/file", "path/to/another/file"}); + * f3d::scene& sce = eng.getscene(); + * sce.add({"path/to/file", "path/to/another/file"}); * f3d::interactor& inter = eng.getInteractor(); * inter.start(); * \endcode @@ -90,7 +90,7 @@ class F3D_EXPORT engine /** * Get the loaded provided by the engine. */ - loader& getLoader(); + scene& getScene(); /** * Get the interactor provided by the engine, if any. diff --git a/library/public/interactor.h b/library/public/interactor.h index 5c8498bdd9..8a9e2bf53d 100644 --- a/library/public/interactor.h +++ b/library/public/interactor.h @@ -2,7 +2,6 @@ #define f3d_interactor_h #include "export.h" -#include "loader.h" #include "options.h" #include "window.h" diff --git a/library/public/loader.h b/library/public/scene.h similarity index 53% rename from library/public/loader.h rename to library/public/scene.h index 2f7f74cf1c..9eebb3af8a 100644 --- a/library/public/loader.h +++ b/library/public/scene.h @@ -1,5 +1,5 @@ -#ifndef f3d_loader_h -#define f3d_loader_h +#ifndef f3d_scene_h +#define f3d_scene_h #include "exception.h" #include "export.h" @@ -12,18 +12,16 @@ namespace f3d { /** - * @class loader - * @brief Class to load files in F3D + * @class scene + * @brief Class to load files into * - * A class to load files in F3D. The loader can load a full scene or multiple geometries into a - * default scene. It also support checking if a scene or geometry reader is available for a given - * file. + * The scene where files and meshes can be added and loaded into. * * Example usage: * \code{.cpp} * std::string path = ... * f3d::engine eng(f3d::window::Type::NATIVE); - * f3d::loader& load = eng.getLoader(); + * f3d::scene& load = eng.getScene(); * * if (load.supports(path) * { @@ -32,11 +30,11 @@ namespace f3d * \endcode * */ -class F3D_EXPORT loader +class F3D_EXPORT scene { public: /** - * An exception that can be thrown by the loader + * An exception that can be thrown by the scene * when it failed to load a file for some reason. */ struct load_failure_exception : public exception @@ -50,25 +48,25 @@ class F3D_EXPORT loader * Add and load provided files into the scene * Already added file will NOT be reloaded */ - virtual loader& add(const std::filesystem::path& filePath) = 0; - virtual loader& add(const std::vector& filePath) = 0; - virtual loader& add(const std::vector& filePathStrings) = 0; + virtual scene& add(const std::filesystem::path& filePath) = 0; + virtual scene& add(const std::vector& filePath) = 0; + virtual scene& add(const std::vector& filePathStrings) = 0; ///@} /** * Add and load provided mesh into the scene */ - virtual loader& add(const mesh_t& mesh) = 0; + virtual scene& add(const mesh_t& mesh) = 0; ///@{ /** * Convenience initializer list signature for add method */ - loader& add(std::initializer_list list) + scene& add(std::initializer_list list) { return this->add(std::vector(list)); } - loader& add(std::initializer_list list) + scene& add(std::initializer_list list) { return this->add(std::vector(list)); } @@ -77,7 +75,7 @@ class F3D_EXPORT loader /** * Clear the scene of all added files */ - virtual loader& clear() = 0; + virtual scene& clear() = 0; /** * Return true if provided file path is supported, false otherwise. @@ -86,12 +84,12 @@ class F3D_EXPORT loader protected: //! @cond - loader() = default; - virtual ~loader() = default; - loader(const loader& opt) = delete; - loader(loader&& opt) = delete; - loader& operator=(const loader& opt) = delete; - loader& operator=(loader&& opt) = delete; + scene() = default; + virtual ~scene() = default; + scene(const scene& opt) = delete; + scene(scene&& opt) = delete; + scene& operator=(const scene& opt) = delete; + scene& operator=(scene&& opt) = delete; //! @endcond }; } diff --git a/library/src/engine.cxx b/library/src/engine.cxx index da76189c82..e549b16fed 100644 --- a/library/src/engine.cxx +++ b/library/src/engine.cxx @@ -3,8 +3,8 @@ #include "config.h" #include "init.h" #include "interactor_impl.h" -#include "loader_impl.h" #include "log.h" +#include "scene_impl.h" #include "window_impl.h" #include "factory.h" @@ -28,7 +28,7 @@ class engine::internals public: std::unique_ptr Options; std::unique_ptr Window; - std::unique_ptr Loader; + std::unique_ptr Scene; std::unique_ptr Interactor; }; @@ -61,14 +61,14 @@ engine::engine(window::Type windowType) std::make_unique(*this->Internals->Options, windowType); this->Internals->Window->SetCachePath(cachePath); - this->Internals->Loader = - std::make_unique(*this->Internals->Options, *this->Internals->Window); + this->Internals->Scene = + std::make_unique(*this->Internals->Options, *this->Internals->Window); // Do not create an interactor for NONE or EXTERNAL if (windowType != window::Type::NONE && windowType != window::Type::EXTERNAL) { this->Internals->Interactor = std::make_unique( - *this->Internals->Options, *this->Internals->Window, *this->Internals->Loader); + *this->Internals->Options, *this->Internals->Window, *this->Internals->Scene); } } @@ -109,9 +109,9 @@ window& engine::getWindow() } //---------------------------------------------------------------------------- -loader& engine::getLoader() +scene& engine::getScene() { - return *this->Internals->Loader; + return *this->Internals->Scene; } //---------------------------------------------------------------------------- diff --git a/library/src/interactor_impl.cxx b/library/src/interactor_impl.cxx index 2b66f47757..ce9dbf1dfb 100644 --- a/library/src/interactor_impl.cxx +++ b/library/src/interactor_impl.cxx @@ -1,8 +1,8 @@ #include "interactor_impl.h" #include "animationManager.h" -#include "loader_impl.h" #include "log.h" +#include "scene_impl.h" #include "window_impl.h" #include "vtkF3DConfigure.h" @@ -35,10 +35,10 @@ namespace f3d::detail class interactor_impl::internals { public: - internals(options& options, window_impl& window, loader_impl& loader) + internals(options& options, window_impl& window, scene_impl& scene) : Options(options) , Window(window) - , Loader(loader) + , Scene(scene) { #ifdef __EMSCRIPTEN__ vtkRenderWindowInteractor::InteractorManagesTheEventLoop = false; @@ -400,7 +400,7 @@ class interactor_impl::internals { assert(self->AnimationManager); self->AnimationManager->StopAnimation(); - self->Loader.add(filesVec); + self->Scene.add(filesVec); self->Window.render(); } } @@ -543,7 +543,7 @@ class interactor_impl::internals options& Options; window_impl& Window; - loader_impl& Loader; + scene_impl& Scene; animationManager* AnimationManager; vtkNew VTKInteractor; @@ -561,11 +561,11 @@ class interactor_impl::internals }; //---------------------------------------------------------------------------- -interactor_impl::interactor_impl(options& options, window_impl& window, loader_impl& loader) - : Internals(std::make_unique(options, window, loader)) +interactor_impl::interactor_impl(options& options, window_impl& window, scene_impl& scene) + : Internals(std::make_unique(options, window, scene)) { - // Loader need the interactor, loader will set the AnimationManager on the interactor - this->Internals->Loader.SetInteractor(this); + // scene need the interactor, scene will set the AnimationManager on the interactor + this->Internals->Scene.SetInteractor(this); } //---------------------------------------------------------------------------- diff --git a/library/src/loader_impl.cxx b/library/src/scene_impl.cxx similarity index 89% rename from library/src/loader_impl.cxx rename to library/src/scene_impl.cxx index 979737ceea..c0fde20fac 100644 --- a/library/src/loader_impl.cxx +++ b/library/src/scene_impl.cxx @@ -1,4 +1,4 @@ -#include "loader_impl.h" +#include "scene_impl.h" #include "animationManager.h" #include "interactor_impl.h" @@ -26,7 +26,7 @@ namespace fs = std::filesystem; namespace f3d::detail { -class loader_impl::internals +class scene_impl::internals { public: internals(const options& options, window_impl& window) @@ -105,12 +105,12 @@ class loader_impl::internals // Manage progress bar vtkNew progressWidget; vtkNew timer; - loader_impl::internals::ProgressDataStruct callbackData; + scene_impl::internals::ProgressDataStruct callbackData; callbackData.timer = timer; callbackData.widget = progressWidget; if (this->Options.ui.loader_progress && this->Interactor) { - loader_impl::internals::CreateProgressRepresentationAndCallback( + scene_impl::internals::CreateProgressRepresentationAndCallback( &callbackData, this->MetaImporter, this->Interactor); } @@ -118,7 +118,7 @@ class loader_impl::internals #if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240707) if (!this->MetaImporter->Update()) { - throw loader::load_failure_exception("failed to load scene"); + throw scene::load_failure_exception("failed to load scene"); } #else this->MetaImporter->Update(); @@ -149,7 +149,7 @@ class loader_impl::internals this->Window.setAnimationNameInfo(this->AnimationManager.GetAnimationName()); // Display output description - loader_impl::internals::DisplayImporterDescription(this->MetaImporter); + scene_impl::internals::DisplayImporterDescription(this->MetaImporter); // Update all window options and reset camera to bounds if needed this->Window.UpdateDynamicOptions(); @@ -191,23 +191,23 @@ class loader_impl::internals }; //---------------------------------------------------------------------------- -loader_impl::loader_impl(const options& options, window_impl& window) - : Internals(std::make_unique(options, window)) +scene_impl::scene_impl(const options& options, window_impl& window) + : Internals(std::make_unique(options, window)) { } //---------------------------------------------------------------------------- -loader_impl::~loader_impl() = default; +scene_impl::~scene_impl() = default; //---------------------------------------------------------------------------- -loader& loader_impl::add(const fs::path& filePath) +scene& scene_impl::add(const fs::path& filePath) { std::vector paths = { filePath }; return this->add(paths); } //---------------------------------------------------------------------------- -loader& loader_impl::add(const std::vector& filePathStrings) +scene& scene_impl::add(const std::vector& filePathStrings) { std::vector paths; paths.reserve(filePathStrings.size()); @@ -219,7 +219,7 @@ loader& loader_impl::add(const std::vector& filePathStrings) } //---------------------------------------------------------------------------- -loader& loader_impl::add(const std::vector& filePaths) +scene& scene_impl::add(const std::vector& filePaths) { if (filePaths.empty()) { @@ -237,7 +237,7 @@ loader& loader_impl::add(const std::vector& filePaths) } if (!vtksys::SystemTools::FileExists(filePath.string(), true)) { - throw loader::load_failure_exception(filePath.string() + " does not exists"); + throw scene::load_failure_exception(filePath.string() + " does not exists"); } // Recover the importer for the provided file path @@ -249,7 +249,7 @@ loader& loader_impl::add(const std::vector& filePaths) } else { - throw loader::load_failure_exception( + throw scene::load_failure_exception( filePath.string() + " is not a file of a supported 3D scene file format"); } vtkSmartPointer importer = reader->createSceneReader(filePath.string()); @@ -286,13 +286,13 @@ loader& loader_impl::add(const std::vector& filePaths) } //---------------------------------------------------------------------------- -loader& loader_impl::add(const mesh_t& mesh) +scene& scene_impl::add(const mesh_t& mesh) { // sanity checks auto [valid, err] = mesh.isValid(); if (!valid) { - throw loader::load_failure_exception(err); + throw scene::load_failure_exception(err); } vtkNew vtkSource; @@ -310,7 +310,7 @@ loader& loader_impl::add(const mesh_t& mesh) } //---------------------------------------------------------------------------- -loader& loader_impl::clear() +scene& scene_impl::clear() { // Clear the meta importer from all importers this->Internals->MetaImporter->Clear(); @@ -322,13 +322,13 @@ loader& loader_impl::clear() } //---------------------------------------------------------------------------- -bool loader_impl::supports(const fs::path& filePath) +bool scene_impl::supports(const fs::path& filePath) { return f3d::factory::instance()->getReader(filePath.string()) != nullptr; } //---------------------------------------------------------------------------- -void loader_impl::SetInteractor(interactor_impl* interactor) +void scene_impl::SetInteractor(interactor_impl* interactor) { this->Internals->Interactor = interactor; this->Internals->AnimationManager.SetInteractor(interactor); diff --git a/library/testing/CMakeLists.txt b/library/testing/CMakeLists.txt index fc39047335..1bf3980518 100644 --- a/library/testing/CMakeLists.txt +++ b/library/testing/CMakeLists.txt @@ -12,8 +12,8 @@ list(APPEND libf3dSDKTests_list TestSDKImage.cxx TestSDKInteractorCallBack.cxx TestSDKInteractorDropFullScene.cxx - TestSDKLoadFromMemory.cxx - TestSDKLoader.cxx + TestSDKSceneFromMemory.cxx + TestSDKScene.cxx TestSDKLog.cxx TestSDKMultiColoring.cxx TestSDKMultiOptions.cxx @@ -32,11 +32,11 @@ if(VTK_VERSION VERSION_GREATER_EQUAL 9.2.20221220) ) endif() -# Invalid loader codepath needs https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11287 -# Merge with TestSDKLoader.cxx when VTK 9.4.0 is required. +# Invalid scene codepath needs https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11287 +# Merge with TestSDKScene.cxx when VTK 9.4.0 is required. if(VTK_VERSION VERSION_GREATER_EQUAL 9.3.20240707) list(APPEND libf3dSDKTests_list - TestSDKLoaderInvalid.cxx + TestSDKSceneInvalid.cxx ) endif() @@ -89,7 +89,7 @@ list(APPEND libf3dSDKTestsNoRender_list TestSDKOptions TestSDKOptionsIO TestSDKLog - TestSDKLoader) + TestSDKScene) # Add all the ADD_TEST for each test foreach (test ${libf3dSDKTests_list}) diff --git a/library/testing/TestSDKAnimation.cxx b/library/testing/TestSDKAnimation.cxx index 3d6a209b14..d2fb547e4c 100644 --- a/library/testing/TestSDKAnimation.cxx +++ b/library/testing/TestSDKAnimation.cxx @@ -1,15 +1,15 @@ #include #include -#include +#include #include int TestSDKAnimation(int argc, char* argv[]) { f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::interactor& inter = eng.getInteractor(); - load.add(std::string(argv[1]) + "/data/InterpolationTest.glb"); + sce.add(std::string(argv[1]) + "/data/InterpolationTest.glb"); inter.startAnimation(); if (!inter.isPlayingAnimation()) diff --git a/library/testing/TestSDKCamera.cxx b/library/testing/TestSDKCamera.cxx index 1325f8fce6..16cdb37673 100644 --- a/library/testing/TestSDKCamera.cxx +++ b/library/testing/TestSDKCamera.cxx @@ -1,6 +1,5 @@ #include #include -#include #include #include diff --git a/library/testing/TestSDKCompareWithFile.cxx b/library/testing/TestSDKCompareWithFile.cxx index a1b9c63873..2b39364135 100644 --- a/library/testing/TestSDKCompareWithFile.cxx +++ b/library/testing/TestSDKCompareWithFile.cxx @@ -1,5 +1,5 @@ #include -#include +#include #include #include "TestSDKHelpers.h" @@ -7,11 +7,11 @@ int TestSDKCompareWithFile(int argc, char* argv[]) { f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::window& win = eng.getWindow(); win.setSize(300, 300); - load.add(std::string(argv[1]) + "/data/cow.vtp"); + sce.add(std::string(argv[1]) + "/data/cow.vtp"); return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/", std::string(argv[2]), "TestSDKCompareWithFile", 50) diff --git a/library/testing/TestSDKDynamicBackgroundColor.cxx b/library/testing/TestSDKDynamicBackgroundColor.cxx index 49c406c724..2e3bc0387a 100644 --- a/library/testing/TestSDKDynamicBackgroundColor.cxx +++ b/library/testing/TestSDKDynamicBackgroundColor.cxx @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include "TestSDKHelpers.h" @@ -8,14 +8,14 @@ int TestSDKDynamicBackgroundColor(int argc, char* argv[]) { f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::window& win = eng.getWindow(); f3d::options& opt = eng.getOptions(); win.setSize(300, 300); opt.ui.filename = true; opt.ui.filename_info = "(1/1) cow.vtp"; - load.add(std::string(argv[1]) + "/data/cow.vtp"); + sce.add(std::string(argv[1]) + "/data/cow.vtp"); win.render(); diff --git a/library/testing/TestSDKDynamicFontFile.cxx b/library/testing/TestSDKDynamicFontFile.cxx index 6178148ec5..edbdbbf1f7 100644 --- a/library/testing/TestSDKDynamicFontFile.cxx +++ b/library/testing/TestSDKDynamicFontFile.cxx @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include "TestSDKHelpers.h" @@ -8,14 +8,14 @@ int TestSDKDynamicFontFile(int argc, char* argv[]) { f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::window& win = eng.getWindow(); f3d::options& opt = eng.getOptions(); win.setSize(300, 300); opt.ui.filename = true; opt.ui.filename_info = "(1/1) cow.vtp"; - load.add(std::string(argv[1]) + "/data/cow.vtp"); + sce.add(std::string(argv[1]) + "/data/cow.vtp"); win.render(); diff --git a/library/testing/TestSDKDynamicHDRI.cxx b/library/testing/TestSDKDynamicHDRI.cxx index 936d8bd56b..0abf79ea72 100644 --- a/library/testing/TestSDKDynamicHDRI.cxx +++ b/library/testing/TestSDKDynamicHDRI.cxx @@ -1,8 +1,8 @@ #include #include -#include #include #include +#include #include #include "TestSDKHelpers.h" @@ -15,14 +15,14 @@ int TestSDKDynamicHDRI(int argc, char* argv[]) f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::window& win = eng.getWindow(); f3d::options& opt = eng.getOptions(); win.setSize(300, 300); opt.ui.filename = true; opt.ui.filename_info = "(1/1) cow.vtp"; - load.add(std::string(argv[1]) + "/data/cow.vtp"); + sce.add(std::string(argv[1]) + "/data/cow.vtp"); bool ret = win.render(); if (!ret) diff --git a/library/testing/TestSDKDynamicLightIntensity.cxx b/library/testing/TestSDKDynamicLightIntensity.cxx index 7ef6290b20..4a86128df6 100644 --- a/library/testing/TestSDKDynamicLightIntensity.cxx +++ b/library/testing/TestSDKDynamicLightIntensity.cxx @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include "TestSDKHelpers.h" @@ -8,12 +8,12 @@ int TestSDKDynamicLightIntensity(int argc, char* argv[]) { f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& Scene = eng.getScene(); f3d::window& win = eng.getWindow(); f3d::options& opt = eng.getOptions(); win.setSize(300, 300); - load.add(std::string(argv[1]) + "/data/cow.vtp"); + Scene.add(std::string(argv[1]) + "/data/cow.vtp"); win.render(); diff --git a/library/testing/TestSDKDynamicProperties.cxx b/library/testing/TestSDKDynamicProperties.cxx index 0da8587e68..74a2531d7b 100644 --- a/library/testing/TestSDKDynamicProperties.cxx +++ b/library/testing/TestSDKDynamicProperties.cxx @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include "TestSDKHelpers.h" @@ -8,14 +8,14 @@ int TestSDKDynamicProperties(int argc, char* argv[]) { f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::window& win = eng.getWindow(); f3d::options& opt = eng.getOptions(); win.setSize(300, 300); opt.ui.filename = true; opt.ui.filename_info = "(1/1) cow.vtp"; - load.add(std::string(argv[1]) + "/data/cow.vtp"); + sce.add(std::string(argv[1]) + "/data/cow.vtp"); win.render(); diff --git a/library/testing/TestSDKEngine.cxx b/library/testing/TestSDKEngine.cxx index 0df0aadcf8..611e1124c0 100644 --- a/library/testing/TestSDKEngine.cxx +++ b/library/testing/TestSDKEngine.cxx @@ -1,8 +1,8 @@ #include #include -#include #include #include +#include #include #include @@ -23,15 +23,15 @@ int TestSDKEngine(int argc, char* argv[]) // Test different flags combinations that makes sense f3d::engine eng0(f3d::window::Type::NONE); - const f3d::loader& load = eng0.getLoader(); + const f3d::scene& sce = eng0.getScene(); f3d::engine eng1(f3d::window::Type::NATIVE); - const f3d::loader& load1 = eng1.getLoader(); + const f3d::scene& sce1 = eng1.getScene(); const f3d::window& window1 = eng1.getWindow(); const f3d::interactor& inter1 = eng1.getInteractor(); f3d::engine eng2(f3d::window::Type::NATIVE_OFFSCREEN); - const f3d::loader& load2 = eng2.getLoader(); + const f3d::scene& sce2 = eng2.getScene(); const f3d::window& window2 = eng2.getWindow(); const f3d::interactor& inter2 = eng2.getInteractor(); diff --git a/library/testing/TestSDKEngineExceptions.cxx b/library/testing/TestSDKEngineExceptions.cxx index 6ed24b2edb..f0daa379fc 100644 --- a/library/testing/TestSDKEngineExceptions.cxx +++ b/library/testing/TestSDKEngineExceptions.cxx @@ -1,6 +1,5 @@ #include #include -#include #include #include diff --git a/library/testing/TestSDKExternalWindowGLFW.cxx b/library/testing/TestSDKExternalWindowGLFW.cxx index 6f1896b6c6..e04c0111d3 100644 --- a/library/testing/TestSDKExternalWindowGLFW.cxx +++ b/library/testing/TestSDKExternalWindowGLFW.cxx @@ -1,5 +1,5 @@ #include -#include +#include #include #include "TestSDKHelpers.h" @@ -12,7 +12,7 @@ int TestSDKExternalWindowGLFW(int argc, char* argv[]) { // create engine and load file f3d::engine eng(f3d::window::Type::EXTERNAL); - eng.getLoader().add(std::string(argv[1]) + "/data/cow.vtp"); + eng.getScene().add(std::string(argv[1]) + "/data/cow.vtp"); // setup glfw window if (!glfwInit()) diff --git a/library/testing/TestSDKExternalWindowQT.cxx b/library/testing/TestSDKExternalWindowQT.cxx index 7ae6a0facb..f564c574ba 100644 --- a/library/testing/TestSDKExternalWindowQT.cxx +++ b/library/testing/TestSDKExternalWindowQT.cxx @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -19,8 +19,8 @@ class F3DWindow : public QOpenGLWindow , mBaselinePath(std::move(baselinePath)) , mOutputPath(std::move(outputPath)) { - f3d::loader& load = mEngine.getLoader(); - load.add(filePath); + f3d::scene& sce = mEngine.getScene(); + sce.add(filePath); } protected: diff --git a/library/testing/TestSDKInteractorCallBack.cxx b/library/testing/TestSDKInteractorCallBack.cxx index bc4b714cf6..8d81695f72 100644 --- a/library/testing/TestSDKInteractorCallBack.cxx +++ b/library/testing/TestSDKInteractorCallBack.cxx @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include @@ -12,7 +12,7 @@ int TestSDKInteractorCallBack(int argc, char* argv[]) { f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); f3d::options& options = eng.getOptions(); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::window& win = eng.getWindow(); f3d::interactor& inter = eng.getInteractor(); win.setSize(300, 300); @@ -49,7 +49,7 @@ int TestSDKInteractorCallBack(int argc, char* argv[]) inter.setDropFilesCallBack([&](std::vector filesVec) -> bool { std::string path = filesVec[0]; size_t found = path.find_last_of("/\\"); - load.add(path.substr(0, found + 1) + "suzanne.ply"); + sce.add(path.substr(0, found + 1) + "suzanne.ply"); win.render(); return true; }); diff --git a/library/testing/TestSDKInteractorDropFullScene.cxx b/library/testing/TestSDKInteractorDropFullScene.cxx index 1d3c19a8aa..defa6afee5 100644 --- a/library/testing/TestSDKInteractorDropFullScene.cxx +++ b/library/testing/TestSDKInteractorDropFullScene.cxx @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -12,7 +11,6 @@ int TestSDKInteractorDropFullScene(int argc, char* argv[]) { f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); const f3d::options& options = eng.getOptions(); - const f3d::loader& load = eng.getLoader(); f3d::window& win = eng.getWindow(); f3d::interactor& inter = eng.getInteractor(); win.setSize(300, 300); diff --git a/library/testing/TestSDKMultiColoring.cxx b/library/testing/TestSDKMultiColoring.cxx index 93c51a7fa2..abc7a8a5f7 100644 --- a/library/testing/TestSDKMultiColoring.cxx +++ b/library/testing/TestSDKMultiColoring.cxx @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include "TestSDKHelpers.h" @@ -12,7 +12,7 @@ int TestSDKMultiColoring(int argc, char* argv[]) { f3d::log::setVerboseLevel(f3d::log::VerboseLevel::DEBUG); f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::options& opt = eng.getOptions(); // Test file logic @@ -24,7 +24,7 @@ int TestSDKMultiColoring(int argc, char* argv[]) std::string right = std::string(argv[1]) + "data/" + rightFilename; // Multiple geometries - load.add(std::vector{ cube, left, right }); + sce.add(std::vector{ cube, left, right }); opt.model.scivis.array_name = "Normals"; diff --git a/library/testing/TestSDKMultiOptions.cxx b/library/testing/TestSDKMultiOptions.cxx index 9fcbe64fc8..77f61b492f 100644 --- a/library/testing/TestSDKMultiOptions.cxx +++ b/library/testing/TestSDKMultiOptions.cxx @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include "TestSDKHelpers.h" @@ -12,7 +12,7 @@ int TestSDKMultiOptions(int argc, char* argv[]) { f3d::log::setVerboseLevel(f3d::log::VerboseLevel::DEBUG); f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::options& opt = eng.getOptions(); f3d::window& win = eng.getWindow(); @@ -22,7 +22,7 @@ int TestSDKMultiOptions(int argc, char* argv[]) std::string right = std::string(argv[1]) + "data/" + rightFilename; // Render one geometry with a render option - load.add(left); + sce.add(left); opt.render.show_edges = true; opt.render.grid.enable = true; opt.ui.metadata = true; @@ -30,7 +30,7 @@ int TestSDKMultiOptions(int argc, char* argv[]) win.render(); // Add another geometry - load.add(right); + sce.add(right); // Check rendering is correct return TestSDKHelpers::RenderTest(eng.getWindow(), std::string(argv[1]) + "baselines/", diff --git a/library/testing/TestSDKRenderAndInteract.cxx b/library/testing/TestSDKRenderAndInteract.cxx index 61c459f342..3004e09cbe 100644 --- a/library/testing/TestSDKRenderAndInteract.cxx +++ b/library/testing/TestSDKRenderAndInteract.cxx @@ -1,6 +1,6 @@ #include #include -#include +#include #include int TestSDKRenderAndInteract(int argc, char* argv[]) @@ -11,8 +11,8 @@ int TestSDKRenderAndInteract(int argc, char* argv[]) // Using an onscreen window to mimic standard usage f3d::engine eng(f3d::window::Type::NATIVE); - f3d::loader& load = eng.getLoader(); - load.add(std::string(argv[1]) + "/data/cow.vtp"); + f3d::scene& sce = eng.getScene(); + sce.add(std::string(argv[1]) + "/data/cow.vtp"); f3d::window& win = eng.getWindow(); win.render(); diff --git a/library/testing/TestSDKRenderFinalShader.cxx b/library/testing/TestSDKRenderFinalShader.cxx index 30481a7e42..140c5e5457 100644 --- a/library/testing/TestSDKRenderFinalShader.cxx +++ b/library/testing/TestSDKRenderFinalShader.cxx @@ -1,6 +1,6 @@ #include -#include #include +#include #include #include "TestSDKHelpers.h" @@ -12,8 +12,8 @@ int TestSDKRenderFinalShader(int argc, char* argv[]) f3d::window& win = eng.getWindow(); win.setSize(300, 300); - f3d::loader& load = eng.getLoader(); - load.add(std::string(argv[1]) + "/data/cow.vtp"); + f3d::scene& sce = eng.getScene(); + sce.add(std::string(argv[1]) + "/data/cow.vtp"); win.render(); diff --git a/library/testing/TestSDKLoader.cxx b/library/testing/TestSDKScene.cxx similarity index 59% rename from library/testing/TestSDKLoader.cxx rename to library/testing/TestSDKScene.cxx index cf15193ee7..f3d0d0be21 100644 --- a/library/testing/TestSDKLoader.cxx +++ b/library/testing/TestSDKScene.cxx @@ -3,21 +3,21 @@ #include #include -#include #include +#include #include #include namespace fs = std::filesystem; -int TestSDKLoader(int argc, char* argv[]) +int TestSDKScene(int argc, char* argv[]) { PseudoUnitTest test; f3d::log::setVerboseLevel(f3d::log::VerboseLevel::DEBUG); f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::window& win = eng.getWindow().setSize(300, 300); // Test file logic @@ -40,31 +40,30 @@ int TestSDKLoader(int argc, char* argv[]) std::string world = std::string(argv[1]) + "data/" + worldFilename; // supports method - test("supported with empty filename", !load.supports(empty)); - test("supported with dummy filename", !load.supports(dummy)); - test("supported with non existent filename", load.supports(nonExistent)); - test("supported with default scene format", load.supports(cube)); - test("supported with full scene format", load.supports(logo)); + test("supported with empty filename", !sce.supports(empty)); + test("supported with dummy filename", !sce.supports(dummy)); + test("supported with non existent filename", sce.supports(nonExistent)); + test("supported with default scene format", sce.supports(cube)); + test("supported with full scene format", sce.supports(logo)); // add error code paths - test.expect( - "add with dummy file", [&]() { load.add(dummy); }); - test.expect( - "add with unsupported file", [&]() { load.add(unsupported); }); - test.expect( - "add with inexistent file", [&]() { load.add(nonExistent); }); + test.expect("add with dummy file", [&]() { sce.add(dummy); }); + test.expect( + "add with unsupported file", [&]() { sce.add(unsupported); }); + test.expect( + "add with inexistent file", [&]() { sce.add(nonExistent); }); // add standard code paths - test("add with empty file", [&]() { load.add(std::vector{}); }); - test("add with empty file", [&]() { load.add(empty); }); - test("add with a single path", [&]() { load.add(fs::path(logo)); }); - test("add with multiples filepaths", [&]() { load.add({ fs::path(sphere2), fs::path(cube) }); }); - test("add with multiples file strings", [&]() { load.add({ sphere1, world }); }); + test("add with empty file", [&]() { sce.add(std::vector{}); }); + test("add with empty file", [&]() { sce.add(empty); }); + test("add with a single path", [&]() { sce.add(fs::path(logo)); }); + test("add with multiples filepaths", [&]() { sce.add({ fs::path(sphere2), fs::path(cube) }); }); + test("add with multiples file strings", [&]() { sce.add({ sphere1, world }); }); // render test test("render after add", [&]() { if (!TestSDKHelpers::RenderTest( - win, std::string(argv[1]) + "baselines/", argv[2], "TestSDKLoader")) + win, std::string(argv[1]) + "baselines/", argv[2], "TestSDKScene")) { throw "rendering test failed"; } diff --git a/library/testing/TestSDKLoadFromMemory.cxx b/library/testing/TestSDKSceneFromMemory.cxx similarity index 65% rename from library/testing/TestSDKLoadFromMemory.cxx rename to library/testing/TestSDKSceneFromMemory.cxx index eadd47e5c3..93c5b301c0 100644 --- a/library/testing/TestSDKLoadFromMemory.cxx +++ b/library/testing/TestSDKSceneFromMemory.cxx @@ -2,62 +2,62 @@ #include "TestSDKHelpers.h" #include -#include #include +#include #include #include -int TestSDKLoadFromMemory(int argc, char* argv[]) +int TestSDKSceneFromMemory(int argc, char* argv[]) { PseudoUnitTest test; f3d::log::setVerboseLevel(f3d::log::VerboseLevel::DEBUG); f3d::engine eng(f3d::window::Type::NATIVE_OFFSCREEN); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); f3d::window& win = eng.getWindow().setSize(300, 300); std::string texturePath = std::string(argv[1]) + "data/world.png"; eng.getOptions().model.color.texture = texturePath; // Add mesh with invalid number of points - test.expect("add mesh with invalid number of points", [&]() { - load.add(f3d::mesh_t{ { 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, 0.f }, {}, {}, { 3 }, { 0, 1, 2 } }); + test.expect("add mesh with invalid number of points", [&]() { + sce.add(f3d::mesh_t{ { 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, 0.f }, {}, {}, { 3 }, { 0, 1, 2 } }); }); // Add mesh with empty points - test.expect( - "add mesh with empty points", [&]() { load.add(f3d::mesh_t{}); }); + test.expect( + "add mesh with empty points", [&]() { sce.add(f3d::mesh_t{}); }); // Add mesh with invalid number of cell indices - test.expect( + test.expect( "add mesh with invalid number of cell indices", [&]() { - load.add(f3d::mesh_t{ + sce.add(f3d::mesh_t{ { 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, 0.f, 0.f }, {}, {}, { 3 }, { 0, 1, 2, 3 } }); }); // Add mesh with invalid vertex index - test.expect("add mesh with invalid vertex index", [&]() { - load.add( + test.expect("add mesh with invalid vertex index", [&]() { + sce.add( f3d::mesh_t{ { 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, 0.f, 0.f }, {}, {}, { 3 }, { 0, 1, 4 } }); }); // Add mesh with invalid normals - test.expect("add mesh with invalid normals", [&]() { - load.add(f3d::mesh_t{ + test.expect("add mesh with invalid normals", [&]() { + sce.add(f3d::mesh_t{ { 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, 0.f, 0.f }, { 1.f }, {}, { 3 }, { 0, 1, 2, 4 } }); }); // Add mesh with invalid texture coordinates - test.expect( + test.expect( "add mesh with invalid texture coordinates", [&]() { - load.add(f3d::mesh_t{ + sce.add(f3d::mesh_t{ { 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, 0.f, 0.f }, {}, { 1.f }, { 3 }, { 0, 1, 2, 4 } }); }); // Add mesh from memory and render it test("add mesh from memory", [&]() { - load.add(f3d::mesh_t{ { 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, 0.f, 0.f, 1.f, 1.f, 0.f }, + sce.add(f3d::mesh_t{ { 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 1.f, 0.f, 0.f, 1.f, 1.f, 0.f }, { 0.f, 0.f, -1.f, 0.f, 0.f, -1.f, 0.f, 0.f, -1.f, 0.f, 0.f, -1.f }, { 0.f, 0.f, 0.f, 1.f, 1.f, 0.f, 1.f, 1.f }, { 3, 3 }, { 0, 1, 2, 1, 3, 2 } }); }); @@ -65,7 +65,7 @@ int TestSDKLoadFromMemory(int argc, char* argv[]) // Render test test("render mesh from memory", [&]() { if (!TestSDKHelpers::RenderTest( - win, std::string(argv[1]) + "baselines/", argv[2], "TestSDKLoadMemory")) + win, std::string(argv[1]) + "baselines/", argv[2], "TestSDKSceneFromMemory")) { throw "rendering test failed"; } diff --git a/library/testing/TestSDKLoaderInvalid.cxx b/library/testing/TestSDKSceneInvalid.cxx similarity index 61% rename from library/testing/TestSDKLoaderInvalid.cxx rename to library/testing/TestSDKSceneInvalid.cxx index 01fb40c91b..5380c34f8c 100644 --- a/library/testing/TestSDKLoaderInvalid.cxx +++ b/library/testing/TestSDKSceneInvalid.cxx @@ -2,29 +2,29 @@ #include #include -#include #include +#include #include #include -int TestSDKLoaderInvalid(int argc, char* argv[]) +int TestSDKSceneInvalid(int argc, char* argv[]) { PseudoUnitTest test; f3d::log::setVerboseLevel(f3d::log::VerboseLevel::DEBUG); f3d::engine eng(f3d::window::Type::NONE); - f3d::loader& load = eng.getLoader(); + f3d::scene& sce = eng.getScene(); std::string invalidDefaultSceneFilename = "invalid.vtp"; std::string invalidFullSceneFilename = "duck_invalid.gltf"; std::string invalidDefaultScene = std::string(argv[1]) + "data/" + invalidDefaultSceneFilename; std::string invalidFullScene = std::string(argv[1]) + "data/" + invalidFullSceneFilename; - test.expect( - "add with invalid default scene file", [&]() { load.add(invalidDefaultScene); }); - test.expect( - "add with invalid full scene file", [&]() { load.add(invalidFullScene); }); + test.expect( + "add with invalid default scene file", [&]() { sce.add(invalidDefaultScene); }); + test.expect( + "add with invalid full scene file", [&]() { sce.add(invalidFullScene); }); return test.result(); } diff --git a/python/F3DPythonBindings.cxx b/python/F3DPythonBindings.cxx index 4fbb2a07c7..459c6bc983 100644 --- a/python/F3DPythonBindings.cxx +++ b/python/F3DPythonBindings.cxx @@ -7,9 +7,9 @@ #include "engine.h" #include "image.h" #include "interactor.h" -#include "loader.h" #include "log.h" #include "options.h" +#include "scene.h" #include "types.h" #include "utils.h" #include "window.h" @@ -240,18 +240,18 @@ PYBIND11_MODULE(pyf3d, module) .def_readwrite("face_sides", &f3d::mesh_t::face_sides) .def_readwrite("face_indices", &f3d::mesh_t::face_indices); - // f3d::loader - py::class_> loader(module, "Loader"); - loader // - .def("supports", &f3d::loader::supports) - .def("clear", &f3d::loader::clear) - .def("add", py::overload_cast(&f3d::loader::add), + // f3d::scene + py::class_> scene(module, "Scene"); + scene // + .def("supports", &f3d::scene::supports) + .def("clear", &f3d::scene::clear) + .def("add", py::overload_cast(&f3d::scene::add), "Add a file the scene", py::arg("file_path")) - .def("add", py::overload_cast&>(&f3d::loader::add), + .def("add", py::overload_cast&>(&f3d::scene::add), "Add multiple filepaths to the scene", py::arg("file_path_vector")) - .def("add", py::overload_cast&>(&f3d::loader::add), + .def("add", py::overload_cast&>(&f3d::scene::add), "Add multiple filenames to the scene", py::arg("file_name_vector")) - .def("add", py::overload_cast(&f3d::loader::add), + .def("add", py::overload_cast(&f3d::scene::add), "Add a surfacic mesh from memory into the scene", py::arg("mesh")); // f3d::camera @@ -332,7 +332,7 @@ PYBIND11_MODULE(pyf3d, module) py::overload_cast(&f3d::engine::setOptions), py::return_value_policy::reference) .def_property_readonly("window", &f3d::engine::getWindow, py::return_value_policy::reference) - .def_property_readonly("loader", &f3d::engine::getLoader, py::return_value_policy::reference) + .def_property_readonly("scene", &f3d::engine::getScene, py::return_value_policy::reference) .def_property_readonly( "interactor", &f3d::engine::getInteractor, py::return_value_policy::reference) .def_static("load_plugin", &f3d::engine::loadPlugin, "Load a plugin") diff --git a/python/__init__.py.in b/python/__init__.py.in index 56bdfdbda9..1cbcd1ac0f 100644 --- a/python/__init__.py.in +++ b/python/__init__.py.in @@ -68,7 +68,7 @@ def deprecated_decorator(f, reason): def add_deprecation_warnings(): for f3d_class in ( Camera, - Loader, + Scene, Options, Interactor, Engine, diff --git a/python/testing/CMakeLists.txt b/python/testing/CMakeLists.txt index d68d52e84c..afcbb16065 100644 --- a/python/testing/CMakeLists.txt +++ b/python/testing/CMakeLists.txt @@ -13,7 +13,7 @@ endif() list(APPEND pyf3dTests_list test_image_compare.py - test_loader.py + test_scene.py ) list(APPEND pyf3dTestsNoRender_list diff --git a/python/testing/test_image_compare.py b/python/testing/test_image_compare.py index 547c5d431e..094dd71304 100644 --- a/python/testing/test_image_compare.py +++ b/python/testing/test_image_compare.py @@ -19,7 +19,7 @@ def test_compare_with_file(): assert engine.window.width == 300 assert engine.window.height == 300 - engine.loader.add(dataset) + engine.scene.add(dataset) img = engine.window.render_to_image() img.save(output) diff --git a/python/testing/test_loader.py b/python/testing/test_scene.py similarity index 71% rename from python/testing/test_loader.py rename to python/testing/test_scene.py index b92d78a4fa..26fa377457 100644 --- a/python/testing/test_loader.py +++ b/python/testing/test_scene.py @@ -5,15 +5,15 @@ import f3d -def test_load_memory(): +def test_scene_memory(): testing_dir = Path(__file__).parent.parent.parent / "testing" - reference = f"{testing_dir}/baselines/TestPythonLoadMemory.png" - output = tempfile.gettempdir() + "/TestPythonLoadMemory.png" + reference = f"{testing_dir}/baselines/TestPythonSceneMemory.png" + output = tempfile.gettempdir() + "/TestPythonSceneMemory.png" engine = f3d.Engine(f3d.Window.NATIVE_OFFSCREEN) engine.window.size = 300, 300 - engine.loader.add( + engine.scene.add( f3d.Mesh( points=[0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0], face_sides=[3], @@ -29,7 +29,7 @@ def test_load_memory(): assert img.compare(f3d.Image(reference), 0.05, error) -def test_loader(): +def test_scene(): testing_dir = Path(__file__).parent.parent.parent / "testing" world = f"{testing_dir}/data/world.obj" logo = f"{testing_dir}/data/f3d.glb" @@ -37,15 +37,15 @@ def test_loader(): sphere2 = f"{testing_dir}/data/mb/recursive/mb_2_0.vtp" cube = f"{testing_dir}/data/mb/recursive/mb_0_0.vtu" cube = f"{testing_dir}/data/f3d.glb" - reference = f"{testing_dir}/baselines/TestPythonLoader.png" - output = tempfile.gettempdir() + "/TestPythonLoader.png" + reference = f"{testing_dir}/baselines/TestPythonScene.png" + output = tempfile.gettempdir() + "/TestPythonScene.png" engine = f3d.Engine(f3d.Window.NATIVE_OFFSCREEN) engine.window.size = 300, 300 - engine.loader.add([world, logo]) - engine.loader.add(Path(sphere1)) - engine.loader.add([Path(sphere2), Path(cube)]) + engine.scene.add([world, logo]) + engine.scene.add(Path(sphere1)) + engine.scene.add([Path(sphere2), Path(cube)]) img = engine.window.render_to_image() img.save(output) diff --git a/testing/baselines/TestPythonLoader.png b/testing/baselines/TestPythonScene.png similarity index 100% rename from testing/baselines/TestPythonLoader.png rename to testing/baselines/TestPythonScene.png diff --git a/testing/baselines/TestPythonLoadMemory.png b/testing/baselines/TestPythonSceneMemory.png similarity index 100% rename from testing/baselines/TestPythonLoadMemory.png rename to testing/baselines/TestPythonSceneMemory.png diff --git a/testing/baselines/TestSDKLoader.png b/testing/baselines/TestSDKScene.png similarity index 100% rename from testing/baselines/TestSDKLoader.png rename to testing/baselines/TestSDKScene.png diff --git a/testing/baselines/TestSDKLoadMemory.png b/testing/baselines/TestSDKSceneFromMemory.png similarity index 100% rename from testing/baselines/TestSDKLoadMemory.png rename to testing/baselines/TestSDKSceneFromMemory.png diff --git a/webassembly/F3DEmscriptenBindings.cxx b/webassembly/F3DEmscriptenBindings.cxx index a179dac01d..42f81048e4 100644 --- a/webassembly/F3DEmscriptenBindings.cxx +++ b/webassembly/F3DEmscriptenBindings.cxx @@ -2,8 +2,8 @@ #include "engine.h" #include "interactor.h" -#include "loader.h" #include "options.h" +#include "scene.h" #include "window.h" namespace emscripten @@ -11,7 +11,7 @@ namespace emscripten namespace internal { template<> -void raw_destructor(f3d::loader* ptr) +void raw_destructor(f3d::scene* ptr) { } @@ -53,19 +53,19 @@ f3d::options* set_color(f3d::options& o, const std::string& name, double r, doub return &o.set(name, std::vector{ r, g, b }); } -f3d::loader* getLoaderPtr(f3d::engine& e) +f3d::scene* getScenePtr(f3d::engine& e) { - return &e.getLoader(); + return &e.getScene(); } -f3d::loader* add(f3d::loader& l, const std::string& p) +f3d::scene* add(f3d::scene& l, const std::string& p) { return &l.add(p); } -bool supports(f3d::loader& l, const std::string& p) +bool supports(f3d::scene& l, const std::string& p) { return l.supports(p); } -f3d::loader* clear(f3d::loader& l) +f3d::scene* clear(f3d::scene& l) { return &l.clear(); } @@ -98,8 +98,8 @@ EMSCRIPTEN_BINDINGS(f3d) .function("set_integer", &set_integer, emscripten::allow_raw_pointers()) .function("set_color", &set_color, emscripten::allow_raw_pointers()); - // f3d::loader - emscripten::class_("Loader") + // f3d::scene + emscripten::class_("Scene") .function("supported", &supported, emscripten::allow_raw_pointers()) .function("add", &add, emscripten::allow_raw_pointers()) .function("clear", &clear, emscripten::allow_raw_pointers()); @@ -117,7 +117,7 @@ EMSCRIPTEN_BINDINGS(f3d) emscripten::class_ engine("Engine"); engine.constructor<>() - .function("getLoader", &getLoaderPtr, emscripten::allow_raw_pointers()) + .function("getScene", &getScenePtr, emscripten::allow_raw_pointers()) .function("getWindow", &getWindowPtr, emscripten::allow_raw_pointers()) .function("getInteractor", &getInteractorPtr, emscripten::allow_raw_pointers()) .function("getOptions", &getOptionsPtr, emscripten::allow_raw_pointers()) diff --git a/webassembly/app.html b/webassembly/app.html index 2ca5d6f485..fd69fd979d 100644 --- a/webassembly/app.html +++ b/webassembly/app.html @@ -124,10 +124,10 @@

F3D Web

const openFile = (name) => { document.getElementById('file-name').innerHTML = name; const filePath = '/' + name; - const loader = Module.engineInstance.getLoader(); - if (loader.supports(filePath)) + const scene = Module.engineInstance.getScene(); + if (scene.supports(filePath)) { - loader.add(filePath); + scene.add(filePath); } else {