1 // Copyright 2009-2020 Intel Corporation 2 // SPDX-License-Identifier: Apache-2.0 3 4 #pragma once 5 6 // ospray 7 #include "ospray/ospray_cpp.h" 8 #include "ospray/ospray_cpp/ext/rkcommon.h" 9 // rkcommon 10 #include "rkcommon/memory/IntrusivePtr.h" 11 #include "rkcommon/utility/ParameterizedObject.h" 12 // std 13 #include <functional> 14 #include <map> 15 16 #include "ospray_testing_export.h" 17 18 namespace ospray { 19 namespace testing { 20 namespace detail { 21 22 using namespace rkcommon; 23 using namespace rkcommon::math; 24 25 struct Builder : public memory::RefCountedObject, 26 public utility::ParameterizedObject 27 { 28 using BuilderFcn = std::function<Builder *()>; 29 30 ~Builder() override = default; 31 32 virtual void commit(); 33 34 virtual cpp::Group buildGroup() const = 0; 35 virtual cpp::World buildWorld() const; 36 virtual cpp::World buildWorld( 37 const std::vector<cpp::Instance> &instances) const; 38 39 static void registerBuilder(const std::string &name, BuilderFcn fcn); 40 static Builder *createBuilder(const std::string &name); 41 42 protected: 43 cpp::TransferFunction makeTransferFunction(const vec2f &valueRange) const; 44 45 cpp::Instance makeGroundPlane(const box3f &bounds) const; 46 47 // Data // 48 49 std::string rendererType{"scivis"}; 50 std::string tfColorMap{"jet"}; 51 std::string tfOpacityMap{"linear"}; 52 53 bool addPlane{true}; 54 55 unsigned int randomSeed{0}; 56 57 private: 58 using BuilderFactory = std::map<std::string, BuilderFcn>; 59 60 static std::unique_ptr<BuilderFactory> factory; 61 }; 62 63 } // namespace detail 64 } // namespace testing 65 } // namespace ospray 66 67 #define OSP_REGISTER_TESTING_BUILDER(InternalClassName, Name) \ 68 static bool init_builder_##Name() \ 69 { \ 70 using Builder = ospray::testing::detail::Builder; \ 71 Builder::registerBuilder( \ 72 TOSTRING(Name), [] { return new InternalClassName; }); \ 73 return true; \ 74 } \ 75 static bool val_##Name##_initialized = init_builder_##Name(); 76