how to use povwall to visualize walls

Asked by guo

Dear all,
I have known from https://answers.launchpad.net/esys-particle/+question/128526 that Esys-particle could visualize wall.
it is something like this.
from esys.lsm.vis.povray import TriangulatedSurface
...
   nodelist=[
              Vec3(0,0,-0.5),
              Vec3(0,0, 0.5),
              Vec3(0.02,0,0.5),
              Vec3(0.02,0,-0.5)
            ]
   trianglelist = [
                   (0,1,2),
                   (0,2,3)
                  ]
   povWall=TriangulatedSurface(nodelist,trianglelist)
   povWall.apply(pkg.Colors.Gray)
   scene.add(povWall)

My question is how to add this to the POVsnaps.py, so that triangle walls could be visualized when call this POVsnaps.py. specifically, how to do this in the hopper_flow.py

Thanks a lot.

Guo

Question information

Language:
English Edit question
Status:
Solved
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Solved by:
J E
Solved:
Last query:
Last reply:
Revision history for this message
Dion Weatherley (d-weatherley) said :
#1

Hi Guo,

To add wall visualisation to POVsnaps.py, you will need to add a subroutine to the POVsnaps Runnable that reads the meshfile (floorMesh.msh) and constructs the nodelist and trianglelist lists accordingly. This subroutine can be called once during the init(..) subroutine call.

After that just add the following code-fragment to the snapshot(..) subroutine just before the "camera = Scene.getCamera()" line.

   povWall=TriangulatedSurface(nodelist,trianglelist)
   povWall.apply(pkg.Colors.Gray)
   scene.add(povWall)

Cheers,

Dion.

Revision history for this message
guo (kwohoo) said :
#2

Thank you Dion, how to add a subroutine to the POVsnaps Runnable that reads the meshfile (floorMesh.msh)? and do you mean constructs the nodelist and triangelist lists in the my py inputfile?

Revision history for this message
Best J E (j-ehlig) said :
#3

Hi Guo,

First you have to add an extra input parameter for the name of your meshfile
to __init__ of POVsnaps and add it to self.

def __init__(self, sim, interval, mesh):
  ...
  self.mesh = mesh
  ...

The next step is to add a subroutine called readMesh(self) to POVsnaps.py
that reads the meshfile stored in self.mesh and stores the data in self.nodelist
and self.trianglelist like you posted it in your question.
I'm a newbie to Python so please don't judge me for the following lines...

  def readMesh(self):
    meshFile = open(self.mesh,"r")
    meshData = meshFile.readlines()
    nodes = int(meshData[1][9:])
    self.nodelist = [0]*nodes
    triangles = int(meshData[3+nodes][5:])
    self.trianglelist = [0]*triangles
    for i in range(nodes):
      # Read node lines
      splitIt = meshData[2+i].split()
      self.nodelist[i] = Vec3(float(splitIt[3]),float(splitIt[4]),float(splitIt[5]))
    for i in range(triangles):
      # Read triangle lines
      splitIt = meshData[4+nodes+i].split()
      self.trianglelist[i] = Vec3(int(splitIt[2]),int(splitIt[3]),int(splitIt[4]))
    meshFile.close()

The very last thing is that you have to do is to add these three lines to
your snapshot subroutine in POVsnaps:

  povWall = TriangulatedSurface(self.nodelist,self.trianglelist)
  povWall.apply(pkg.Colors.Gray)
  Scene.add(povWall)

All this worked for hopper_flow.py and a pyramide I built by myself.
Enjoy!

Revision history for this message
guo (kwohoo) said :
#4

Thanks J E, that solved my question.