1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #include "pxr/usd/usdGeom/basisCurves.h"
25 #include "pxr/usd/usd/schemaBase.h"
26
27 #include "pxr/usd/sdf/primSpec.h"
28
29 #include "pxr/usd/usd/pyConversions.h"
30 #include "pxr/base/tf/pyContainerConversions.h"
31 #include "pxr/base/tf/pyResultConversions.h"
32 #include "pxr/base/tf/pyUtils.h"
33 #include "pxr/base/tf/wrapTypeHelpers.h"
34
35 #include <boost/python.hpp>
36
37 #include <string>
38
39 using namespace boost::python;
40
41 PXR_NAMESPACE_USING_DIRECTIVE
42
43 namespace {
44
45 #define WRAP_CUSTOM \
46 template <class Cls> static void _CustomWrapCode(Cls &_class)
47
48 // fwd decl.
49 WRAP_CUSTOM;
50
51
52 static UsdAttribute
_CreateTypeAttr(UsdGeomBasisCurves & self,object defaultVal,bool writeSparsely)53 _CreateTypeAttr(UsdGeomBasisCurves &self,
54 object defaultVal, bool writeSparsely) {
55 return self.CreateTypeAttr(
56 UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Token), writeSparsely);
57 }
58
59 static UsdAttribute
_CreateBasisAttr(UsdGeomBasisCurves & self,object defaultVal,bool writeSparsely)60 _CreateBasisAttr(UsdGeomBasisCurves &self,
61 object defaultVal, bool writeSparsely) {
62 return self.CreateBasisAttr(
63 UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Token), writeSparsely);
64 }
65
66 static UsdAttribute
_CreateWrapAttr(UsdGeomBasisCurves & self,object defaultVal,bool writeSparsely)67 _CreateWrapAttr(UsdGeomBasisCurves &self,
68 object defaultVal, bool writeSparsely) {
69 return self.CreateWrapAttr(
70 UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Token), writeSparsely);
71 }
72
73 static std::string
_Repr(const UsdGeomBasisCurves & self)74 _Repr(const UsdGeomBasisCurves &self)
75 {
76 std::string primRepr = TfPyRepr(self.GetPrim());
77 return TfStringPrintf(
78 "UsdGeom.BasisCurves(%s)",
79 primRepr.c_str());
80 }
81
82 } // anonymous namespace
83
wrapUsdGeomBasisCurves()84 void wrapUsdGeomBasisCurves()
85 {
86 typedef UsdGeomBasisCurves This;
87
88 class_<This, bases<UsdGeomCurves> >
89 cls("BasisCurves");
90
91 cls
92 .def(init<UsdPrim>(arg("prim")))
93 .def(init<UsdSchemaBase const&>(arg("schemaObj")))
94 .def(TfTypePythonClass())
95
96 .def("Get", &This::Get, (arg("stage"), arg("path")))
97 .staticmethod("Get")
98
99 .def("Define", &This::Define, (arg("stage"), arg("path")))
100 .staticmethod("Define")
101
102 .def("GetSchemaAttributeNames",
103 &This::GetSchemaAttributeNames,
104 arg("includeInherited")=true,
105 return_value_policy<TfPySequenceToList>())
106 .staticmethod("GetSchemaAttributeNames")
107
108 .def("_GetStaticTfType", (TfType const &(*)()) TfType::Find<This>,
109 return_value_policy<return_by_value>())
110 .staticmethod("_GetStaticTfType")
111
112 .def(!self)
113
114
115 .def("GetTypeAttr",
116 &This::GetTypeAttr)
117 .def("CreateTypeAttr",
118 &_CreateTypeAttr,
119 (arg("defaultValue")=object(),
120 arg("writeSparsely")=false))
121
122 .def("GetBasisAttr",
123 &This::GetBasisAttr)
124 .def("CreateBasisAttr",
125 &_CreateBasisAttr,
126 (arg("defaultValue")=object(),
127 arg("writeSparsely")=false))
128
129 .def("GetWrapAttr",
130 &This::GetWrapAttr)
131 .def("CreateWrapAttr",
132 &_CreateWrapAttr,
133 (arg("defaultValue")=object(),
134 arg("writeSparsely")=false))
135
136 .def("__repr__", ::_Repr)
137 ;
138
139 _CustomWrapCode(cls);
140 }
141
142 // ===================================================================== //
143 // Feel free to add custom code below this line, it will be preserved by
144 // the code generator. The entry point for your custom code should look
145 // minimally like the following:
146 //
147 // WRAP_CUSTOM {
148 // _class
149 // .def("MyCustomMethod", ...)
150 // ;
151 // }
152 //
153 // Of course any other ancillary or support code may be provided.
154 //
155 // Just remember to wrap code in the appropriate delimiters:
156 // 'namespace {', '}'.
157 //
158 // ===================================================================== //
159 // --(BEGIN CUSTOM CODE)--
160
161 namespace {
162
163 static
164 TfToken
_ComputeInterpolationForSize(const UsdGeomBasisCurves & curvesSchema,size_t n,const UsdTimeCode & timeCode)165 _ComputeInterpolationForSize(
166 const UsdGeomBasisCurves& curvesSchema,
167 size_t n,
168 const UsdTimeCode& timeCode)
169 {
170 return curvesSchema.ComputeInterpolationForSize(n, timeCode, NULL);
171 }
172
173
174
175 WRAP_CUSTOM {
176 typedef UsdGeomBasisCurves This;
177
178 _class
179 .def("ComputeInterpolationForSize", _ComputeInterpolationForSize)
180 .def("ComputeUniformDataSize", &This::ComputeUniformDataSize)
181 .def("ComputeVaryingDataSize", &This::ComputeVaryingDataSize)
182 .def("ComputeVertexDataSize", &This::ComputeVertexDataSize)
183 ;
184 }
185
186 } // anonymous namespace
187