yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #10471
[Branch ~yade-pkg/yade/git-trunk] Rev 3823: added example of paraview sphere "solid sections"
------------------------------------------------------------
revno: 3823
committer: Jan Stransky <jan.stransky@xxxxxxxxxxx>
timestamp: Mon 2014-02-17 17:37:16 +0100
message:
added example of paraview sphere "solid sections"
improvement of export.textExt function to support arbitrary quantity export
added:
examples/test/paraview-spheres-solid-section/
examples/test/paraview-spheres-solid-section/export_text.py
examples/test/paraview-spheres-solid-section/pv_section.py
modified:
py/export.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
=== added directory 'examples/test/paraview-spheres-solid-section'
=== added file 'examples/test/paraview-spheres-solid-section/export_text.py'
--- examples/test/paraview-spheres-solid-section/export_text.py 1970-01-01 00:00:00 +0000
+++ examples/test/paraview-spheres-solid-section/export_text.py 2014-02-17 16:37:16 +0000
@@ -0,0 +1,12 @@
+from yade import pack, export
+pred = pack.inAlignedBox((0,0,0),(10,10,10))
+O.bodies.append(pack.randomDensePack(pred,radius=1.,rRelFuzz=.5,spheresInCell=500,memoizeDb='/tmp/pack.db'))
+
+export.textExt('/tmp/test.txt',format='x_y_z_r_attrs',attrs=('b.state.pos.norm()','b.state.pos'),comment='dstN dstV_x dstV_y dstV_z')
+# text2vtk and text2vtkSection function can be copy-pasted from yade/py/export.py into separate py file to avoid executing yade or to use pure python
+export.text2vtk('/tmp/test.txt','/tmp/test.vtk')
+export.text2vtkSection('/tmp/test.txt','/tmp/testSection.vtk',point=(5,5,5),normal=(1,1,1))
+
+# now open paraview, click "Tools" menu -> "Python Shell", click "Run Script", choose "pv_section.py" from this directiory
+# or just run python pv_section.py
+# and enjoy :-)
=== added file 'examples/test/paraview-spheres-solid-section/pv_section.py'
--- examples/test/paraview-spheres-solid-section/pv_section.py 1970-01-01 00:00:00 +0000
+++ examples/test/paraview-spheres-solid-section/pv_section.py 2014-02-17 16:37:16 +0000
@@ -0,0 +1,660 @@
+try: paraview.simple
+except: from paraview.simple import *
+paraview.simple._DisableFirstRenderCameraReset()
+
+RenderView1 = CreateRenderView()
+RenderView1.LightSpecularColor = [1.0, 1.0, 1.0]
+RenderView1.KeyLightAzimuth = 10.0
+RenderView1.UseTexturedBackground = 0
+RenderView1.UseLight = 1
+RenderView1.CameraPosition = [-10.901121443539559, -17.271355476388358, 4.309974877565033]
+RenderView1.FillLightKFRatio = 3.0
+RenderView1.Background2 = [0.0, 0.0, 0.165]
+RenderView1.FillLightAzimuth = -10.0
+RenderView1.LODResolution = 50.0
+RenderView1.BackgroundTexture = []
+RenderView1.InteractionMode = '3D'
+RenderView1.StencilCapable = 1
+RenderView1.LightIntensity = 1.0
+RenderView1.CameraFocalPoint = [4.732498500000004, 5.045734999999994, 4.874767500000023]
+RenderView1.ImageReductionFactor = 2
+RenderView1.CameraViewAngle = 30.0
+RenderView1.CameraParallelScale = 7.0538593576100945
+RenderView1.EyeAngle = 2.0
+RenderView1.HeadLightKHRatio = 3.0
+RenderView1.StereoRender = 0
+RenderView1.KeyLightIntensity = 0.75
+RenderView1.BackLightAzimuth = 110.0
+RenderView1.OrientationAxesInteractivity = 0
+RenderView1.UseInteractiveRenderingForSceenshots = 0
+RenderView1.UseOffscreenRendering = 0
+RenderView1.Background = [1.0, 1.0, 1.0]
+RenderView1.UseOffscreenRenderingForScreenshots = 0
+RenderView1.NonInteractiveRenderDelay = 2
+RenderView1.CenterOfRotation = [4.7324985, 5.045735, 4.8747675]
+RenderView1.CameraParallelProjection = 0
+RenderView1.CompressorConfig = 'vtkSquirtCompressor 0 3'
+RenderView1.HeadLightWarmth = 0.5
+RenderView1.MaximumNumberOfPeels = 4
+RenderView1.LightDiffuseColor = [1.0, 1.0, 1.0]
+RenderView1.StereoType = 'Red-Blue'
+RenderView1.DepthPeeling = 1
+RenderView1.BackLightKBRatio = 3.5
+RenderView1.StereoCapableWindow = 1
+RenderView1.CameraViewUp = [-0.818931483577863, 0.5738512869077476, -0.006776851723502143]
+RenderView1.LightType = 'HeadLight'
+RenderView1.LightAmbientColor = [1.0, 1.0, 1.0]
+RenderView1.RemoteRenderThreshold = 3.0
+RenderView1.CacheKey = 0.0
+RenderView1.UseCache = 0
+RenderView1.KeyLightElevation = 50.0
+RenderView1.CenterAxesVisibility = 0
+RenderView1.MaintainLuminance = 0
+RenderView1.StillRenderImageReductionFactor = 1
+RenderView1.BackLightWarmth = 0.5
+RenderView1.FillLightElevation = -75.0
+RenderView1.MultiSamples = 0
+RenderView1.FillLightWarmth = 0.4
+RenderView1.AlphaBitPlanes = 1
+RenderView1.LightSwitch = 0
+RenderView1.OrientationAxesVisibility = 0
+RenderView1.CameraClippingRange = [14.893135346284218, 43.89470107765568]
+RenderView1.BackLightElevation = 0.0
+RenderView1.ViewTime = 0.0
+RenderView1.OrientationAxesOutlineColor = [1.0, 1.0, 1.0]
+RenderView1.LODThreshold = 5.0
+RenderView1.CollectGeometryThreshold = 100.0
+RenderView1.UseGradientBackground = 0
+RenderView1.KeyLightWarmth = 0.6
+RenderView1.OrientationAxesLabelColor = [1.0, 1.0, 1.0]
+
+test_vtk = LegacyVTKReader( guiName="test.vtk", FileNames=['/tmp/test.vtk'] )
+
+Glyph1 = Glyph( guiName="Glyph1", RandomMode=1, GlyphTransform="Transform2", GlyphType="Sphere", MaximumNumberofPoints=5000, ScaleMode='scalar', MaskPoints=0, Vectors=['POINTS', ''], SetScaleFactor=1.0, Scalars=['POINTS', 'radius'], Orient=1 )
+Glyph1.GlyphType.StartTheta = 0.0
+Glyph1.GlyphType.ThetaResolution = 12
+Glyph1.GlyphTransform.Rotate = [0.0, 0.0, 0.0]
+Glyph1.GlyphTransform.Translate = [0.0, 0.0, 0.0]
+Glyph1.GlyphType.PhiResolution = 12
+Glyph1.GlyphType.EndTheta = 360.0
+Glyph1.GlyphType.EndPhi = 180.0
+Glyph1.GlyphType.Center = [0.0, 0.0, 0.0]
+Glyph1.GlyphType.Radius = 1.0
+Glyph1.GlyphTransform.Scale = [1.0, 1.0, 1.0]
+Glyph1.GlyphType.StartPhi = 0.0
+
+Clip2 = Clip( guiName="Clip2", InsideOut=0, UseValueAsOffset=0, Scalars=['POINTS', 'radius'], Value=0.0, ClipType="Plane" )
+Clip2.ClipType.Normal = [1.0, 1.0, 1.0]
+Clip2.ClipType.Origin = [5.0, 5.0, 5.0]
+Clip2.ClipType.Offset = 0.0
+
+testSection_vtk = LegacyVTKReader( guiName="testSection.vtk", FileNames=['/tmp/testSection.vtk'] )
+
+Glyph3 = Glyph( guiName="Glyph3", ScaleMode='scalar', GlyphType="Cylinder", MaskPoints=0, RandomMode=1, Vectors=['POINTS', 'normal'], GlyphTransform="Transform2", Scalars=['POINTS', 'radius'], MaximumNumberofPoints=5000, SetScaleFactor=1.0, Orient=1 )
+Glyph3.GlyphType.Capping = 1
+Glyph3.GlyphType.Height = 0.01
+Glyph3.GlyphTransform.Rotate = [0.0, 0.0, -90.0]
+Glyph3.GlyphType.Radius = 1.0
+Glyph3.GlyphTransform.Translate = [0.0, 0.0, 0.0]
+Glyph3.GlyphType.Center = [0.0, 0.0, 0.0]
+Glyph3.GlyphType.Resolution = 18
+Glyph3.GlyphTransform.Scale = [1.0, 1.0, 1.0]
+
+a1_radius_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] )
+
+a1_radiusOrig_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] )
+
+a1_radius_PVLookupTable = GetLookupTableForArray( "radius", 1, Discretize=1, RGBPoints=[0.522954, 0.0, 0.0, 1.0, 1.42914, 1.0, 0.0, 0.0], UseLogScale=0, VectorComponent=0, NanColor=[0.498039, 0.498039, 0.498039], NumberOfTableValues=256, ColorSpace='HSV', VectorMode='Magnitude', HSVWrap=0, ScalarRangeInitialized=1.0, LockScalarRange=1 )
+
+a1_radiusOrig_PVLookupTable = GetLookupTableForArray( "radiusOrig", 1, Discretize=1, RGBPoints=[0.54491, 0.0, 0.0, 1.0, 1.41118, 1.0, 0.0, 0.0], UseLogScale=0, VectorComponent=0, NanColor=[0.498039, 0.498039, 0.498039], NumberOfTableValues=256, ColorSpace='HSV', VectorMode='Magnitude', HSVWrap=0, ScalarRangeInitialized=1.0, LockScalarRange=1 )
+
+SetActiveSource(test_vtk)
+DataRepresentation1 = Show()
+DataRepresentation1.CubeAxesZAxisVisibility = 1
+DataRepresentation1.SelectionPointLabelColor = [0.5, 0.5, 0.5]
+DataRepresentation1.SelectionPointFieldDataArrayName = 'radius'
+DataRepresentation1.SuppressLOD = 0
+DataRepresentation1.CubeAxesXGridLines = 0
+DataRepresentation1.CubeAxesYAxisTickVisibility = 1
+DataRepresentation1.CubeAxesColor = [1.0, 1.0, 1.0]
+DataRepresentation1.Position = [0.0, 0.0, 0.0]
+DataRepresentation1.BackfaceRepresentation = 'Follow Frontface'
+DataRepresentation1.SelectionOpacity = 1.0
+DataRepresentation1.SelectionPointLabelShadow = 0
+DataRepresentation1.CubeAxesYGridLines = 0
+DataRepresentation1.CubeAxesZAxisRange = [0.0, 1.0]
+DataRepresentation1.OrientationMode = 'Direction'
+DataRepresentation1.Source.TipResolution = 6
+DataRepresentation1.ScaleMode = 'No Data Scaling Off'
+DataRepresentation1.Diffuse = 1.0
+DataRepresentation1.SelectionUseOutline = 0
+DataRepresentation1.CubeAxesZTitle = 'Z-Axis'
+DataRepresentation1.Specular = 0.1
+DataRepresentation1.SelectionVisibility = 1
+DataRepresentation1.InterpolateScalarsBeforeMapping = 1
+DataRepresentation1.CubeAxesZAxisTickVisibility = 1
+DataRepresentation1.Origin = [0.0, 0.0, 0.0]
+DataRepresentation1.CubeAxesVisibility = 0
+DataRepresentation1.Scale = [1.0, 1.0, 1.0]
+DataRepresentation1.SelectionCellLabelJustification = 'Left'
+DataRepresentation1.DiffuseColor = [1.0, 1.0, 1.0]
+DataRepresentation1.SelectionCellLabelOpacity = 1.0
+DataRepresentation1.Source = "Arrow"
+DataRepresentation1.Source.Invert = 0
+DataRepresentation1.Masking = 0
+DataRepresentation1.Opacity = 1.0
+DataRepresentation1.LineWidth = 1.0
+DataRepresentation1.MeshVisibility = 0
+DataRepresentation1.Visibility = 1
+DataRepresentation1.SelectionCellLabelFontSize = 18
+DataRepresentation1.CubeAxesCornerOffset = 0.0
+DataRepresentation1.SelectionPointLabelJustification = 'Left'
+DataRepresentation1.SelectionPointLabelVisibility = 0
+DataRepresentation1.SelectOrientationVectors = ''
+DataRepresentation1.CubeAxesTickLocation = 'Inside'
+DataRepresentation1.CubeAxesXAxisMinorTickVisibility = 1
+DataRepresentation1.CubeAxesYAxisVisibility = 1
+DataRepresentation1.SelectionPointLabelFontFamily = 'Arial'
+DataRepresentation1.Source.ShaftResolution = 6
+DataRepresentation1.CubeAxesFlyMode = 'Closest Triad'
+DataRepresentation1.SelectScaleArray = ''
+DataRepresentation1.CubeAxesYTitle = 'Y-Axis'
+DataRepresentation1.ColorAttributeType = 'POINT_DATA'
+DataRepresentation1.SpecularPower = 100.0
+DataRepresentation1.Texture = []
+DataRepresentation1.SelectionCellLabelShadow = 0
+DataRepresentation1.AmbientColor = [1.0, 1.0, 1.0]
+DataRepresentation1.MapScalars = 1
+DataRepresentation1.PointSize = 2.0
+DataRepresentation1.Source.TipLength = 0.35
+DataRepresentation1.SelectionCellLabelFormat = ''
+DataRepresentation1.Scaling = 0
+DataRepresentation1.StaticMode = 0
+DataRepresentation1.SelectionCellLabelColor = [0.0, 1.0, 0.0]
+DataRepresentation1.Source.TipRadius = 0.1
+DataRepresentation1.EdgeColor = [0.0, 0.0, 0.5000076295109483]
+DataRepresentation1.CubeAxesXAxisTickVisibility = 1
+DataRepresentation1.SelectionCellLabelVisibility = 0
+DataRepresentation1.NonlinearSubdivisionLevel = 1
+DataRepresentation1.CubeAxesXAxisRange = [0.0, 1.0]
+DataRepresentation1.Representation = 'Surface'
+DataRepresentation1.CubeAxesYAxisRange = [0.0, 1.0]
+DataRepresentation1.CustomBounds = [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
+DataRepresentation1.Orientation = [0.0, 0.0, 0.0]
+DataRepresentation1.CubeAxesEnableCustomAxisRange = 0
+DataRepresentation1.CubeAxesXTitle = 'X-Axis'
+DataRepresentation1.CubeAxesInertia = 1
+DataRepresentation1.BackfaceOpacity = 1.0
+DataRepresentation1.SelectionCellFieldDataArrayName = 'vtkOriginalCellIds'
+DataRepresentation1.SelectionColor = [1.0, 0.0, 1.0]
+DataRepresentation1.Ambient = 0.0
+DataRepresentation1.SelectionPointLabelFontSize = 18
+DataRepresentation1.ScaleFactor = 0.8360145000000001
+DataRepresentation1.BackfaceAmbientColor = [1.0, 1.0, 1.0]
+DataRepresentation1.Source.ShaftRadius = 0.03
+DataRepresentation1.SelectMaskArray = ''
+DataRepresentation1.SelectionLineWidth = 2.0
+DataRepresentation1.CubeAxesZAxisMinorTickVisibility = 1
+DataRepresentation1.CubeAxesXAxisVisibility = 1
+DataRepresentation1.Interpolation = 'Gouraud'
+DataRepresentation1.SelectionCellLabelFontFamily = 'Arial'
+DataRepresentation1.SelectionCellLabelItalic = 0
+DataRepresentation1.CubeAxesYAxisMinorTickVisibility = 1
+DataRepresentation1.CubeAxesZGridLines = 0
+DataRepresentation1.SelectionPointLabelFormat = ''
+DataRepresentation1.SelectionPointLabelOpacity = 1.0
+DataRepresentation1.BackfaceDiffuseColor = [1.0, 1.0, 1.0]
+DataRepresentation1.Pickable = 1
+DataRepresentation1.CustomBoundsActive = [0, 0, 0]
+DataRepresentation1.SelectionRepresentation = 'Wireframe'
+DataRepresentation1.SelectionPointLabelBold = 0
+DataRepresentation1.ColorArrayName = 'radius'
+DataRepresentation1.SelectionPointLabelItalic = 0
+DataRepresentation1.AllowSpecularHighlightingWithScalarColoring = 0
+DataRepresentation1.SpecularColor = [1.0, 1.0, 1.0]
+DataRepresentation1.LookupTable = a1_radius_PVLookupTable
+DataRepresentation1.SelectionPointSize = 5.0
+DataRepresentation1.SelectionCellLabelBold = 0
+DataRepresentation1.Orient = 0
+
+SetActiveSource(Glyph1)
+DataRepresentation3 = Show()
+DataRepresentation3.CubeAxesZAxisVisibility = 1
+DataRepresentation3.SelectionPointLabelColor = [0.5, 0.5, 0.5]
+DataRepresentation3.SelectionPointFieldDataArrayName = 'radius'
+DataRepresentation3.SuppressLOD = 0
+DataRepresentation3.CubeAxesXGridLines = 0
+DataRepresentation3.CubeAxesYAxisTickVisibility = 1
+DataRepresentation3.CubeAxesColor = [1.0, 1.0, 1.0]
+DataRepresentation3.Position = [0.0, 0.0, 0.0]
+DataRepresentation3.BackfaceRepresentation = 'Follow Frontface'
+DataRepresentation3.SelectionOpacity = 1.0
+DataRepresentation3.SelectionPointLabelShadow = 0
+DataRepresentation3.CubeAxesYGridLines = 0
+DataRepresentation3.CubeAxesZAxisRange = [0.0, 1.0]
+DataRepresentation3.OrientationMode = 'Direction'
+DataRepresentation3.Source.TipResolution = 6
+DataRepresentation3.ScaleMode = 'No Data Scaling Off'
+DataRepresentation3.Diffuse = 1.0
+DataRepresentation3.SelectionUseOutline = 0
+DataRepresentation3.CubeAxesZTitle = 'Z-Axis'
+DataRepresentation3.Specular = 0.1
+DataRepresentation3.SelectionVisibility = 1
+DataRepresentation3.InterpolateScalarsBeforeMapping = 1
+DataRepresentation3.CubeAxesZAxisTickVisibility = 1
+DataRepresentation3.Origin = [0.0, 0.0, 0.0]
+DataRepresentation3.CubeAxesVisibility = 0
+DataRepresentation3.Scale = [1.0, 1.0, 1.0]
+DataRepresentation3.SelectionCellLabelJustification = 'Left'
+DataRepresentation3.DiffuseColor = [1.0, 1.0, 1.0]
+DataRepresentation3.SelectionCellLabelOpacity = 1.0
+DataRepresentation3.Source = "Arrow"
+DataRepresentation3.Source.Invert = 0
+DataRepresentation3.Masking = 0
+DataRepresentation3.Opacity = 1.0
+DataRepresentation3.LineWidth = 1.0
+DataRepresentation3.MeshVisibility = 0
+DataRepresentation3.Visibility = 0
+DataRepresentation3.SelectionCellLabelFontSize = 18
+DataRepresentation3.CubeAxesCornerOffset = 0.0
+DataRepresentation3.SelectionPointLabelJustification = 'Left'
+DataRepresentation3.SelectionPointLabelVisibility = 0
+DataRepresentation3.SelectOrientationVectors = ''
+DataRepresentation3.CubeAxesTickLocation = 'Inside'
+DataRepresentation3.CubeAxesXAxisMinorTickVisibility = 1
+DataRepresentation3.CubeAxesYAxisVisibility = 1
+DataRepresentation3.SelectionPointLabelFontFamily = 'Arial'
+DataRepresentation3.Source.ShaftResolution = 6
+DataRepresentation3.CubeAxesFlyMode = 'Closest Triad'
+DataRepresentation3.SelectScaleArray = ''
+DataRepresentation3.CubeAxesYTitle = 'Y-Axis'
+DataRepresentation3.ColorAttributeType = 'POINT_DATA'
+DataRepresentation3.SpecularPower = 100.0
+DataRepresentation3.Texture = []
+DataRepresentation3.SelectionCellLabelShadow = 0
+DataRepresentation3.AmbientColor = [1.0, 1.0, 1.0]
+DataRepresentation3.MapScalars = 1
+DataRepresentation3.PointSize = 2.0
+DataRepresentation3.Source.TipLength = 0.35
+DataRepresentation3.SelectionCellLabelFormat = ''
+DataRepresentation3.Scaling = 0
+DataRepresentation3.StaticMode = 0
+DataRepresentation3.SelectionCellLabelColor = [0.0, 1.0, 0.0]
+DataRepresentation3.Source.TipRadius = 0.1
+DataRepresentation3.EdgeColor = [0.0, 0.0, 0.5000076295109483]
+DataRepresentation3.CubeAxesXAxisTickVisibility = 1
+DataRepresentation3.SelectionCellLabelVisibility = 0
+DataRepresentation3.NonlinearSubdivisionLevel = 1
+DataRepresentation3.CubeAxesXAxisRange = [0.0, 1.0]
+DataRepresentation3.Representation = 'Surface'
+DataRepresentation3.CubeAxesYAxisRange = [0.0, 1.0]
+DataRepresentation3.CustomBounds = [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
+DataRepresentation3.Orientation = [0.0, 0.0, 0.0]
+DataRepresentation3.CubeAxesEnableCustomAxisRange = 0
+DataRepresentation3.CubeAxesXTitle = 'X-Axis'
+DataRepresentation3.CubeAxesInertia = 1
+DataRepresentation3.BackfaceOpacity = 1.0
+DataRepresentation3.SelectionCellFieldDataArrayName = 'vtkOriginalCellIds'
+DataRepresentation3.SelectionColor = [1.0, 0.0, 1.0]
+DataRepresentation3.Ambient = 0.0
+DataRepresentation3.SelectionPointLabelFontSize = 18
+DataRepresentation3.ScaleFactor = 0.9713980622589589
+DataRepresentation3.BackfaceAmbientColor = [1.0, 1.0, 1.0]
+DataRepresentation3.Source.ShaftRadius = 0.03
+DataRepresentation3.SelectMaskArray = ''
+DataRepresentation3.SelectionLineWidth = 2.0
+DataRepresentation3.CubeAxesZAxisMinorTickVisibility = 1
+DataRepresentation3.CubeAxesXAxisVisibility = 1
+DataRepresentation3.Interpolation = 'Gouraud'
+DataRepresentation3.SelectionCellLabelFontFamily = 'Arial'
+DataRepresentation3.SelectionCellLabelItalic = 0
+DataRepresentation3.CubeAxesYAxisMinorTickVisibility = 1
+DataRepresentation3.CubeAxesZGridLines = 0
+DataRepresentation3.SelectionPointLabelFormat = ''
+DataRepresentation3.SelectionPointLabelOpacity = 1.0
+DataRepresentation3.BackfaceDiffuseColor = [1.0, 1.0, 1.0]
+DataRepresentation3.Pickable = 1
+DataRepresentation3.CustomBoundsActive = [0, 0, 0]
+DataRepresentation3.SelectionRepresentation = 'Wireframe'
+DataRepresentation3.SelectionPointLabelBold = 0
+DataRepresentation3.ColorArrayName = 'radius'
+DataRepresentation3.SelectionPointLabelItalic = 0
+DataRepresentation3.AllowSpecularHighlightingWithScalarColoring = 0
+DataRepresentation3.SpecularColor = [1.0, 1.0, 1.0]
+DataRepresentation3.LookupTable = a1_radius_PVLookupTable
+DataRepresentation3.SelectionPointSize = 5.0
+DataRepresentation3.SelectionCellLabelBold = 0
+DataRepresentation3.Orient = 0
+
+SetActiveSource(Clip2)
+DataRepresentation5 = Show()
+DataRepresentation5.CubeAxesZAxisVisibility = 1
+DataRepresentation5.SelectionPointLabelColor = [0.5, 0.5, 0.5]
+DataRepresentation5.SelectionPointFieldDataArrayName = 'radius'
+DataRepresentation5.SuppressLOD = 0
+DataRepresentation5.CubeAxesXGridLines = 0
+DataRepresentation5.CubeAxesYAxisTickVisibility = 1
+DataRepresentation5.CubeAxesColor = [1.0, 1.0, 1.0]
+DataRepresentation5.Position = [0.0, 0.0, 0.0]
+DataRepresentation5.BackfaceRepresentation = 'Follow Frontface'
+DataRepresentation5.SelectionOpacity = 1.0
+DataRepresentation5.SelectionPointLabelShadow = 0
+DataRepresentation5.CubeAxesYGridLines = 0
+DataRepresentation5.CubeAxesZAxisRange = [0.0, 1.0]
+DataRepresentation5.OrientationMode = 'Direction'
+DataRepresentation5.Source.TipResolution = 6
+DataRepresentation5.ScaleMode = 'No Data Scaling Off'
+DataRepresentation5.Diffuse = 1.0
+DataRepresentation5.SelectionUseOutline = 0
+DataRepresentation5.SelectionPointLabelFormat = ''
+DataRepresentation5.CubeAxesZTitle = 'Z-Axis'
+DataRepresentation5.Specular = 0.1
+DataRepresentation5.SelectionVisibility = 1
+DataRepresentation5.InterpolateScalarsBeforeMapping = 1
+DataRepresentation5.CubeAxesZAxisTickVisibility = 1
+DataRepresentation5.Origin = [0.0, 0.0, 0.0]
+DataRepresentation5.CubeAxesVisibility = 0
+DataRepresentation5.Scale = [1.0, 1.0, 1.0]
+DataRepresentation5.SelectionCellLabelJustification = 'Left'
+DataRepresentation5.DiffuseColor = [1.0, 1.0, 1.0]
+DataRepresentation5.SelectionCellLabelOpacity = 1.0
+DataRepresentation5.CubeAxesInertia = 1
+DataRepresentation5.Source = "Arrow"
+DataRepresentation5.Source.Invert = 0
+DataRepresentation5.Masking = 0
+DataRepresentation5.Opacity = 1.0
+DataRepresentation5.LineWidth = 1.0
+DataRepresentation5.MeshVisibility = 0
+DataRepresentation5.Visibility = 1
+DataRepresentation5.SelectionCellLabelFontSize = 18
+DataRepresentation5.CubeAxesCornerOffset = 0.0
+DataRepresentation5.SelectionPointLabelJustification = 'Left'
+DataRepresentation5.SelectionPointLabelVisibility = 0
+DataRepresentation5.SelectOrientationVectors = ''
+DataRepresentation5.CubeAxesTickLocation = 'Inside'
+DataRepresentation5.BackfaceDiffuseColor = [1.0, 1.0, 1.0]
+DataRepresentation5.CubeAxesYAxisVisibility = 1
+DataRepresentation5.SelectionPointLabelFontFamily = 'Arial'
+DataRepresentation5.Source.ShaftResolution = 6
+DataRepresentation5.CubeAxesFlyMode = 'Closest Triad'
+DataRepresentation5.SelectScaleArray = ''
+DataRepresentation5.CubeAxesYTitle = 'Y-Axis'
+DataRepresentation5.ColorAttributeType = 'POINT_DATA'
+DataRepresentation5.SpecularPower = 100.0
+DataRepresentation5.Texture = []
+DataRepresentation5.SelectionCellLabelShadow = 0
+DataRepresentation5.AmbientColor = [1.0, 1.0, 1.0]
+DataRepresentation5.MapScalars = 1
+DataRepresentation5.PointSize = 2.0
+DataRepresentation5.Source.TipLength = 0.35
+DataRepresentation5.SelectionCellLabelFormat = ''
+DataRepresentation5.Scaling = 0
+DataRepresentation5.StaticMode = 0
+DataRepresentation5.SelectionCellLabelColor = [0.0, 1.0, 0.0]
+DataRepresentation5.Source.TipRadius = 0.1
+DataRepresentation5.EdgeColor = [0.0, 0.0, 0.5000076295109483]
+DataRepresentation5.CubeAxesXAxisTickVisibility = 1
+DataRepresentation5.SelectionCellLabelVisibility = 0
+DataRepresentation5.NonlinearSubdivisionLevel = 1
+DataRepresentation5.CubeAxesXAxisRange = [0.0, 1.0]
+DataRepresentation5.Representation = 'Surface'
+DataRepresentation5.CubeAxesYAxisRange = [0.0, 1.0]
+DataRepresentation5.CustomBounds = [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
+DataRepresentation5.Orientation = [0.0, 0.0, 0.0]
+DataRepresentation5.CubeAxesEnableCustomAxisRange = 0
+DataRepresentation5.CubeAxesXTitle = 'X-Axis'
+DataRepresentation5.ScalarOpacityUnitDistance = 1.1040324233388048
+DataRepresentation5.BackfaceOpacity = 1.0
+DataRepresentation5.SelectionPointLabelFontSize = 18
+DataRepresentation5.SelectionCellFieldDataArrayName = 'vtkOriginalCellIds'
+DataRepresentation5.SelectionColor = [1.0, 0.0, 1.0]
+DataRepresentation5.Ambient = 0.0
+DataRepresentation5.CubeAxesXAxisMinorTickVisibility = 1
+DataRepresentation5.ScaleFactor = 0.8981979608535767
+DataRepresentation5.BackfaceAmbientColor = [1.0, 1.0, 1.0]
+DataRepresentation5.Source.ShaftRadius = 0.03
+DataRepresentation5.ScalarOpacityFunction = a1_radius_PiecewiseFunction
+DataRepresentation5.SelectMaskArray = ''
+DataRepresentation5.SelectionLineWidth = 2.0
+DataRepresentation5.CubeAxesZAxisMinorTickVisibility = 1
+DataRepresentation5.CubeAxesXAxisVisibility = 1
+DataRepresentation5.Interpolation = 'Gouraud'
+DataRepresentation5.SelectMapper = 'Projected tetra'
+DataRepresentation5.SelectionCellLabelFontFamily = 'Arial'
+DataRepresentation5.SelectionCellLabelItalic = 0
+DataRepresentation5.CubeAxesYAxisMinorTickVisibility = 1
+DataRepresentation5.CubeAxesZGridLines = 0
+DataRepresentation5.ExtractedBlockIndex = 0
+DataRepresentation5.SelectionPointLabelOpacity = 1.0
+DataRepresentation5.Pickable = 1
+DataRepresentation5.CustomBoundsActive = [0, 0, 0]
+DataRepresentation5.SelectionRepresentation = 'Wireframe'
+DataRepresentation5.SelectionPointLabelBold = 0
+DataRepresentation5.ColorArrayName = 'radius'
+DataRepresentation5.SelectionPointLabelItalic = 0
+DataRepresentation5.AllowSpecularHighlightingWithScalarColoring = 0
+DataRepresentation5.SpecularColor = [1.0, 1.0, 1.0]
+DataRepresentation5.LookupTable = a1_radius_PVLookupTable
+DataRepresentation5.SelectionPointSize = 5.0
+DataRepresentation5.SelectionCellLabelBold = 0
+DataRepresentation5.Orient = 0
+
+SetActiveSource(testSection_vtk)
+DataRepresentation7 = Show()
+DataRepresentation7.CubeAxesZAxisVisibility = 1
+DataRepresentation7.SelectionPointLabelColor = [0.5, 0.5, 0.5]
+DataRepresentation7.SelectionPointFieldDataArrayName = 'radius'
+DataRepresentation7.SuppressLOD = 0
+DataRepresentation7.CubeAxesXGridLines = 0
+DataRepresentation7.CubeAxesYAxisTickVisibility = 1
+DataRepresentation7.CubeAxesColor = [1.0, 1.0, 1.0]
+DataRepresentation7.Position = [0.0, 0.0, 0.0]
+DataRepresentation7.BackfaceRepresentation = 'Follow Frontface'
+DataRepresentation7.SelectionOpacity = 1.0
+DataRepresentation7.SelectionPointLabelShadow = 0
+DataRepresentation7.CubeAxesYGridLines = 0
+DataRepresentation7.CubeAxesZAxisRange = [0.0, 1.0]
+DataRepresentation7.OrientationMode = 'Direction'
+DataRepresentation7.Source.TipResolution = 6
+DataRepresentation7.ScaleMode = 'No Data Scaling Off'
+DataRepresentation7.Diffuse = 1.0
+DataRepresentation7.SelectionUseOutline = 0
+DataRepresentation7.CubeAxesZTitle = 'Z-Axis'
+DataRepresentation7.Specular = 0.1
+DataRepresentation7.SelectionVisibility = 1
+DataRepresentation7.InterpolateScalarsBeforeMapping = 1
+DataRepresentation7.CubeAxesZAxisTickVisibility = 1
+DataRepresentation7.Origin = [0.0, 0.0, 0.0]
+DataRepresentation7.CubeAxesVisibility = 0
+DataRepresentation7.Scale = [1.0, 1.0, 1.0]
+DataRepresentation7.SelectionCellLabelJustification = 'Left'
+DataRepresentation7.DiffuseColor = [1.0, 1.0, 1.0]
+DataRepresentation7.SelectionCellLabelOpacity = 1.0
+DataRepresentation7.Source = "Arrow"
+DataRepresentation7.Source.Invert = 0
+DataRepresentation7.Masking = 0
+DataRepresentation7.Opacity = 1.0
+DataRepresentation7.LineWidth = 1.0
+DataRepresentation7.MeshVisibility = 0
+DataRepresentation7.Visibility = 1
+DataRepresentation7.SelectionCellLabelFontSize = 18
+DataRepresentation7.CubeAxesCornerOffset = 0.0
+DataRepresentation7.SelectionPointLabelJustification = 'Left'
+DataRepresentation7.SelectionPointLabelVisibility = 0
+DataRepresentation7.SelectOrientationVectors = ''
+DataRepresentation7.CubeAxesTickLocation = 'Inside'
+DataRepresentation7.CubeAxesXAxisMinorTickVisibility = 1
+DataRepresentation7.CubeAxesYAxisVisibility = 1
+DataRepresentation7.SelectionPointLabelFontFamily = 'Arial'
+DataRepresentation7.Source.ShaftResolution = 6
+DataRepresentation7.CubeAxesFlyMode = 'Closest Triad'
+DataRepresentation7.SelectScaleArray = ''
+DataRepresentation7.CubeAxesYTitle = 'Y-Axis'
+DataRepresentation7.ColorAttributeType = 'POINT_DATA'
+DataRepresentation7.SpecularPower = 100.0
+DataRepresentation7.Texture = []
+DataRepresentation7.SelectionCellLabelShadow = 0
+DataRepresentation7.AmbientColor = [1.0, 1.0, 1.0]
+DataRepresentation7.MapScalars = 1
+DataRepresentation7.PointSize = 2.0
+DataRepresentation7.Source.TipLength = 0.35
+DataRepresentation7.SelectionCellLabelFormat = ''
+DataRepresentation7.Scaling = 0
+DataRepresentation7.StaticMode = 0
+DataRepresentation7.SelectionCellLabelColor = [0.0, 1.0, 0.0]
+DataRepresentation7.Source.TipRadius = 0.1
+DataRepresentation7.EdgeColor = [0.0, 0.0, 0.5000076295109483]
+DataRepresentation7.CubeAxesXAxisTickVisibility = 1
+DataRepresentation7.SelectionCellLabelVisibility = 0
+DataRepresentation7.NonlinearSubdivisionLevel = 1
+DataRepresentation7.CubeAxesXAxisRange = [0.0, 1.0]
+DataRepresentation7.Representation = 'Surface'
+DataRepresentation7.CubeAxesYAxisRange = [0.0, 1.0]
+DataRepresentation7.CustomBounds = [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
+DataRepresentation7.Orientation = [0.0, 0.0, 0.0]
+DataRepresentation7.CubeAxesEnableCustomAxisRange = 0
+DataRepresentation7.CubeAxesXTitle = 'X-Axis'
+DataRepresentation7.CubeAxesInertia = 1
+DataRepresentation7.BackfaceOpacity = 1.0
+DataRepresentation7.SelectionCellFieldDataArrayName = 'vtkOriginalCellIds'
+DataRepresentation7.SelectionColor = [1.0, 0.0, 1.0]
+DataRepresentation7.Ambient = 0.0
+DataRepresentation7.SelectionPointLabelFontSize = 18
+DataRepresentation7.ScaleFactor = 0.73055
+DataRepresentation7.BackfaceAmbientColor = [1.0, 1.0, 1.0]
+DataRepresentation7.Source.ShaftRadius = 0.03
+DataRepresentation7.SelectMaskArray = ''
+DataRepresentation7.SelectionLineWidth = 2.0
+DataRepresentation7.CubeAxesZAxisMinorTickVisibility = 1
+DataRepresentation7.CubeAxesXAxisVisibility = 1
+DataRepresentation7.Interpolation = 'Gouraud'
+DataRepresentation7.SelectionCellLabelFontFamily = 'Arial'
+DataRepresentation7.SelectionCellLabelItalic = 0
+DataRepresentation7.CubeAxesYAxisMinorTickVisibility = 1
+DataRepresentation7.CubeAxesZGridLines = 0
+DataRepresentation7.SelectionPointLabelFormat = ''
+DataRepresentation7.SelectionPointLabelOpacity = 1.0
+DataRepresentation7.BackfaceDiffuseColor = [1.0, 1.0, 1.0]
+DataRepresentation7.Pickable = 1
+DataRepresentation7.CustomBoundsActive = [0, 0, 0]
+DataRepresentation7.SelectionRepresentation = 'Wireframe'
+DataRepresentation7.SelectionPointLabelBold = 0
+DataRepresentation7.ColorArrayName = 'radius'
+DataRepresentation7.SelectionPointLabelItalic = 0
+DataRepresentation7.AllowSpecularHighlightingWithScalarColoring = 0
+DataRepresentation7.SpecularColor = [1.0, 1.0, 1.0]
+DataRepresentation7.LookupTable = a1_radius_PVLookupTable
+DataRepresentation7.SelectionPointSize = 5.0
+DataRepresentation7.SelectionCellLabelBold = 0
+DataRepresentation7.Orient = 0
+
+SetActiveSource(Glyph3)
+DataRepresentation8 = Show()
+DataRepresentation8.CubeAxesZAxisVisibility = 1
+DataRepresentation8.SelectionPointLabelColor = [0.5, 0.5, 0.5]
+DataRepresentation8.SelectionPointFieldDataArrayName = 'radius'
+DataRepresentation8.SuppressLOD = 0
+DataRepresentation8.CubeAxesXGridLines = 0
+DataRepresentation8.CubeAxesYAxisTickVisibility = 1
+DataRepresentation8.CubeAxesColor = [1.0, 1.0, 1.0]
+DataRepresentation8.Position = [0.0, 0.0, 0.0]
+DataRepresentation8.BackfaceRepresentation = 'Follow Frontface'
+DataRepresentation8.SelectionOpacity = 1.0
+DataRepresentation8.SelectionPointLabelShadow = 0
+DataRepresentation8.CubeAxesYGridLines = 0
+DataRepresentation8.CubeAxesZAxisRange = [0.0, 1.0]
+DataRepresentation8.OrientationMode = 'Direction'
+DataRepresentation8.Source.TipResolution = 6
+DataRepresentation8.ScaleMode = 'No Data Scaling Off'
+DataRepresentation8.Diffuse = 1.0
+DataRepresentation8.SelectionUseOutline = 0
+DataRepresentation8.CubeAxesZTitle = 'Z-Axis'
+DataRepresentation8.Specular = 0.1
+DataRepresentation8.SelectionVisibility = 1
+DataRepresentation8.InterpolateScalarsBeforeMapping = 1
+DataRepresentation8.CubeAxesZAxisTickVisibility = 1
+DataRepresentation8.Origin = [0.0, 0.0, 0.0]
+DataRepresentation8.CubeAxesVisibility = 0
+DataRepresentation8.Scale = [1.0, 1.0, 1.0]
+DataRepresentation8.SelectionCellLabelJustification = 'Left'
+DataRepresentation8.DiffuseColor = [1.0, 1.0, 1.0]
+DataRepresentation8.SelectionCellLabelOpacity = 1.0
+DataRepresentation8.Source = "Arrow"
+DataRepresentation8.Source.Invert = 0
+DataRepresentation8.Masking = 0
+DataRepresentation8.Opacity = 1.0
+DataRepresentation8.LineWidth = 1.0
+DataRepresentation8.MeshVisibility = 0
+DataRepresentation8.Visibility = 1
+DataRepresentation8.SelectionCellLabelFontSize = 18
+DataRepresentation8.CubeAxesCornerOffset = 0.0
+DataRepresentation8.SelectionPointLabelJustification = 'Left'
+DataRepresentation8.SelectionPointLabelVisibility = 0
+DataRepresentation8.SelectOrientationVectors = ''
+DataRepresentation8.CubeAxesTickLocation = 'Inside'
+DataRepresentation8.CubeAxesXAxisMinorTickVisibility = 1
+DataRepresentation8.CubeAxesYAxisVisibility = 1
+DataRepresentation8.SelectionPointLabelFontFamily = 'Arial'
+DataRepresentation8.Source.ShaftResolution = 6
+DataRepresentation8.CubeAxesFlyMode = 'Closest Triad'
+DataRepresentation8.SelectScaleArray = ''
+DataRepresentation8.CubeAxesYTitle = 'Y-Axis'
+DataRepresentation8.ColorAttributeType = 'POINT_DATA'
+DataRepresentation8.SpecularPower = 100.0
+DataRepresentation8.Texture = []
+DataRepresentation8.SelectionCellLabelShadow = 0
+DataRepresentation8.AmbientColor = [1.0, 1.0, 1.0]
+DataRepresentation8.MapScalars = 1
+DataRepresentation8.PointSize = 2.0
+DataRepresentation8.Source.TipLength = 0.35
+DataRepresentation8.SelectionCellLabelFormat = ''
+DataRepresentation8.Scaling = 0
+DataRepresentation8.StaticMode = 0
+DataRepresentation8.SelectionCellLabelColor = [0.0, 1.0, 0.0]
+DataRepresentation8.Source.TipRadius = 0.1
+DataRepresentation8.EdgeColor = [0.0, 0.0, 0.5000076295109483]
+DataRepresentation8.CubeAxesXAxisTickVisibility = 1
+DataRepresentation8.SelectionCellLabelVisibility = 0
+DataRepresentation8.NonlinearSubdivisionLevel = 1
+DataRepresentation8.CubeAxesXAxisRange = [0.0, 1.0]
+DataRepresentation8.Representation = 'Surface'
+DataRepresentation8.CubeAxesYAxisRange = [0.0, 1.0]
+DataRepresentation8.CustomBounds = [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
+DataRepresentation8.Orientation = [0.0, 0.0, 0.0]
+DataRepresentation8.CubeAxesEnableCustomAxisRange = 0
+DataRepresentation8.CubeAxesXTitle = 'X-Axis'
+DataRepresentation8.CubeAxesInertia = 1
+DataRepresentation8.BackfaceOpacity = 1.0
+DataRepresentation8.SelectionCellFieldDataArrayName = 'vtkOriginalCellIds'
+DataRepresentation8.SelectionColor = [1.0, 0.0, 1.0]
+DataRepresentation8.Ambient = 0.0
+DataRepresentation8.SelectionPointLabelFontSize = 18
+DataRepresentation8.ScaleFactor = 0.8328240185976029
+DataRepresentation8.BackfaceAmbientColor = [1.0, 1.0, 1.0]
+DataRepresentation8.Source.ShaftRadius = 0.03
+DataRepresentation8.SelectMaskArray = ''
+DataRepresentation8.SelectionLineWidth = 2.0
+DataRepresentation8.CubeAxesZAxisMinorTickVisibility = 1
+DataRepresentation8.CubeAxesXAxisVisibility = 1
+DataRepresentation8.Interpolation = 'Gouraud'
+DataRepresentation8.SelectionCellLabelFontFamily = 'Arial'
+DataRepresentation8.SelectionCellLabelItalic = 0
+DataRepresentation8.CubeAxesYAxisMinorTickVisibility = 1
+DataRepresentation8.CubeAxesZGridLines = 0
+DataRepresentation8.SelectionPointLabelFormat = ''
+DataRepresentation8.SelectionPointLabelOpacity = 1.0
+DataRepresentation8.BackfaceDiffuseColor = [1.0, 1.0, 1.0]
+DataRepresentation8.Pickable = 1
+DataRepresentation8.CustomBoundsActive = [0, 0, 0]
+DataRepresentation8.SelectionRepresentation = 'Wireframe'
+DataRepresentation8.SelectionPointLabelBold = 0
+DataRepresentation8.ColorArrayName = 'radiusOrig'
+DataRepresentation8.SelectionPointLabelItalic = 0
+DataRepresentation8.AllowSpecularHighlightingWithScalarColoring = 0
+DataRepresentation8.SpecularColor = [1.0, 1.0, 1.0]
+DataRepresentation8.LookupTable = a1_radiusOrig_PVLookupTable
+DataRepresentation8.SelectionPointSize = 5.0
+DataRepresentation8.SelectionCellLabelBold = 0
+DataRepresentation8.Orient = 0
+
+Render()
=== modified file 'py/export.py'
--- py/export.py 2014-01-28 13:33:10 +0000
+++ py/export.py 2014-02-17 16:37:16 +0000
@@ -7,13 +7,14 @@
from yade import utils,Matrix3,Vector3
#textExt===============================================================
-def textExt(filename, format='x_y_z_r', comment='',mask=-1):
+def textExt(filename, format='x_y_z_r', comment='',mask=-1,attrs=[]):
"""Save sphere coordinates and other parameters into a text file in specific format. Non-spherical bodies are silently skipped. Users can add here their own specific format, giving meaningful names. The first file row will contain the format name. Be sure to add the same format specification in ymport.textExt.
:param string filename: the name of the file, where sphere coordinates will be exported.
- :param string format: the name of output format. Supported 'x_y_z_r'(default), 'x_y_z_r_matId'
- :param string comment: the text, which will be added as a comment at the top of file. If you want to create several lines of text, please use '\\\\n#' for next lines.
+ :param string format: the name of output format. Supported 'x_y_z_r'(default), 'x_y_z_r_matId', 'x_y_z_r_attrs' (use proper comment)
+ :param string comment: the text, which will be added as a comment at the top of file. If you want to create several lines of text, please use '\\\\n#' for next lines. With 'x_y_z_r_attrs' format, the last (or only) line should consist of column headers of quantities passed as attrs (1 comment word for scalars, 3 comment words for vectors and 9 comment words for matrices)
:param int mask: export only spheres with the corresponding mask export only spheres with the corresponding mask
+ :param [str] attrs: attributes to be exported with 'x_y_z_r_attrs' format. Each str in the list is evaluated for every body exported with body=b (i.e. 'b.state.pos.norm()' would stand for distance of body from coordinate system origin)
:return: number of spheres which were written.
:rtype: int
"""
@@ -26,12 +27,19 @@
count=0
+ # TODO use output=[] instrad of ''???
output = ''
outputVel=''
if (format<>'liggghts_in'):
output = '#format ' + format + '\n'
if (comment):
- output += '# ' + comment + '\n'
+ if format=='x_y_z_r_attrs':
+ cmts = comment.split('\n')
+ for cmt in cmts[:-1]:
+ output += cmt
+ output += '# x y z r ' + cmts[-1] + '\n'
+ else:
+ output += '# ' + comment + '\n'
minCoord= Vector3.Zero
maxCoord= Vector3.Zero
@@ -44,6 +52,17 @@
output+=('%g\t%g\t%g\t%g\n'%(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius))
elif (format=='x_y_z_r_matId'):
output+=('%g\t%g\t%g\t%g\t%d\n'%(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius,b.material.id))
+ elif (format=='x_y_z_r_attrs'):
+ output+=('%g\t%g\t%g\t%g'%(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius))
+ for cmd in attrs:
+ v = eval(cmd)
+ if isinstance(v,(int,float)):
+ output+='\t%g'%v
+ elif isinstance(v,Vector3):
+ output+='\t%g\t%g\t%g'%tuple(v[i] for i in xrange(3))
+ elif isinstance(v,Matrix3):
+ output+='\t%g'%tuple(v[i] for i in xrange(9))
+ output += '\n'
elif (format=='id_x_y_z_r_matId'):
output+=('%d\t%g\t%g\t%g\t%g\t%d\n'%(b.id,b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius,b.material.id))
elif (format=='jointedPM'):
@@ -75,6 +94,29 @@
out.write(output)
out.close()
return count
+
+ bodies = [b for b in O.bodies if isinstance(b.shape,Sphere) and (True if mask==-1 else b.msak==mask)]
+ data = []
+ for b in bodies:
+ pos = b.state.pos
+ d = [pos[i] for i in (0,1,2)]
+ for name,command in what:
+ val = eval(command)
+ if isinstance(val,Matrix3):
+ d.extend((val[0,0],val[0,1],val[0,2],val[1,0],val[1,1],val[1,2],val[2,0],val[2,1],val[2,2]))
+ elif isinstance(val,Vector3):
+ d.extend((v[0],v[1],v[2]))
+ elif isinstance(val,(int,float)):
+ d.append(val)
+ else:
+ print 'WARNING: export.text: wrong `what` parameter, output might be corrupted'
+ return 0
+ data.append(d)
+ dataw = [' '.join('%e'%v for v in d) for d in data]
+ outFile = open(filename,'w')
+ outFile.writelines(dataw)
+ outFile.close()
+ return len(bodies)
#textExt===============================================================
def textClumps(filename, format='x_y_z_r_clumpId', comment='',mask=-1):
@@ -792,3 +834,103 @@
pass
out.close()
return count
+
+
+
+
+# external vtk manipulation ===============================================================
+def text2vtk(inFileName,outFileName):
+ """Converts text file (created by :yref:`yade.export.textExt` function) into vtk file.
+ See :ysrc:`examples/test/paraview-spheres-solid-section/export_text.py` example
+
+ :param str inFileName: name of input text file
+ :param str outFileName: name of output vtk file
+ """
+ fin = open(inFileName)
+ fout = open(outFileName,'w')
+ lastLine = None
+ line = '#'
+ while line.startswith('#'):
+ lastLine = line
+ line = fin.readline()
+ columns = lastLine.split()[5:]
+ data = [line.split() for line in fin]
+ fin.close()
+ n = len(data)
+ fout.write('# vtk DataFile Version 3.0.\ncomment\nASCII\n\nDATASET POLYDATA\nPOINTS %d double\n'%(n))
+ fout.writelines('%s %s %s\n'%(d[0],d[1],d[2]) for d in data)
+ fout.write("\nPOINT_DATA %d\nSCALARS radius double 1\nLOOKUP_TABLE default\n"%(n))
+ fout.writelines('%s\n'%(d[3]) for d in data)
+ for i,c in enumerate(columns):
+ fout.write("\nSCALARS %s double 1\nLOOKUP_TABLE default\n"%(c))
+ fout.writelines('%s\n'%(d[4+i]) for d in data)
+ fout.close()
+
+def text2vtkSection(inFileName,outFileName,point,normal=(1,0,0)):
+ """Converts section through spheres from text file (created by :yref:`yade.export.textExt` function) into vtk file.
+ See :ysrc:`examples/test/paraview-spheres-solid-section/export_text.py` example
+
+ :param str inFileName: name of input text file
+ :param str outFileName: name of output vtk file
+ :param Vector3|(float,float,float) point: coordinates of a point lying on the section plane
+ :param Vector3|(float,float,float) normal: normal vector of the section plane
+ """
+ from math import sqrt
+ norm = sqrt(pow(normal[0],2)+pow(normal[1],2)+pow(normal[2],2))
+ normal = (normal[0]/norm,normal[1]/norm,normal[2]/norm)
+ #
+ def computeD(point,normal):
+ # from point and normal computes parameter d in plane equation ax+by+cz+d=0
+ return -normal[0]*point[0] - normal[1]*point[1] - normal[2]*point[2]
+ def computeDistanceFromPlane(dat,point,normal,d=None):
+ # computes distance of sphere dat from plane (point,normal)
+ x,y,z = computeProjectionOnPlane(dat,point,normal,d)
+ cx,cy,cz = dat[0],dat[1],dat[2]
+ return sqrt(pow(x-cx,2)+pow(y-cy,2)+pow(z-cz,2))
+ def computeProjectionOnPlane(self,point,normal,d=None):
+ # computes projection of sphere dat on plane (point,normal)
+ if d is None:
+ d = computeD(point,normal)
+ nx,ny,nz = normal[0],normal[1],normal[2]
+ cx,cy,cz = dat[0],dat[1],dat[2]
+ t = (-d-nx*cx-ny*cy-nz*cz) / (nx*nx+ny*ny+nz*nz)
+ x,y,z = cx+t*nx, cy+t*ny, cz+t*nz
+ return x,y,z
+ #
+ fin = open(inFileName)
+ lastLine = None
+ line = '#'
+ while line.startswith('#'):
+ lastLine = line
+ line = fin.readline()
+ columns = lastLine.split()[4:]
+ data = [[float(w) for w in line.split()] for line in fin]
+ fin.close()
+ #
+ d = computeD(point,normal)
+ circs = []
+ for dat in data:
+ r = dat[3]
+ dst = computeDistanceFromPlane(dat,point,normal,d)
+ if dst > r:
+ continue
+ x,y,z = computeProjectionOnPlane(dat,point,normal,d)
+ rNew = sqrt(r*r-dst*dst)
+ dNew = [x,y,z,rNew,r]
+ dNew.extend(dat[4:])
+ circs.append(dNew)
+ n = len(circs)
+ fout = open(outFileName,'w')
+ fout.write('# vtk DataFile Version 3.0.\ncomment\nASCII\n\nDATASET POLYDATA\nPOINTS %d double\n'%(n))
+ fout.writelines('%g %g %g\n'%(c[0],c[1],c[2]) for c in circs)
+ fout.write("\nPOINT_DATA %d\nSCALARS radius double 1\nLOOKUP_TABLE default\n"%(n))
+ fout.writelines('%g\n'%(c[3]) for c in circs)
+ fout.write("\nSCALARS radiusOrig double 1\nLOOKUP_TABLE default\n")
+ fout.writelines('%g\n'%(c[4]) for c in circs)
+ fout.write("\nVECTORS normal double\n")
+ fout.writelines("%g %g %g\n"%normal for i in circs)
+ for i,c in enumerate(columns):
+ fout.write("\nSCALARS %s double 1\nLOOKUP_TABLE default\n"%(c))
+ fout.writelines('%s\n'%(c[4+i]) for c in circs)
+ fout.close()
+