yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #06700
[Branch ~yade-dev/yade/trunk] Rev 2649: 1. python-imaging is added to installation section of sphinx-docs as well as to debian-dependency
------------------------------------------------------------
revno: 2649
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Thu 2011-01-13 11:21:10 +0100
message:
1. python-imaging is added to installation section of sphinx-docs as well as to debian-dependency
2. geom.facetHelix and facetPolygon are added with examples
modified:
debian/control-template
doc/sphinx/installation.rst
examples/packs/packs.py
py/geom.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 'debian/control-template'
--- debian/control-template 2011-01-03 19:26:59 +0000
+++ debian/control-template 2011-01-13 10:21:10 +0000
@@ -7,7 +7,7 @@
Package: yade@_VERSION@
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, python-numpy, ipython, python-matplotlib, python-tk, python-qt4, python-xlib, mencoder, gnuplot
+Depends: ${shlibs:Depends}, ${misc:Depends}, python-numpy, ipython, python-matplotlib, python-tk, python-qt4, python-xlib, mencoder, gnuplot, python-imaging
Description: Platform for discrete element modeling.
Yet Another Dynamic Engine.
Extensible open-source framework for discrete numerical models,
=== modified file 'doc/sphinx/installation.rst'
--- doc/sphinx/installation.rst 2010-11-30 15:41:55 +0000
+++ doc/sphinx/installation.rst 2011-01-13 10:21:10 +0000
@@ -62,7 +62,7 @@
python-matplotlib libsqlite3-dev python-numeric python-tk gnuplot doxygen \
libgts-dev python-pygraphviz libvtk5-dev python-scientific bzr libeigen2-dev \
binutils-gold python-xlib python-qt4 pyqt4-dev-tools \
- libqglviewer-qt4-dev
+ libqglviewer-qt4-dev python-imaging
command line (cut&paste to the terminal under root privileges) for Fedora (not good tested yet!)::
@@ -71,7 +71,7 @@
log4cxx log4cxx-devel python-devel boost-python ipython python-matplotlib \
sqlite-devel python-numeric ScientificPython-tk gnuplot doxygen gts-devel \
graphviz-python vtk-devel ScientificPython bzr eigen2-devel libQGLViewer-devel \
- loki-lib-devel python-xlib PyQt4 PyQt4-devel
+ loki-lib-devel python-xlib PyQt4 PyQt4-devel python-imaging
Compilation
=== modified file 'examples/packs/packs.py'
--- examples/packs/packs.py 2011-01-12 16:22:18 +0000
+++ examples/packs/packs.py 2011-01-13 10:21:10 +0000
@@ -1,6 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from yade import pack,ymport,export,log,geom
+import math
""" This script demonstrates how to use 2 components of creating packings:
@@ -47,23 +48,25 @@
# Example of geom.facetBox usage
-oriBody = Quaternion(Vector3(0,0,1),(3.14159/3))
+oriBody = Quaternion(Vector3(0,0,1),(math.pi/3))
O.bodies.append(geom.facetBox((12,0,-6+0.9),(1,0.7,0.9),oriBody,**kwBoxes))
-oriBody = Quaternion(Vector3(0,0,1),(3.14159/2))
+oriBody = Quaternion(Vector3(0,0,1),(math.pi/2))
O.bodies.append(geom.facetBox((0,12,-6+0.9),(1,0.7,0.9),oriBody,**kwBoxes))
-oriBody = Quaternion(Vector3(0,0,1),(3.14159))
+oriBody = Quaternion(Vector3(0,0,1),(math.pi))
O.bodies.append(geom.facetBox((-12,-12,-6+0.9),(1,0.7,0.9),oriBody,**kwBoxes))
-# Example of geom.facetCylinder usage, RotationEngine example see below
-oriBody = Quaternion(Vector3(0,0,1),(3.14159/2))
-rotateIDs=O.bodies.append(geom.facetCylinder((6.0,6.0,-4.0),2.0,4.0,oriBody,wallMask=4,segmentsNumber=10,**kwBoxes))
+# Example of geom.facetCylinder, facetHelix and RotationEngine usage example
+oriBody = Quaternion(Vector3(1,0,0),(math.pi/2.0))
+rotateIDs=O.bodies.append(geom.facetHelix((-7.0,-6.0,-5.0),radiusOuter=2.0,radiusInner=0.1,pitch=2.0,orientation=oriBody,segmentsNumber=50,angleRange=[math.pi*8.0,0],**kwBoxes))
+O.bodies.append(geom.facetCylinder((-7.0,-12.0,-5.0),radius=2.0,height=7.0,orientation=oriBody,segmentsNumber=10,wallMask=4,**kwMeshes))
+O.bodies.append(geom.facetCylinder((-7.0,-7.0,-5.0),radius=2.0,height=4.0,segmentsNumber=10,wallMask=4,angleRange=[-math.pi*0.2,math.pi*1.2],**kwMeshes))
-oriBody = Quaternion(Vector3(0,0,1),(3.14159/2))
+oriBody = Quaternion(Vector3(0,0,1),(math.pi/2))
O.bodies.append(ymport.gmsh('cone.mesh',orientation=oriBody,**kwMeshes))#generates facets from the mesh file
-oriBody = Quaternion(Vector3(0,0,1),(3.14159/2))
+oriBody = Quaternion(Vector3(0,0,1),(math.pi/2))
O.bodies.append(ymport.gengeoFile('LSMGenGeo.geo',shift=Vector3(-7.0,-7.0,0.0),scale=1.0,orientation=oriBody,color=(1,0,1),**kw))
#facetBunker Demonstration
@@ -104,10 +107,10 @@
NewtonIntegrator(damping=.1,exactAsphericalRot=True),
RotationEngine(
ids=rotateIDs,
- angularVelocity=10.0,
- rotationAxis=[0,0,1],
+ angularVelocity=100.0,
+ rotationAxis=[0,-1,0],
rotateAroundZero=1,
- zeroPoint=[6.0,6.0,0.0]),
+ zeroPoint=[-7.0,-6.0,-5.0]),
HarmonicMotionEngine(A=[0,0,0.5], f=[0,0,20.0], fi = [0.0,0.0,pi], ids = vibrationPlate),
HarmonicRotationEngine(A=0.2, f=20.0, fi = pi, rotationAxis=[1.0,0.0,0.0], rotateAroundZero = True, zeroPoint = [-15.0,3.0,-7.0], ids = vibrationRotationPlate)
]
=== modified file 'py/geom.py'
--- py/geom.py 2011-01-12 16:22:18 +0000
+++ py/geom.py 2011-01-13 10:21:10 +0000
@@ -8,6 +8,7 @@
from miniEigen import *
import utils,math,numpy
+#facetBox===============================================================
def facetBox(center,extents,orientation=Quaternion.Identity,wallMask=63,**kw):
"""
Create arbitrarily-aligned box composed of facets, with given center, extents and orientation.
@@ -21,7 +22,6 @@
:returns: list of facets forming the box
"""
-
#Defense from zero dimensions
if (wallMask>63):
print "wallMask must be 63 or less"
@@ -56,7 +56,8 @@
if wallMask&16: ret+=doWall(A,B,C,D)
if wallMask&32: ret+=doWall(E,H,G,F)
return ret
-
+
+#facetCylinder==========================================================
def facetCylinder(center,radius,height,orientation=Quaternion.Identity,segmentsNumber=10,wallMask=7,angleRange=None,closeGap=False,**kw):
"""
Create arbitrarily-aligned cylinder composed of facets, with given center, radius, height and orientation.
@@ -68,7 +69,7 @@
:param Quaternion orientation: orientation of the cylinder; the reference orientation has axis along the $+x$ axis.
:param int segmentsNumber: number of edges on the cylinder surface (>=5)
:param bitmask wallMask: determines which walls will be created, in the order up (1), down (2), side (4). The numbers are ANDed; the default 7 means to create all walls
- :param (θmin,Îmax) angleRange: allows to create only part of cylinder by specifying range of angles; if ``None``, (0,2*pi) is assumed.
+ :param (θmin,Îmax) angleRange: allows to create only part of bunker by specifying range of angles; if ``None``, (0,2*pi) is assumed.
:param bool closeGap: close range skipped in angleRange with triangular facets at cylinder bases.
:param **kw: (unused keyword arguments) passed to utils.facet;
"""
@@ -77,6 +78,8 @@
return facetCylinderConeGenerator(center=center,radiusTop=radius,height=height,orientation=orientation,segmentsNumber=segmentsNumber,wallMask=wallMask,angleRange=angleRange,closeGap=closeGap,**kw)
+
+#facetCone==============================================================
def facetCone(center,radiusTop,radiusBottom,height,orientation=Quaternion.Identity,segmentsNumber=10,wallMask=7,angleRange=None,closeGap=False,**kw):
"""
Create arbitrarily-aligned cone composed of facets, with given center, radius, height and orientation.
@@ -97,73 +100,46 @@
if ((radiusBottom<=0) and (radiusTop<=0)): raise RuntimeError("The radiusBottom or radiusTop should have the positive value");
return facetCylinderConeGenerator(center=center,radiusTop=radiusTop,radiusBottom=radiusBottom,height=height,orientation=orientation,segmentsNumber=segmentsNumber,wallMask=wallMask,angleRange=angleRange,closeGap=closeGap,**kw)
-
-def facetCylinderConeGenerator(center,radiusTop,height,orientation=Quaternion.Identity,segmentsNumber=10,wallMask=7,angleRange=None,closeGap=False,radiusBottom=-1,**kw):
- """
- Please, do not use this function directly! Use geom.facetCylinder and geom.facetCone instead.
- This is the base function for generating cylinders and cones from facets.
- :param float radiusTop: top radius
- :param float radiusBottom: bottom radius
- :param **kw: (unused keyword arguments) passed to utils.facet;
- """
-
- #For cylinders top and bottom radii are equal
- if (radiusBottom == -1):
- radiusBottom = radiusTop
- # check zero dimentions
- if (segmentsNumber<3): raise RuntimeError("The segmentsNumber should be at least 3");
- if (height<=0): raise RuntimeError("The height should have the positive value");
- if angleRange==None: angleRange=(0,2*math.pi)
- if (abs(angleRange[1]-angleRange[0]>2.0*math.pi)): raise RuntimeError("The |angleRange| cannot be larger 2.0*math.pi");
-
- if isinstance(angleRange,float):
- print u'WARNING: geom.facetCylinder,angleRange should be (Îmin,Îmax), not just Îmax (one number), update your code.'
- angleRange=(0,angleRange)
-
- anglesInRad = numpy.linspace(angleRange[0], angleRange[1], segmentsNumber+1, endpoint=True)
-
- PTop=[]; PTop.append(Vector3(0,0,+height/2))
- PBottom=[]; PBottom.append(Vector3(0,0,-height/2))
-
- for i in anglesInRad:
- XTop=radiusTop*math.cos(i); YTop=radiusTop*math.sin(i);
- PTop.append(Vector3(XTop,YTop,+height/2))
-
- XBottom=radiusBottom*math.cos(i); YBottom=radiusBottom*math.sin(i);
- PBottom.append(Vector3(XBottom,YBottom,-height/2))
-
- for i in range(0,len(PTop)):
- PTop[i]=orientation*PTop[i]+center
- PBottom[i]=orientation*PBottom[i]+center
-
- ret=[]
- for i in range(2,len(PTop)):
- if (wallMask&1)and(radiusTop!=0):
- ret.append(utils.facet((PTop[0],PTop[i],PTop[i-1]),**kw))
-
- if (wallMask&2)and(radiusBottom!=0):
- ret.append(utils.facet((PBottom[0],PBottom[i-1],PBottom[i]),**kw))
-
- if wallMask&4:
- if (radiusBottom!=0):
- ret.append(utils.facet((PTop[i],PBottom[i],PBottom[i-1]),**kw))
- if (radiusTop!=0):
- ret.append(utils.facet((PBottom[i-1],PTop[i-1],PTop[i]),**kw))
-
- if closeGap and (angleRange[0]%(2*math.pi))!=(angleRange[1]%(2*math.pi)and(abs(angleRange[1]-angleRange[0])>math.pi)): # some part is skipped
- if (wallMask&1)and(radiusTop!=0):
- pts=[(radiusTop*math.cos(angleRange[i]),radiusTop*math.sin(angleRange[i])) for i in (0,1)]
- pp=[(pts[0][0],pts[0][1],+height/2.0),(pts[1][0],pts[1][1],+height/2.0),(0,0,+height/2.0)]
- pp=[orientation*p+center for p in pp]
- ret.append(utils.facet(pp,**kw))
-
- if (wallMask&2)and(radiusBottom!=0):
- pts=[(radiusBottom*math.cos(angleRange[i]),radiusBottom*math.sin(angleRange[i])) for i in (0,1)]
- pp=[(pts[0][0],pts[0][1],-height/2.0),(pts[1][0],pts[1][1],-height/2.0),(0,0,-height/2.0)]
- pp=[orientation*p+center for p in pp]
- ret.append(utils.facet(pp,**kw))
- return ret
-
+
+#facetPolygon===========================================================
+def facetPolygon(center,radiusOuter,orientation=Quaternion.Identity,segmentsNumber=10,angleRange=None,radiusInner=0,**kw):
+ """
+ Create arbitrarily-aligned polygon composed of facets, with given center, radius (outer and inner) and orientation.
+ Return List of facets forming the polygon;
+
+ :param Vector3 center: center of the created cylinder
+ :param float radiusOuter: outer radius
+ :param float radiusInner: inner height (can be 0)
+ :param Quaternion orientation: orientation of the polygon; the reference orientation has axis along the $+x$ axis.
+ :param int segmentsNumber: number of edges on the polygon surface (>=3)
+ :param (θmin,Îmax) angleRange: allows to create only part of polygon by specifying range of angles; if ``None``, (0,2*pi) is assumed.
+ :param **kw: (unused keyword arguments) passed to utils.facet;
+ """
+ # check zero dimentions
+ if (abs(angleRange[1]-angleRange[0])>2.0*math.pi): raise RuntimeError("The |angleRange| cannot be larger 2.0*math.pi");
+
+ return facetPolygonHelixGenerator(center=center,radiusOuter=radiusOuter,orientation=orientation,segmentsNumber=segmentsNumber,angleRange=angleRange,radiusInner=radiusInner,**kw)
+
+#facetHelix===========================================================
+def facetHelix(center,radiusOuter,pitch,orientation=Quaternion.Identity,segmentsNumber=10,angleRange=None,radiusInner=0,**kw):
+ """
+ Create arbitrarily-aligned helix composed of facets, with given center, radius (outer and inner), pitch and orientation.
+ Return List of facets forming the helix;
+
+ :param Vector3 center: center of the created cylinder
+ :param float radiusOuter: outer radius
+ :param float radiusInner: inner height (can be 0)
+ :param Quaternion orientation: orientation of the helix; the reference orientation has axis along the $+x$ axis.
+ :param int segmentsNumber: number of edges on the helix surface (>=3)
+ :param (θmin,Îmax) angleRange: range of angles; if ``None``, (0,2*pi) is assumed.
+ :param **kw: (unused keyword arguments) passed to utils.facet;
+ """
+
+ # check zero dimentions
+ if (pitch<=0): raise RuntimeError("The pitch should have the positive value");
+ return facetPolygonHelixGenerator(center=center,radiusOuter=radiusOuter,orientation=orientation,segmentsNumber=segmentsNumber,angleRange=angleRange,radiusInner=radiusInner,pitch=pitch,**kw)
+
+#facetBunker============================================================
def facetBunker(center,dBunker,dOutput,hBunker,hOutput,hPipe=0.0,orientation=Quaternion.Identity,segmentsNumber=10,wallMask=4,angleRange=None,closeGap=False,**kw):
"""
Create arbitrarily-aligned bunker, composed of facets, with given center, radii, heights and orientation.
@@ -194,10 +170,10 @@
:param float hBunker: bunker height
:param float hOutput: bunker output height
:param float hPipe: bunker pipe height
- :param Quaternion orientation: orientation of the cone; the reference orientation has axis along the $+x$ axis.
- :param int segmentsNumber: number of edges on the cone surface (>=5)
+ :param Quaternion orientation: orientation of the bunker; the reference orientation has axis along the $+x$ axis.
+ :param int segmentsNumber: number of edges on the bunker surface (>=5)
:param bitmask wallMask: determines which walls will be created, in the order up (1), down (2), side (4). The numbers are ANDed; the default 7 means to create all walls
- :param (θmin,Îmax) angleRange: allows to create only part of cone by specifying range of angles; if ``None``, (0,2*pi) is assumed.
+ :param (θmin,Îmax) angleRange: allows to create only part of bunker by specifying range of angles; if ``None``, (0,2*pi) is assumed.
:param bool closeGap: close range skipped in angleRange with triangular facets at cylinder bases.
:param **kw: (unused keyword arguments) passed to utils.facet;
"""
@@ -219,9 +195,120 @@
centerBunker = Vector3(0.0,0.0,hPipe+hOutput+hBunker/2.0)
ret+=facetCylinder(center=centerBunker,radius=dBunker/2.0,height=hBunker,segmentsNumber=segmentsNumber,wallMask=wallMask&5,angleRange=angleRange,closeGap=closeGap,**kw)
-
for i in ret:
i.state.pos=orientation*(i.state.pos)+Vector3(center)
i.state.ori=orientation
return ret
+
+#facetPolygonHelixGenerator==================================================
+def facetPolygonHelixGenerator(center,radiusOuter,pitch=0,orientation=Quaternion.Identity,segmentsNumber=10,angleRange=None,radiusInner=0,**kw):
+ """
+ Please, do not use this function directly! Use geom.facetPloygon and geom.facetHelix instead.
+ This is the base function for generating polygons and helixes from facets.
+ """
+ # check zero dimentions
+ if (segmentsNumber<3): raise RuntimeError("The segmentsNumber should be at least 3");
+ if (radiusOuter<=0): raise RuntimeError("The radiusOuter should have the positive value");
+ if (radiusInner<0): raise RuntimeError("The radiusInner should have the positive value or 0");
+ if angleRange==None: angleRange=(0,2*math.pi)
+
+ anglesInRad = numpy.linspace(angleRange[0], angleRange[1], segmentsNumber+1, endpoint=True)
+ heightsInRad = numpy.linspace(0, pitch*(abs(angleRange[1]-angleRange[0])/(2.0*math.pi)), segmentsNumber+1, endpoint=True)
+
+ POuter=[];
+ PInner=[];
+ PCenter=[];
+ z=0;
+ for i in anglesInRad:
+ XOuter=radiusOuter*math.cos(i); YOuter=radiusOuter*math.sin(i);
+ POuter.append(Vector3(XOuter,YOuter,heightsInRad[z]))
+ PCenter.append(Vector3(0,0,heightsInRad[z]))
+ if (radiusInner<>0):
+ XInner=radiusInner*math.cos(i); YInner=radiusInner*math.sin(i);
+ PInner.append(Vector3(XInner,YInner,heightsInRad[z]))
+ z+=1
+
+ for i in range(0,len(POuter)):
+ POuter[i]=orientation*POuter[i]+center
+ PCenter[i]=orientation*PCenter[i]+center
+ if (radiusInner<>0):
+ PInner[i]=orientation*PInner[i]+center
+
+ ret=[]
+ for i in range(1,len(POuter)):
+ if (radiusInner==0):
+ ret.append(utils.facet((PCenter[i],POuter[i],POuter[i-1]),**kw))
+ else:
+ ret.append(utils.facet((PInner[i-1],POuter[i-1],POuter[i]),**kw))
+ ret.append(utils.facet((PInner[i],PInner[i-1],POuter[i]),**kw))
+
+ return ret
+
+
+#facetCylinderConeGenerator=============================================
+def facetCylinderConeGenerator(center,radiusTop,height,orientation=Quaternion.Identity,segmentsNumber=10,wallMask=7,angleRange=None,closeGap=False,radiusBottom=-1,**kw):
+ """
+ Please, do not use this function directly! Use geom.facetCylinder and geom.facetCone instead.
+ This is the base function for generating cylinders and cones from facets.
+ :param float radiusTop: top radius
+ :param float radiusBottom: bottom radius
+ :param **kw: (unused keyword arguments) passed to utils.facet;
+ """
+
+ #For cylinders top and bottom radii are equal
+ if (radiusBottom == -1):
+ radiusBottom = radiusTop
+ # check zero dimentions
+ if (segmentsNumber<3): raise RuntimeError("The segmentsNumber should be at least 3");
+ if (height<=0): raise RuntimeError("The height should have the positive value");
+ if angleRange==None: angleRange=(0,2*math.pi)
+ if (abs(angleRange[1]-angleRange[0])>2.0*math.pi): raise RuntimeError("The |angleRange| cannot be larger 2.0*math.pi");
+
+ if isinstance(angleRange,float):
+ print u'WARNING: geom.facetCylinder,angleRange should be (Îmin,Îmax), not just Îmax (one number), update your code.'
+ angleRange=(0,angleRange)
+
+ anglesInRad = numpy.linspace(angleRange[0], angleRange[1], segmentsNumber+1, endpoint=True)
+
+ PTop=[]; PTop.append(Vector3(0,0,+height/2))
+ PBottom=[]; PBottom.append(Vector3(0,0,-height/2))
+
+ for i in anglesInRad:
+ XTop=radiusTop*math.cos(i); YTop=radiusTop*math.sin(i);
+ PTop.append(Vector3(XTop,YTop,+height/2))
+
+ XBottom=radiusBottom*math.cos(i); YBottom=radiusBottom*math.sin(i);
+ PBottom.append(Vector3(XBottom,YBottom,-height/2))
+
+ for i in range(0,len(PTop)):
+ PTop[i]=orientation*PTop[i]+center
+ PBottom[i]=orientation*PBottom[i]+center
+
+ ret=[]
+ for i in range(2,len(PTop)):
+ if (wallMask&1)and(radiusTop!=0):
+ ret.append(utils.facet((PTop[0],PTop[i],PTop[i-1]),**kw))
+
+ if (wallMask&2)and(radiusBottom!=0):
+ ret.append(utils.facet((PBottom[0],PBottom[i-1],PBottom[i]),**kw))
+
+ if wallMask&4:
+ if (radiusBottom!=0):
+ ret.append(utils.facet((PTop[i],PBottom[i],PBottom[i-1]),**kw))
+ if (radiusTop!=0):
+ ret.append(utils.facet((PBottom[i-1],PTop[i-1],PTop[i]),**kw))
+
+ if closeGap and (angleRange[0]%(2*math.pi))!=(angleRange[1]%(2*math.pi)and(abs(angleRange[1]-angleRange[0])>math.pi)): # some part is skipped
+ if (wallMask&1)and(radiusTop!=0):
+ pts=[(radiusTop*math.cos(angleRange[i]),radiusTop*math.sin(angleRange[i])) for i in (0,1)]
+ pp=[(pts[0][0],pts[0][1],+height/2.0),(pts[1][0],pts[1][1],+height/2.0),(0,0,+height/2.0)]
+ pp=[orientation*p+center for p in pp]
+ ret.append(utils.facet(pp,**kw))
+
+ if (wallMask&2)and(radiusBottom!=0):
+ pts=[(radiusBottom*math.cos(angleRange[i]),radiusBottom*math.sin(angleRange[i])) for i in (0,1)]
+ pp=[(pts[0][0],pts[0][1],-height/2.0),(pts[1][0],pts[1][1],-height/2.0),(0,0,-height/2.0)]
+ pp=[orientation*p+center for p in pp]
+ ret.append(utils.facet(pp,**kw))
+ return ret