← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2648: 1. Fixed warnings in packs.py->utils.py

 

------------------------------------------------------------
revno: 2648
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Wed 2011-01-12 17:22:18 +0100
message:
  1. Fixed warnings in packs.py->utils.py
  2. Created geom.py module for generating geometrical forms from facets.
  3. utils.facetBox and utils.facetCylinder have been moved to geom.facetBox and geom.facetCylinder respectively. Backward compatibility is saved. Examples are fixed.
  4. closeGap in utils.facetCylinder and utils.facetCone works now only when |anglRange|>math.pi
  5. geom.facetBunker is added with corresponding example in pack.py
added:
  py/geom.py
modified:
  examples/bulldozer/bulldozer.py
  examples/bulldozer/bulldozerVTK.py
  examples/packs/packs.py
  py/SConscript
  py/tests/__init__.py
  py/utils.py
  scripts/test/facet-box.py
  scripts/test/hdaps.py
  scripts/test/shots.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 'examples/bulldozer/bulldozer.py'
--- examples/bulldozer/bulldozer.py	2010-12-26 15:42:43 +0000
+++ examples/bulldozer/bulldozer.py	2011-01-12 16:22:18 +0000
@@ -33,12 +33,12 @@
 KnifeIDs=O.bodies.append(pack.gtsSurface2Facets(KnifePoly,color=(1,0,0),wire=False))
 
 
-KnifeIDs+=O.bodies.append(utils.facetBox((-lengthKnife/2-radiusKnife,lengthKnife/2,-radiusKnife+buldozerHeight/2),(lengthKnife/2,lengthKnife/2,buldozerHeight/2.),wallMask=47,color=(0,1,0),wire=False))
-
-KnifeIDs+=O.bodies.append(utils.facetBox((-lengthKnife/2-radiusKnife-lengthKnife/4.,lengthKnife/2,-radiusKnife+buldozerHeight*3./2.-buldozerHeight/4.),(lengthKnife/4.,lengthKnife/3.,buldozerHeight/4.),wallMask=47,color=(0,0,1),wire=False))
-
-
-O.bodies.append(utils.facetBox((0,lengthKnife/2,radiusKnife),(lengthKnife*4,lengthKnife*4,lengthKnife),wallMask=16,color=(1,1,1),wire=False))
+KnifeIDs+=O.bodies.append(geom.facetBox((-lengthKnife/2-radiusKnife,lengthKnife/2,-radiusKnife+buldozerHeight/2),(lengthKnife/2,lengthKnife/2,buldozerHeight/2.),wallMask=47,color=(0,1,0),wire=False))
+
+KnifeIDs+=O.bodies.append(geom.facetBox((-lengthKnife/2-radiusKnife-lengthKnife/4.,lengthKnife/2,-radiusKnife+buldozerHeight*3./2.-buldozerHeight/4.),(lengthKnife/4.,lengthKnife/3.,buldozerHeight/4.),wallMask=47,color=(0,0,1),wire=False))
+
+
+O.bodies.append(geom.facetBox((0,lengthKnife/2,radiusKnife),(lengthKnife*4,lengthKnife*4,lengthKnife),wallMask=16,color=(1,1,1),wire=False))
 
 
 

=== modified file 'examples/bulldozer/bulldozerVTK.py'
--- examples/bulldozer/bulldozerVTK.py	2010-09-27 17:47:59 +0000
+++ examples/bulldozer/bulldozerVTK.py	2011-01-12 16:22:18 +0000
@@ -41,11 +41,11 @@
 KnifePoly=pack.sweptPolylines2gtsSurface(KnifeP,threshold=1e-4)
 KnifeIDs=O.bodies.append(pack.gtsSurface2Facets(KnifePoly,color=(1,0,0),wire=False,material=facetMat))
 
-KnifeIDs+=O.bodies.append(utils.facetBox((-lengthKnife/2-radiusKnife,lengthKnife/2,-radiusKnife+buldozerHeight/2),(lengthKnife/2,lengthKnife/2,buldozerHeight/2.),wallMask=47,color=(0,1,0),wire=False))
-
-KnifeIDs+=O.bodies.append(utils.facetBox((-lengthKnife/2-radiusKnife-lengthKnife/4.,lengthKnife/2,-radiusKnife+buldozerHeight*3./2.-buldozerHeight/4.),(lengthKnife/4.,lengthKnife/3.,buldozerHeight/4.),wallMask=47,color=(0,0,1),wire=False))
-
-O.bodies.append(utils.facetBox((0,0,radiusKnife),(lengthKnife*3,lengthKnife*3,lengthKnife),wallMask=16,color=(1,1,1),wire=False,material=facetMat))
+KnifeIDs+=O.bodies.append(geom.facetBox((-lengthKnife/2-radiusKnife,lengthKnife/2,-radiusKnife+buldozerHeight/2),(lengthKnife/2,lengthKnife/2,buldozerHeight/2.),wallMask=47,color=(0,1,0),wire=False))
+
+KnifeIDs+=O.bodies.append(geom.facetBox((-lengthKnife/2-radiusKnife-lengthKnife/4.,lengthKnife/2,-radiusKnife+buldozerHeight*3./2.-buldozerHeight/4.),(lengthKnife/4.,lengthKnife/3.,buldozerHeight/4.),wallMask=47,color=(0,0,1),wire=False))
+
+O.bodies.append(geom.facetBox((0,0,radiusKnife),(lengthKnife*3,lengthKnife*3,lengthKnife),wallMask=16,color=(1,1,1),wire=False,material=facetMat))
 
 
 ### Creating the material for buldozer

=== modified file 'examples/packs/packs.py'
--- examples/packs/packs.py	2010-12-20 13:44:40 +0000
+++ examples/packs/packs.py	2011-01-12 16:22:18 +0000
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
-from yade import pack,ymport,export,log
+from yade import pack,ymport,export,log,geom
 
 """ This script demonstrates how to use 2 components of creating packings:
 
@@ -46,25 +46,29 @@
 	]: O.bodies.appendClumped(part)
 
 
-# Example of utils.facetBox usage 
+# Example of geom.facetBox usage 
 oriBody = Quaternion(Vector3(0,0,1),(3.14159/3))
-O.bodies.append(utils.facetBox((12,0,-6+0.9),(1,0.7,0.9),oriBody,**kwBoxes))
+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))
-O.bodies.append(utils.facetBox((0,12,-6+0.9),(1,0.7,0.9),oriBody,**kwBoxes))
+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))
-O.bodies.append(utils.facetBox((-12,-12,-6+0.9),(1,0.7,0.9),oriBody,**kwBoxes))
+O.bodies.append(geom.facetBox((-12,-12,-6+0.9),(1,0.7,0.9),oriBody,**kwBoxes))
 
-# Example of utils.facetCylinder usage, RotationEngine example see below
+# Example of geom.facetCylinder usage, RotationEngine example see below
 oriBody = Quaternion(Vector3(0,0,1),(3.14159/2))
-rotateIDs=O.bodies.append(utils.facetCylinder((6.0,6.0,-4.0),2.0,4.0,oriBody,wallMask=4,segmentsNumber=10,**kwBoxes))
+rotateIDs=O.bodies.append(geom.facetCylinder((6.0,6.0,-4.0),2.0,4.0,oriBody,wallMask=4,segmentsNumber=10,**kwBoxes))
 
 oriBody = Quaternion(Vector3(0,0,1),(3.14159/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))
-O.bodies.append(ymport.gengeoFile('LSMGenGeo.geo',shift=Vector3(-7.0,-7.0,-5.9),scale=1.0,orientation=oriBody,color=(1,0,1),**kw))
+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
+#Demonstration of HarmonicMotionEngine
+vibrationPlate = O.bodies.append(geom.facetBunker((-7.0,-7.0,-3.0),dBunker=5.0,dOutput=3.0,hBunker=11.0,hOutput=1.5,hPipe=0.8,wallMask=5,segmentsNumber=20,**kwMeshes))
 
 # spheresToFile saves coordinates and radii of all spheres of the simulation into the text file, works but disabled. Please, uncomment it, if you need
 #print "Saved into the OutFile " + str (export.text("OutFile")) + " spheres";
@@ -72,26 +76,20 @@
 # spheresFromFile function imports coordinates and radii of all spheres of the simulation into the text file
 O.bodies.append(ymport.text('foo.spheres',shift=Vector3(6.0,6.0,-2.9),scale=0.7,color=(1,1,1),**kw))
 
-#Demonstration of HarmonicMotionEngine
-O.bodies.append(pack.regularHexa(pack.inSphere((-10,5,-5),1.5),radius=rad*2.0,gap=rad/3.0,color=(0.2,0.5,0.9),material=0))
-O.bodies.append(utils.facetBox((-10,5,-5),(2,2,2),wallMask=15,**kwMeshes))
-vibrationPlate = O.bodies.append(utils.facetBox((-10,5,-5),(2,2,2),wallMask=16,**kwBoxes))
-
 #Demonstration of HarmonicRotationEngine
 O.bodies.append(pack.regularHexa(pack.inSphere((-15,5,-5),1.5),radius=rad*2.0,gap=rad/3.0,color=(0.5,0.5,0.1),material=0))
-O.bodies.append(utils.facetBox((-15,5,-5),(2,2,2),wallMask=15,**kwMeshes))
-vibrationRotationPlate = O.bodies.append(utils.facetBox((-15,5,-5),(2,2,2),wallMask=16,**kwBoxes))
+O.bodies.append(geom.facetBox((-15,5,-5),(2,2,2),wallMask=15,**kwMeshes))
+vibrationRotationPlate = O.bodies.append(geom.facetBox((-15,5,-5),(2,2,2),wallMask=16,**kwBoxes))
 
 O.bodies.append(utils.wall((0,0,-10),axis=2))
 
-
 try:
 	from yade import qt
 	qt.Controller()
 	qt.View()
 except ImportError: pass
 
-log.setLevel('SubdomainBalancer',log.TRACE)
+#log.setLevel('SubdomainBalancer',log.TRACE)
 
 O.engines=[
 	#SubdomainBalancer(colorize=True,initRun=True,iterPeriod=100),

=== modified file 'py/SConscript'
--- py/SConscript	2010-11-06 11:33:09 +0000
+++ py/SConscript	2011-01-12 16:22:18 +0000
@@ -25,6 +25,7 @@
 	env.AlwaysBuild(env.ScanReplace('config.py.in')),
 	env.File('utils.py'),
 	env.File('ymport.py'),
+	env.File('geom.py'),
 	env.File('export.py'),
 	env.File('eudoxos.py'),
 	env.File('plot.py'),

=== added file 'py/geom.py'
--- py/geom.py	1970-01-01 00:00:00 +0000
+++ py/geom.py	2011-01-12 16:22:18 +0000
@@ -0,0 +1,227 @@
+#!/usr/bin/python
+# encoding: utf-8
+"""
+Creates geometry objects from facets.
+"""
+
+from yade.wrapper import *
+from miniEigen import *
+import utils,math,numpy
+
+def facetBox(center,extents,orientation=Quaternion.Identity,wallMask=63,**kw):
+	"""
+	Create arbitrarily-aligned box composed of facets, with given center, extents and orientation.
+	If any of the box dimensions is zero, corresponding facets will not be created. The facets are oriented outwards from the box.
+
+	:param Vector3 center: center of the box
+	:param Vector3 extents: lengths of the box sides
+	:param Quaternion orientation: orientation of the box
+	:param bitmask wallMask: determines which walls will be created, in the order -x (1), +x (2), -y (4), +y (8), -z (16), +z (32). The numbers are ANDed; the default 63 means to create all walls
+	:param **kw: (unused keyword arguments) passed to :yref:`yade.utils.facet`
+	:returns: list of facets forming the box
+	"""
+
+
+	#Defense from zero dimensions
+	if (wallMask>63):
+		print "wallMask must be 63 or less"
+		wallMask=63
+	if (extents[0]==0):
+		wallMask=1
+	elif (extents[1]==0):
+		wallMask=4
+	elif (extents[2]==0):
+		wallMask=16
+	if (((extents[0]==0) and (extents[1]==0)) or ((extents[0]==0) and (extents[2]==0)) or ((extents[1]==0) and (extents[2]==0))):
+		raise RuntimeError("Please, specify at least 2 none-zero dimensions in extents!");
+	# ___________________________
+
+	mn,mx=[-extents[i] for i in 0,1,2],[extents[i] for i in 0,1,2]
+	def doWall(a,b,c,d):
+		return [utils.facet((a,b,c),**kw),utils.facet((a,c,d),**kw)]
+	ret=[]
+
+	A=orientation*Vector3(mn[0],mn[1],mn[2])+center
+	B=orientation*Vector3(mx[0],mn[1],mn[2])+center
+	C=orientation*Vector3(mx[0],mx[1],mn[2])+center
+	D=orientation*Vector3(mn[0],mx[1],mn[2])+center
+	E=orientation*Vector3(mn[0],mn[1],mx[2])+center
+	F=orientation*Vector3(mx[0],mn[1],mx[2])+center
+	G=orientation*Vector3(mx[0],mx[1],mx[2])+center
+	H=orientation*Vector3(mn[0],mx[1],mx[2])+center
+	if wallMask&1:  ret+=doWall(A,D,H,E)
+	if wallMask&2:  ret+=doWall(B,F,G,C)
+	if wallMask&4:  ret+=doWall(A,E,F,B)
+	if wallMask&8:  ret+=doWall(D,C,G,H)
+	if wallMask&16: ret+=doWall(A,B,C,D)
+	if wallMask&32: ret+=doWall(E,H,G,F)
+	return ret
+
+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.
+	Return List of facets forming the cylinder;
+
+	:param Vector3 center: center of the created cylinder
+	:param float radius:  cylinder radius
+	:param float height: cylinder height
+	: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 bool closeGap: close range skipped in angleRange with triangular facets at cylinder bases.
+	:param **kw: (unused keyword arguments) passed to utils.facet;
+	"""
+	# check zero dimentions
+	if (radius<=0): raise RuntimeError("The radius should have the positive value");
+	
+	return facetCylinderConeGenerator(center=center,radiusTop=radius,height=height,orientation=orientation,segmentsNumber=segmentsNumber,wallMask=wallMask,angleRange=angleRange,closeGap=closeGap,**kw)
+	
+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.
+	Return List of facets forming the cone;
+
+	:param Vector3 center: center of the created cylinder
+	:param float radiusTop:  cone top radius
+	:param float radiusBottom:  cone bottom radius
+	:param float height: cone 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 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 bool closeGap: close range skipped in angleRange with triangular facets at cylinder bases.
+	:param **kw: (unused keyword arguments) passed to utils.facet;
+	"""
+	# check zero dimentions
+	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
+
+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.
+	Return List of facets forming the bunker;
+	
+	   dBunker
+	______________
+	|            |
+	|            |
+	|            | hBunker
+	|            |
+	|            |
+	|            |
+	|____________|
+	\            /
+	 \          /
+	  \        /   hOutput
+	   \      /
+	    \____/
+	    |    |
+	    |____|     hPipe
+	    dOutput
+	
+	
+	:param Vector3 center: center of the created bunker
+	:param float dBunker: bunker diameter, top
+	:param float dOutput: bunker output diameter
+	: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 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 bool closeGap: close range skipped in angleRange with triangular facets at cylinder bases.
+	:param **kw: (unused keyword arguments) passed to utils.facet;
+	"""
+	# check zero dimentions
+	if (dBunker<=0): raise RuntimeError("The diameter dBunker should have the positive value");
+	if (dOutput<=0): raise RuntimeError("The diameter dOutput should have the positive value");
+	if (hBunker<=0): raise RuntimeError("The height hBunker should have the positive value");
+	if (hOutput<=0): raise RuntimeError("The height hOutput should have the positive value");
+	if (hPipe<0): raise RuntimeError("The height hPipe should have the positive value or zero");
+	
+	ret=[]
+	if ((hPipe>0) or (wallMask&2)):
+		centerPipe = Vector3(0,0,hPipe/2.0)
+		ret+=facetCylinder(center=centerPipe,radius=dOutput/2.0,height=hPipe,segmentsNumber=segmentsNumber,wallMask=wallMask&6,angleRange=angleRange,closeGap=closeGap,**kw)
+	
+	centerOutput = Vector3(0.0,0.0,hPipe+hOutput/2.0)
+	ret+=facetCone(center=centerOutput,radiusTop=dBunker/2.0,radiusBottom=dOutput/2.0,height=hOutput,segmentsNumber=segmentsNumber,wallMask=wallMask&4,angleRange=angleRange,closeGap=closeGap,**kw)
+	
+	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

=== modified file 'py/tests/__init__.py'
--- py/tests/__init__.py	2010-12-03 00:20:06 +0000
+++ py/tests/__init__.py	2011-01-12 16:22:18 +0000
@@ -7,8 +7,8 @@
 allTests=['wrapper','omega','pbc','clump','cohesive-chain']
 
 # all yade modules (ugly...)
-import yade.eudoxos,yade.export,yade.linterpolation,yade.log,yade.pack,yade.plot,yade.post2d,yade.timing,yade.utils,yade.ymport
-allModules=(yade.eudoxos,yade.export,yade.linterpolation,yade.log,yade.pack,yade.plot,yade.post2d,yade.timing,yade.utils,yade.ymport)
+import yade.eudoxos,yade.export,yade.linterpolation,yade.log,yade.pack,yade.plot,yade.post2d,yade.timing,yade.utils,yade.ymport,yade.geom
+allModules=(yade.eudoxos,yade.export,yade.linterpolation,yade.log,yade.pack,yade.plot,yade.post2d,yade.timing,yade.utils,yade.ymport,yade.geom)
 try:
 	import yade.qt
 	allModules+=(yade.qt,)

=== modified file 'py/utils.py'
--- py/utils.py	2011-01-12 12:01:03 +0000
+++ py/utils.py	2011-01-12 16:22:18 +0000
@@ -9,7 +9,7 @@
 Devs: please DO NOT ADD more functions here, it is getting too crowded!
 """
 
-import math,random
+import math,random,doctest,geom
 from yade import *
 from yade.wrapper import *
 from miniEigen import *
@@ -17,7 +17,7 @@
 	import psyco
 	psyco.full()
 except ImportError: pass
-import doctest
+
 
 # c++ implementations for performance reasons
 from yade._utils import *
@@ -270,120 +270,21 @@
 	center=inscribedCircleCenter(vertices[0],vertices[1],vertices[2])
 	vertices=Vector3(vertices[0])-center,Vector3(vertices[1])-center,Vector3(vertices[2])-center
 	b.shape=Facet(color=color if color else randomColor(),wire=wire,highlight=highlight,vertices=vertices)
-	_commonBodySetup(b,0,Vector3(0,0,0),material,noBound=noBound,pos=center,dynamic=dynamic,fixed=fixed)
+	_commonBodySetup(b,0,Vector3(0,0,0),material,noBound=noBound,pos=center,fixed=fixed)
 	b.aspherical=False # mass and inertia are 0 anyway; fell free to change to ``True`` if needed
 	b.mask=mask
 	return b
-
-def facetBox(center,extents,orientation=Quaternion.Identity,wallMask=63,**kw):
-	"""
-	Create arbitrarily-aligned box composed of facets, with given center, extents and orientation.
-	If any of the box dimensions is zero, corresponding facets will not be created. The facets are oriented outwards from the box.
-
-	:param Vector3 center: center of the box
-	:param Vector3 extents: lengths of the box sides
-	:param Quaternion orientation: orientation of the box
-	:param bitmask wallMask: determines which walls will be created, in the order -x (1), +x (2), -y (4), +y (8), -z (16), +z (32). The numbers are ANDed; the default 63 means to create all walls
-	:param **kw: (unused keyword arguments) passed to :yref:`yade.utils.facet`
-	:returns: list of facets forming the box
-	"""
-
-
-	#Defense from zero dimensions
-	if (wallMask>63):
-		print "wallMask must be 63 or less"
-		wallMask=63
-	if (extents[0]==0):
-		wallMask=1
-	elif (extents[1]==0):
-		wallMask=4
-	elif (extents[2]==0):
-		wallMask=16
-	if (((extents[0]==0) and (extents[1]==0)) or ((extents[0]==0) and (extents[2]==0)) or ((extents[1]==0) and (extents[2]==0))):
-		raise RuntimeError("Please, specify at least 2 none-zero dimensions in extents!");
-	# ___________________________
-
-	mn,mx=[-extents[i] for i in 0,1,2],[extents[i] for i in 0,1,2]
-	def doWall(a,b,c,d):
-		return [facet((a,b,c),**kw),facet((a,c,d),**kw)]
-	ret=[]
-
-	A=orientation*Vector3(mn[0],mn[1],mn[2])+center
-	B=orientation*Vector3(mx[0],mn[1],mn[2])+center
-	C=orientation*Vector3(mx[0],mx[1],mn[2])+center
-	D=orientation*Vector3(mn[0],mx[1],mn[2])+center
-	E=orientation*Vector3(mn[0],mn[1],mx[2])+center
-	F=orientation*Vector3(mx[0],mn[1],mx[2])+center
-	G=orientation*Vector3(mx[0],mx[1],mx[2])+center
-	H=orientation*Vector3(mn[0],mx[1],mx[2])+center
-	if wallMask&1:  ret+=doWall(A,D,H,E)
-	if wallMask&2:  ret+=doWall(B,F,G,C)
-	if wallMask&4:  ret+=doWall(A,E,F,B)
-	if wallMask&8:  ret+=doWall(D,C,G,H)
-	if wallMask&16: ret+=doWall(A,B,C,D)
-	if wallMask&32: ret+=doWall(E,H,G,F)
-	return ret
-
-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.
-	Return List of facets forming the cylinder;
-
-	:param Vector3 center: center of the created cylinder
-	:param float radius:  cylinder radius
-	:param float height: cylinder height
-	: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 bool closeGap: close range skipped in angleRange with triangular facets at cylinder bases.
-	:param **kw: (unused keyword arguments) passed to utils.facet;
-	"""
-
-	# 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 (radius<=0): raise RuntimeError("The radius should have the positive value");
-
-	import numpy
-	if angleRange==None: angleRange=(0,2*math.pi)
-	if isinstance(angleRange,float):
-		print u'WARNING: utils.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)
-	P1=[]; P2=[]
-	P1.append(Vector3(0,0,-height/2))
-	P2.append(Vector3(0,0,+height/2))
-
-	for i in anglesInRad:
-		X=radius*math.cos(i)
-		Y=radius*math.sin(i)
-		P1.append(Vector3(X,Y,-height/2))
-		P2.append(Vector3(X,Y,+height/2))
-	for i in range(0,len(P1)):
-		P1[i]=orientation*P1[i]+center
-		P2[i]=orientation*P2[i]+center
-
-	ret=[]
-	for i in range(2,len(P1)):
-		if wallMask&2:
-			ret.append(facet((P1[0],P1[i],P1[i-1]),**kw))
-		if wallMask&1:
-			ret.append(facet((P2[0],P2[i-1],P2[i]),**kw))
-		if wallMask&4:
-			ret.append(facet((P1[i],P2[i],P2[i-1]),**kw))
-			ret.append(facet((P2[i-1],P1[i-1],P1[i]),**kw))
-	if closeGap and (angleRange[0]%(2*math.pi))!=(angleRange[1]%(2*math.pi)): # some part is skipped
-		pts=[(radius*math.cos(angleRange[i]),radius*math.sin(angleRange[i])) for i in (0,1)]
-		for Z in -height/2,height/2:
-			#print (pts[0][0],pts[0][1],Z),(pts[1][0],pts[1][1],Z),(0,0,Z)
-			pp=[(pts[0][0],pts[0][1],Z),(pts[1][0],pts[1][1],Z),(0,0,Z)]
-			pp=[orientation*p+center for p in pp]
-			ret.append(facet(pp,**kw))
-
-	return ret
-
-
+	
+def facetBox(*args,**kw):
+	"|ydeprecated|"
+	_deprecatedUtilsFunction('facetBox','geom.facetBox')
+	return geom.facetBox(*args,**kw)
+
+def facetCylinder(*args,**kw):
+	"|ydeprecated|"
+	_deprecatedUtilsFunction('facetCylinder','geom.facetCylinder')
+	return geom.facetCylinder(*args,**kw)
+	
 def aabbWalls(extrema=None,thickness=None,oversizeFactor=1.5,**kw):
 	"""Return 6 boxes that will wrap existing packing as walls from all sides;
 	extrema are extremal points of the Aabb of the packing (will be calculated if not specified)

=== modified file 'scripts/test/facet-box.py'
--- scripts/test/facet-box.py	2009-12-19 07:16:06 +0000
+++ scripts/test/facet-box.py	2011-01-12 16:22:18 +0000
@@ -1,3 +1,3 @@
-O.bodies.append(utils.facetBox((0,0,0),(10,5,2)))
-O.bodies.append(utils.facetBox((0,0,10),(10,5,2),wallMask=0b110011,wire=False))
-O.bodies.append(utils.facetBox((0,10,5),(10,5,2),wallMask=0b101010,wire=False))
+O.bodies.append(geom.facetBox((0,0,0),(10,5,2)))
+O.bodies.append(geom.facetBox((0,0,10),(10,5,2),wallMask=0b110011,wire=False))
+O.bodies.append(geom.facetBox((0,10,5),(10,5,2),wallMask=0b101010,wire=False))

=== modified file 'scripts/test/hdaps.py'
--- scripts/test/hdaps.py	2010-11-05 14:13:01 +0000
+++ scripts/test/hdaps.py	2011-01-12 16:22:18 +0000
@@ -3,7 +3,7 @@
 # laptop.
 
 O.bodies.append(
-	utils.facetBox(center=(0,0,.1),extents=(.5,.5,.1),wallMask=31,color=(0,0,1))+
+	geom.facetBox(center=(0,0,.1),extents=(.5,.5,.1),wallMask=31,color=(0,0,1))+
 	[utils.sphere((0,0,.1),.04,color=(1,1,1))]
 )
 

=== modified file 'scripts/test/shots.py'
--- scripts/test/shots.py	2010-12-19 09:55:19 +0000
+++ scripts/test/shots.py	2011-01-12 16:22:18 +0000
@@ -10,7 +10,7 @@
 # shotsId,steelId=O.materials.index('shots'),O.materials.index('steel')
 #
 
-O.bodies.append(utils.facetBox(center=(0,0,0),extents=(30e-3,30e-3,0),wallMask=32,wire=False,material='steel',color=(0,1,.3)))
+O.bodies.append(geom.facetBox(center=(0,0,0),extents=(30e-3,30e-3,0),wallMask=32,wire=False,material='steel',color=(0,1,.3)))
 
 O.engines=[
 	ForceResetter(),