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) 2012-2013 Esteban Tovagliari, Jupiter Jazz Limited |
9 | // Copyright (c) 2014-2017 Esteban Tovagliari, The appleseedhq Organization |
10 | // |
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
12 | // of this software and associated documentation files (the "Software"), to deal |
13 | // in the Software without restriction, including without limitation the rights |
14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
15 | // copies of the Software, and to permit persons to whom the Software is |
16 | // furnished to do so, subject to the following conditions: |
17 | // |
18 | // The above copyright notice and this permission notice shall be included in |
19 | // all copies or substantial portions of the Software. |
20 | // |
21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
27 | // THE SOFTWARE. |
28 | // |
29 | |
30 | // appleseed.python headers. |
31 | #include "pyseed.h" // has to be first, to avoid redefinition warnings |
32 | #include "dict2dict.h" |
33 | |
34 | // appleseed.renderer headers. |
35 | #include "renderer/modeling/entity/connectableentity.h" |
36 | #include "renderer/modeling/entity/entity.h" |
37 | #include "renderer/modeling/entity/entitymap.h" |
38 | #include "renderer/modeling/entity/entityvector.h" |
39 | #include "renderer/modeling/project/configuration.h" |
40 | #include "renderer/modeling/scene/assembly.h" |
41 | #include "renderer/modeling/scene/assemblyinstance.h" |
42 | |
43 | // Standard headers. |
44 | #include <cstddef> |
45 | #include <string> |
46 | |
47 | namespace bpy = boost::python; |
48 | using namespace foundation; |
49 | using namespace renderer; |
50 | using namespace std; |
51 | |
52 | // Work around a regression in Visual Studio 2015 Update 3. |
53 | #if defined(_MSC_VER) && _MSC_VER == 1900 |
54 | namespace boost |
55 | { |
56 | template <> Entity const volatile* get_pointer<Entity const volatile>(Entity const volatile* p) { return p; } |
57 | template <> ConnectableEntity const volatile* get_pointer<ConnectableEntity const volatile>(ConnectableEntity const volatile* p) { return p; } |
58 | } |
59 | #endif |
60 | |
61 | namespace |
62 | { |
63 | bpy::dict entity_get_parameters(const Entity* e) |
64 | { |
65 | return param_array_to_bpy_dict(e->get_parameters()); |
66 | } |
67 | |
68 | void entity_set_parameters(Entity* e, const bpy::dict& params) |
69 | { |
70 | e->get_parameters() = bpy_dict_to_param_array(params); |
71 | } |
72 | } |
73 | |
74 | void bind_entity() |
75 | { |
76 | bpy::class_<Entity, auto_release_ptr<Entity>, boost::noncopyable>("Entity" , bpy::no_init) |
77 | .def("get_uid" , &Identifiable::get_uid) |
78 | |
79 | .def("get_version_id" , &Versionable::get_version_id) |
80 | .def("bump_version_id" , &Versionable::bump_version_id) |
81 | |
82 | .def("get_class_uid" , &Entity::get_class_uid) |
83 | |
84 | .def("get_name" , &Entity::get_name) |
85 | .def("set_name" , &Entity::set_name) |
86 | |
87 | .def("get_parameters" , entity_get_parameters) |
88 | .def("set_parameters" , entity_set_parameters) |
89 | |
90 | .def("set_render_layer_index" , &Entity::set_render_layer_index) |
91 | .def("get_render_layer_index" , &Entity::get_render_layer_index) |
92 | ; |
93 | |
94 | bpy::class_<ConnectableEntity, auto_release_ptr<ConnectableEntity>, bpy::bases<Entity>, boost::noncopyable>("ConnectableEntity" , bpy::no_init); |
95 | |
96 | bpy::class_<EntityVector, boost::noncopyable>("EntityVector" ) |
97 | .def("clear" , &EntityVector::clear) |
98 | .def("__len__" , &EntityVector::size) |
99 | ; |
100 | |
101 | bpy::class_<EntityMap, boost::noncopyable>("EntityMap" ) |
102 | .def("clear" , &EntityMap::clear) |
103 | .def("__len__" , &EntityMap::size) |
104 | ; |
105 | } |
106 | |