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 ////////////////////////////////////////////////////////////////////////
25 // This file is generated by a script. Do not edit directly. Edit the
26 // wrapRange.template.cpp file to make changes.
27
28 #include "pxr/pxr.h"
29 #include "pxr/base/gf/range2f.h"
30 #include "pxr/base/gf/range2d.h"
31
32 #include "pxr/base/tf/pyUtils.h"
33 #include "pxr/base/tf/wrapTypeHelpers.h"
34 #include "pxr/base/tf/pyContainerConversions.h"
35
36 #include <boost/python/class.hpp>
37 #include <boost/python/copy_const_reference.hpp>
38 #include <boost/python/operators.hpp>
39 #include <boost/python/return_arg.hpp>
40
41 #include <string>
42
43 using namespace boost::python;
44
45 using std::string;
46
47 PXR_NAMESPACE_USING_DIRECTIVE
48
49 namespace {
50
51 static const int _dimension = 2;
52
_Repr(GfRange2f const & self)53 static string _Repr(GfRange2f const &self) {
54 return TF_PY_REPR_PREFIX + "Range2f(" +
55 TfPyRepr(self.GetMin()) + ", " + TfPyRepr(self.GetMax()) + ")";
56 }
57
58 #if PY_MAJOR_VERSION == 2
__truediv__(const GfRange2f & self,double value)59 static GfRange2f __truediv__(const GfRange2f &self, double value)
60 {
61 return self / value;
62 }
63
__itruediv__(GfRange2f & self,double value)64 static GfRange2f __itruediv__(GfRange2f &self, double value)
65 {
66 return self /= value;
67 }
68 #endif
69
__hash__(GfRange2f const & r)70 static size_t __hash__(GfRange2f const &r) { return hash_value(r); }
71
72 } // anonymous namespace
73
wrapRange2f()74 void wrapRange2f()
75 {
76 object getMin = make_function(&GfRange2f::GetMin,
77 return_value_policy<return_by_value>());
78
79 object getMax = make_function(&GfRange2f::GetMax,
80 return_value_policy<return_by_value>());
81
82 class_<GfRange2f>("Range2f", init<>())
83 .def(init<GfRange2f>())
84 .def(init<const GfVec2f &, const GfVec2f &>())
85
86 .def(TfTypePythonClass())
87
88 .def_readonly("dimension", _dimension)
89
90 .add_property("min", getMin, &GfRange2f::SetMin)
91 .add_property("max", getMax, &GfRange2f::SetMax)
92
93 .def("GetMin", getMin)
94 .def("GetMax", getMax)
95
96 .def("GetSize", &GfRange2f::GetSize)
97 .def("GetMidpoint", &GfRange2f::GetMidpoint)
98
99 .def("SetMin", &GfRange2f::SetMin)
100 .def("SetMax", &GfRange2f::SetMax)
101
102 .def("IsEmpty", &GfRange2f::IsEmpty)
103
104 .def("SetEmpty", &GfRange2f::SetEmpty)
105
106 .def("Contains", (bool (GfRange2f::*)(const GfVec2f &) const)
107 &GfRange2f::Contains)
108 .def("Contains", (bool (GfRange2f::*)(const GfRange2f &) const)
109 &GfRange2f::Contains)
110
111 .def("GetUnion", &GfRange2f::GetUnion)
112 .staticmethod("GetUnion")
113
114 .def("UnionWith", (const GfRange2f & (GfRange2f::*)(const GfVec2f &))
115 &GfRange2f::UnionWith, return_self<>())
116 .def("UnionWith", (const GfRange2f & (GfRange2f::*)(const GfRange2f &))
117 &GfRange2f::UnionWith, return_self<>())
118
119 .def("GetIntersection", &GfRange2f::GetIntersection)
120 .staticmethod("GetIntersection")
121
122 .def("IntersectWith", (const GfRange2f & (GfRange2f::*)(const GfRange2f &))
123 &GfRange2f::IntersectWith, return_self<>())
124
125 .def("GetDistanceSquared", &GfRange2f::GetDistanceSquared)
126
127 .def(str(self))
128 .def(self += self)
129 .def(self -= self)
130 .def(self *= double())
131 .def(self /= double())
132 .def(self + self)
133 .def(self - self)
134 .def(double() * self)
135 .def(self * double())
136 .def(self / double())
137 .def(self == GfRange2d())
138 .def(self != GfRange2d())
139 .def(self == self)
140 .def(self != self)
141
142 #if PY_MAJOR_VERSION == 2
143 // Needed only to support "from __future__ import division" in
144 // python 2. In python 3 builds boost::python adds this for us.
145 .def("__truediv__", __truediv__ )
146 .def("__itruediv__", __itruediv__ )
147 #endif
148
149 .def("__repr__", _Repr)
150 .def("__hash__", __hash__)
151
152 .def("GetCorner", &GfRange2f::GetCorner)
153 .def("GetQuadrant", &GfRange2f::GetQuadrant)
154 .def_readonly("unitSquare", &GfRange2f::UnitSquare)
155
156 ;
157 to_python_converter<std::vector<GfRange2f>,
158 TfPySequenceToPython<std::vector<GfRange2f> > >();
159
160 }
161