← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2909: Small changes in yade.ymport.unv and corresponding example

 

------------------------------------------------------------
revno: 2909
committer: Jan Stransky <honzik.stransky@xxxxxxxxx>
branch nick: yade
timestamp: Sat 2011-08-27 20:10:30 +0200
message:
  Small changes in yade.ymport.unv and corresponding example
modified:
  py/ymport.py
  scripts/test/unvRead.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/ymport.py'
--- py/ymport.py	2011-08-27 17:40:30 +0000
+++ py/ymport.py	2011-08-27 18:10:30 +0000
@@ -248,7 +248,9 @@
 	# class used in ymport.unv function
 	# reads and evaluate given unv file and extracts all triangles
 	# can be extended to read tetrahedrons as well
-	def __init__(self,fileName,shift,scale):
+	def __init__(self,fileName,shift=(0,0,0),scale=1.0):
+		self.shift = shift
+		self.scale = scale
 		self.unvFile = open(fileName,'r')
 		self.flag = 0
 		self.line = self.unvFile.readline()
@@ -277,14 +279,20 @@
 		#elif self.flag == 4: self.evalGroup()
 	def evalVertices(self):
 		self.readLine()
-		self.vertices.append(Vector3(float(self.lineSplit[0]),float(self.lineSplit[1]),float(self.lineSplit[2])))
+		self.vertices.append((
+			self.shift[0]+self.scale*float(self.lineSplit[0]),
+			self.shift[1]+self.scale*float(self.lineSplit[1]),
+			self.shift[2]+self.scale*float(self.lineSplit[2])))
 	def evalEdge(self):
 		if self.lineSplit[1]=='41': self.flag = 3; self.evalFacet()
 		else: self.readLine(); self.readLine()
 	def evalFacet(self):
 		if self.lineSplit[1]=='41': # triangle
 			self.readLine()
-			self.verticesTris.append([self.vertices[int(self.lineSplit[0])-1],self.vertices[int(self.lineSplit[1])-1],self.vertices[int(self.lineSplit[2])-1]])
+			self.verticesTris.append([
+				self.vertices[int(self.lineSplit[0])-1],
+				self.vertices[int(self.lineSplit[1])-1],
+				self.vertices[int(self.lineSplit[2])-1]])
 		else: # is not triangle
 			self.readLine()
 			self.flag = 4

=== modified file 'scripts/test/unvRead.py'
--- scripts/test/unvRead.py	2011-08-27 17:40:30 +0000
+++ scripts/test/unvRead.py	2011-08-27 18:10:30 +0000
@@ -1,7 +1,7 @@
 from yade import *
 from yade import ymport
 
-facets = ymport.unv('shell.unv')
+facets = ymport.unv('shell.unv',shift=(100,200,300),scale=1000)
 O.bodies.append([f for f in facets])
 
 try: