yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #03474
[Branch ~yade-dev/yade/trunk] Rev 2046: rename sphere{From, To}File to {ymport, export}.text for consistency.
------------------------------------------------------------
revno: 2046
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-02-21 10:29:06 +0100
message:
rename sphere{From,To}File to {ymport,export}.text for consistency.
modified:
py/export.py
py/ymport.py
scripts/test/regular-sphere-pack.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/export.py'
--- py/export.py 2010-02-21 00:04:22 +0000
+++ py/export.py 2010-02-21 09:29:06 +0000
@@ -120,7 +120,7 @@
outFile.close()
self.snapCount+=1
-def spheresToFile(filename, consider=lambda id: True):
+def text(filename, consider=lambda id: True):
"""Save sphere coordinates into a text file; the format of the line is: x y z r.
Non-spherical bodies are silently skipped.
Returns number of spheres which were written.
=== modified file 'py/ymport.py'
--- py/ymport.py 2010-02-21 00:04:22 +0000
+++ py/ymport.py 2010-02-21 09:29:06 +0000
@@ -7,11 +7,11 @@
from yade import utils
-def spheresFromFile(fileName,shift=[0.0,0.0,0.0],scale=1.0,**kw):
+def text(fileName,shift=[0.0,0.0,0.0],scale=1.0,**kw):
"""Load sphere coordinates from file, create spheres, insert them to the simulation.
filename is the file which has 4 colums [x, y, z, radius].
All remaining arguments are passed the the yade.utils.sphere function which creates bodies.
- Comments, started from # are supported
+ Lines starting with # are skipped
"""
infile = open(fileName,"r")
lines = infile.readlines()
@@ -19,8 +19,8 @@
ret=[]
for line in lines:
data = line.split()
- if (data[0][0] != "#"):
- ret.append(utils.sphere([shift[0]+scale*float(data[0]),shift[1]+scale*float(data[1]),shift[2]+scale*float(data[2])],scale*float(data[3]),**kw))
+ if (data[0][0] == "#"): continue
+ ret.append(utils.sphere([shift[0]+scale*float(data[0]),shift[1]+scale*float(data[1]),shift[2]+scale*float(data[2])],scale*float(data[3]),**kw))
return ret
def stl(file, dynamic=False,wire=True,color=None,highlight=False,noBound=False,material=0):
=== modified file 'scripts/test/regular-sphere-pack.py'
--- scripts/test/regular-sphere-pack.py 2010-02-21 00:04:22 +0000
+++ scripts/test/regular-sphere-pack.py 2010-02-21 09:29:06 +0000
@@ -44,7 +44,7 @@
]: O.bodies.appendClumped(part)
-""" Example of utils.facetBox usage """
+# Example of utils.facetBox usage
q1 = Quaternion(Vector3(0,0,1),(3.14159/3))
o1,o_angl = q1.ToAxisAngle()
O.bodies.append(utils.facetBox((12,0,-6+0.9),(1,0.7,0.9),(o1[0],o1[1],o1[2],o_angl),**kwBoxes))
@@ -55,22 +55,22 @@
o1,o_angl = q1.ToAxisAngle()
O.bodies.append(utils.facetBox((-12,-12,-6+0.9),(1,0.7,0.9),(o1[0],o1[1],o1[2],o_angl),**kwBoxes))
-""" Example of utils.facetCylinder usage, RotationEngine example see below"""
+# Example of utils.facetCylinder usage, RotationEngine example see below
q1 = Quaternion(Vector3(0,0,1),(3.14159/2))
o1,o_angl = q1.ToAxisAngle()
rotateIDs=O.bodies.append(utils.facetCylinder((6.0,6.0,-4.0),2.0,4.0,(o1[0],o1[1],o1[2],o_angl),wallMask=4,segmentsNumber=10,**kwBoxes))
-"""Import regular-sphere-pack.mesh into the YADE simulation"""
+# Import regular-sphere-pack.mesh into the YADE simulation
O.bodies.append(ymport.gmsh('regular-sphere-pack.mesh',**kwMeshes))#generates facets from the mesh file
-"""Import regular-sphere-pack-LSMGenGeo.geo into the YADE simulation"""
+# Import regular-sphere-pack-LSMGenGeo.geo into the YADE simulation
O.bodies.append(ymport.gengeoFile('regular-sphere-pack-LSMGenGeo.geo',shift=[-7.0,-7.0,-5.9],scale=1.0,color=(1,0,1),**kw))
-"""spheresToFile saves coordinates and radiuses of all spheres of the simulation into the text file"""
-print "Saved into the OutFile " + str (export.spheresToFile("OutFile")) + " spheres";
+# spheresToFile saves coordinates and radiuses of all spheres of the simulation into the text file
+print "Saved into the OutFile " + str (export.text("OutFile")) + " spheres";
-"""spheresFromFile function imports coordinates and radiuses of all spheres of the simulation into the text file"""
-O.bodies.append(ymport.spheresFromFile('regular-sphere-pack-FromFile',shift=[6.0,6.0,-2.9],scale=0.7,color=(1,1,1),**kw))
+# spheresFromFile function imports coordinates and radiuses of all spheres of the simulation into the text file"""
+O.bodies.append(ymport.text('regular-sphere-pack-FromFile',shift=[6.0,6.0,-2.9],scale=0.7,color=(1,1,1),**kw))
try:
from yade import qt