1
2//
3// This source file is part of appleseed.
4// Visit http://appleseedhq.net/ for additional information and resources.
5//
6// This software is released under the MIT license.
7//
8// Copyright (c) 2015-2017 Esteban Tovagliari, The appleseedhq Organization
9//
10// Permission is hereby granted, free of charge, to any person obtaining a copy
11// of this software and associated documentation files (the "Software"), to deal
12// in the Software without restriction, including without limitation the rights
13// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14// copies of the Software, and to permit persons to whom the Software is
15// furnished to do so, subject to the following conditions:
16//
17// The above copyright notice and this permission notice shall be included in
18// all copies or substantial portions of the Software.
19//
20// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26// THE SOFTWARE.
27//
28
29// appleseed.python headers.
30#include "pyseed.h" // has to be first, to avoid redefinition warnings
31#include "bindentitycontainers.h"
32#include "dict2dict.h"
33#include "metadata.h"
34
35// appleseed.renderer headers.
36#include "renderer/api/bssrdf.h"
37
38// Standard headers.
39#include <string>
40
41namespace bpy = boost::python;
42using namespace foundation;
43using namespace renderer;
44using namespace std;
45
46// Work around a regression in Visual Studio 2015 Update 3.
47#if defined(_MSC_VER) && _MSC_VER == 1900
48namespace boost
49{
50 template <> BSSRDF const volatile* get_pointer<BSSRDF const volatile>(BSSRDF const volatile* p) { return p; }
51}
52#endif
53
54namespace
55{
56 auto_release_ptr<BSSRDF> create_bssrdf(
57 const string& model,
58 const string& name,
59 const bpy::dict& params)
60 {
61 BSSRDFFactoryRegistrar factories;
62 const IBSSRDFFactory* factory = factories.lookup(model.c_str());
63
64 if (factory)
65 return factory->create(name.c_str(), bpy_dict_to_param_array(params));
66 else
67 {
68 PyErr_SetString(PyExc_RuntimeError, "BSSRDF model not found");
69 bpy::throw_error_already_set();
70 }
71
72 return auto_release_ptr<BSSRDF>();
73 }
74}
75
76void bind_bssrdf()
77{
78 bpy::class_<BSSRDF, auto_release_ptr<BSSRDF>, bpy::bases<ConnectableEntity>, boost::noncopyable>("BSSRDF", bpy::no_init)
79 .def("get_model_metadata", &detail::get_entity_model_metadata<BSSRDFFactoryRegistrar>).staticmethod("get_model_metadata")
80 .def("get_input_metadata", &detail::get_entity_input_metadata<BSSRDFFactoryRegistrar>).staticmethod("get_input_metadata")
81 .def("__init__", bpy::make_constructor(create_bssrdf))
82 .def("get_model", &BSSRDF::get_model)
83 ;
84
85 bind_typed_entity_vector<BSSRDF>("BSSRDFContainer");
86}
87