MCPcopy Create free account
hub / github.com/ImageEngine/cortex / testBound

Method testBound

test/IECoreScene/PointsPrimitive.py:160–252  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

158 self.assertEqual( p3.topologyHash(), p2.topologyHash() )
159
160 def testBound( self ) :
161
162 p = IECoreScene.PointsPrimitive( 2 )
163 self.assertEqual( p.bound(), imath.Box3f() )
164
165 p["P"] = IECoreScene.PrimitiveVariable(
166 IECoreScene.PrimitiveVariable.Interpolation.Vertex,
167 IECore.V3fVectorData( [ imath.V3f( 1, 2, 3 ), imath.V3f( 12, 13, 14 ) ] )
168 )
169
170 # when no width is specified, it defaults to 1
171 self.assertEqual(
172 p.bound(),
173 imath.Box3f(
174 imath.V3f( 1, 2, 3 ) - imath.V3f( 1 ) / 2.0,
175 imath.V3f( 12, 13, 14 ) + imath.V3f( 1 ) / 2.0
176 )
177 )
178
179 # constantwidth overrides the default
180 p["constantwidth"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, 2.0 )
181
182 self.assertEqual(
183 p.bound(),
184 imath.Box3f(
185 imath.V3f( 1, 2, 3 ) - imath.V3f( 2 ) / 2.0,
186 imath.V3f( 12, 13, 14 ) + imath.V3f( 2 ) / 2.0
187 )
188 )
189
190 # vertex width works too, and multiplies with constantwidth
191
192 p["width"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Vertex, IECore.FloatVectorData( [ 2, 4 ] ) )
193
194 self.assertEqual(
195 p.bound(),
196 imath.Box3f(
197 imath.V3f( 1, 2, 3 ) - imath.V3f( 2 * 2 ) / 2.0,
198 imath.V3f( 12, 13, 14 ) + imath.V3f( 2 * 4 ) / 2.0
199 )
200 )
201
202 # aspect ratio should have no effect whatsoever if type is not "patch"
203
204 p["patchaspectratio"] = IECoreScene.PrimitiveVariable( IECoreScene.PrimitiveVariable.Interpolation.Constant, 2.0 )
205 del p["width"]
206 del p["constantwidth"]
207
208 self.assertEqual(
209 p.bound(),
210 imath.Box3f(
211 imath.V3f( 1, 2, 3 ) - imath.V3f( 1 ) / 2.0,
212 imath.V3f( 12, 13, 14 ) + imath.V3f( 1 ) / 2.0
213 )
214 )
215
216 # but it should take effect when type is "patch"
217

Callers

nothing calls this directly

Calls 3

boundMethod · 0.95
PointsPrimitiveMethod · 0.80
PrimitiveVariableMethod · 0.80

Tested by

no test coverage detected