yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #07705
[Branch ~yade-dev/yade/trunk] Rev 2876: Fix an error, when spheresPackDimensions tried to get states of non-existent bodies
------------------------------------------------------------
revno: 2876
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Thu 2011-06-16 09:11:37 +0200
message:
Fix an error, when spheresPackDimensions tried to get states of non-existent bodies
modified:
py/bodiesHandling.py
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'py/bodiesHandling.py'
--- py/bodiesHandling.py 2011-02-23 15:29:44 +0000
+++ py/bodiesHandling.py 2011-06-16 07:11:37 +0000
@@ -38,24 +38,26 @@
else:
raise TypeError("Unknow type of data, should be list of int's or bodies's")
- spherePosition=b.state.pos
- try:
- sphereRadius=b.shape.radius #skip non-spheres
- except AttributeError: continue
-
- sphereRadiusVec3 = Vector3(sphereRadius,sphereRadius,sphereRadius)
-
- sphereMax = spherePosition + sphereRadiusVec3
- sphereMin = spherePosition - sphereRadiusVec3
-
- for dim in range(0,3):
- if ((sphereMax[dim]>max[dim]) or (counter==0)):
- max[dim]=sphereMax[dim]
- maxId[dim] = b.id
- if ((sphereMin[dim]<min[dim]) or (counter==0)):
- min[dim]=sphereMin[dim]
- minId[dim] = b.id
- counter += 1
+ if (b):
+ spherePosition=b.state.pos #skip non-existent spheres
+
+ try:
+ sphereRadius=b.shape.radius #skip non-spheres
+ except AttributeError: continue
+
+ sphereRadiusVec3 = Vector3(sphereRadius,sphereRadius,sphereRadius)
+
+ sphereMax = spherePosition + sphereRadiusVec3
+ sphereMin = spherePosition - sphereRadiusVec3
+
+ for dim in range(0,3):
+ if ((sphereMax[dim]>max[dim]) or (counter==0)):
+ max[dim]=sphereMax[dim]
+ maxId[dim] = b.id
+ if ((sphereMin[dim]<min[dim]) or (counter==0)):
+ min[dim]=sphereMin[dim]
+ minId[dim] = b.id
+ counter += 1
center = (max-min)/2.0+min
extends = max-min