Example #1
0
def mainR():
    '''
  Test to demonstrate reading an obj file
  and using clones

  '''
    from PyRatObjParser import PyRatObjParser
    from PyRatClone import PyRatClone
    from PyRatBox import test
    import sys

    if len(sys.argv) > 1:
        filename = sys.argv[1]
    else:
        filename = 'tests/clone2.obj'
        filename = 'tests/new_plant.obj'

    hasGL = False
    world = PyRatObjParser(filename, verbose=True, GL=True)
    if world.root.size == 0:
        world.error('Zero size in world root')
        return False
    world.root.planes = world.infinitePlane

    info = {'verbose': True}
    name = str(globals()['__file__'].split('/')[-1].split('.')[0])
    test(np.zeros(3),
         np.zeros(3),
         obj=world.root,
         info=info,
         type=name,
         nAtTime=100 * 100 / 20,
         name=name[5:])
    return True
Example #2
0
def mainR():
  '''
  Test to demonstrate reading an obj file
  and using clones

  '''
  from PyRatObjParser import PyRatObjParser
  from PyRatClone import PyRatClone
  from PyRatBox import test
  import sys
  
  if len(sys.argv) > 1:
    filename = sys.argv[1]
  else:
    filename = 'tests/clone2.obj'
    filename = 'tests/new_plant.obj'
    
  hasGL = False
  world = PyRatObjParser(filename,verbose=True,GL=True)
  if world.root.size == 0:
    world.error('Zero size in world root')
    return False
  world.root.planes = world.infinitePlane

  info = {'verbose':True}
  name = str(globals()['__file__'].split('/')[-1].split('.')[0])
  test(np.zeros(3),np.zeros(3),obj=world.root,info=info,type=name,nAtTime=100*100/20,name=name[5:])
  return True  
Example #3
0
def main():
    '''
  Test code
  '''
    from PyRatObjParser import PyRatObjParser
    filename = 'spheresTest/HET01_DIS_UNI_NIR_20/HET01_DIS_UNI_NIR_20.obj'
    try:
        world = PyRatObjParser.load(filename + '.npz')
    except:
        world = PyRatObjParser(filename, verbose=True)
        world.dump(filename + '.npz')

    print 'ok'
Example #4
0
def main():
  '''
  Test code
  '''
  from PyRatObjParser import PyRatObjParser
  filename = 'spheresTest/HET01_DIS_UNI_NIR_20/HET01_DIS_UNI_NIR_20.obj'
  try:
    world = PyRatObjParser.load(filename +'.npz')
  except:
    world = PyRatObjParser(filename,verbose=True)
    world.dump(filename +'.npz')

  print 'ok'
Example #5
0
def main():
    '''
  A simple test of the clone algorithm
  
  A scan over a cube is made and 2 images produced
  tests/PyRatBox-near.png and tests/PyRatBox-far.png
  with the near and far distances 

  Here we also demonstrate that setting info['lad']
  makes the object volumetric
  '''
    from PyRatBox import PyRatBox
    from PyRatSpheroid import PyRatSpheroid
    from PyRatClone import PyRatClone
    from PyRatEllipsoid import PyRatEllipsoid
    from PyRatObjParser import PyRatObjParser
    from PyRatPlane import PyRatPlane
    from tempfile import NamedTemporaryFile
    import os

    data = '''
  !{
  !{
  v 0 0 0
  v 0 0 1
  plane -1 -2
  #define objects
  g group
  box 2 2 0.5 1 1 1
  v 0 0 1
  sph -1 0.5
  v 2 1 2
  sph -1 0.5
  v -1 1 0
  ell -1 0.2 0.3 1
  !}
  clone -0.5 1.5 0 Rz 45 Ry 10 Rx -5 group
  !}
  '''
    f = NamedTemporaryFile(delete=False)
    f.write(data)
    f.close()

    p = PyRatObjParser(f.name)
    p.root.planes = p.infinitePlane

    name = str(globals()['__file__'].split('/')[-1].split('.')[0])
    test(np.zeros(3),
         None,
         obj=p.root,
         info={},
         type=name,
         nAtTime=100 * 100 / 20,
         name=name[5:])
    os.unlink(f.name)
Example #6
0
def mainGL():
    '''
  To test GL 
  '''
    from PyRatObjParser import PyRatObjParser
    from PyRatClone import PyRatClone
    from PyRatBox import test
    if len(sys.argv) > 1:
        filename = sys.argv[1]
    else:
        filename = 'tests/clone2.obj'
        filename = 'tests/new_plant.obj'
    world = PyRatObjParser(filename, verbose=True, GL=True)
    mlab.show()