← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3675: corrected bug in utils.UnstructuredGrid.updateElements (question #267761)

 

------------------------------------------------------------
revno: 3675
committer: Jan Stransky <jan.stransky@xxxxxxxxxxx>
timestamp: Wed 2015-06-10 10:07:09 +0200
message:
  corrected bug in utils.UnstructuredGrid.updateElements (question #267761)
modified:
  py/utils.py


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'py/utils.py'
--- py/utils.py	2015-06-02 23:32:38 +0000
+++ py/utils.py	2015-06-10 08:07:09 +0000
@@ -1084,7 +1084,12 @@
 			e.state.pos = Vector3(0,0,0)
 			e.state.ori = Quaternion((1,0,0),0)
 			if isinstance(e.shape,Facet):
-				e.shape.vertices = [self.vertices[j] for j in c]
+				#e.shape.vertices = [self.vertices[j] for j in c]
+				vs = [Vector3(self.vertices[j]) for j in c]
+				cc = sum(vs,Vector3.Zero)/3.
+				for v in vs: v -= cc
+				e.state.pos = cc
+				e.shape.setVertices(vs)
 			elif isinstance(e.shape,Tetra):
 				e.shape.v = [self.vertices[j] for j in c]
 			else: