Пример #1
0
def testprofiling(ID):
  tree = Display.getFront().getLayerSet().findById(ID)

  coords = Matrix(getNodeCoordinates(tree))

  #Define axis vectors and origin
  xnorm = Matrix([[1,0,0]])
  ynorm = Matrix([[0,1,0]])
  znorm = Matrix([[0,0,1]])
  center= Matrix([[0,0,0]])

  #Project nodes onto axis
  dpx=[]
  dpy=[]
  dpz=[]
  m=coords.getRowDimension()
  for i in range(0, m):
    xstore = Matrix([coords.getRow( i )]) * xnorm.transpose()
    ystore = Matrix([coords.getRow( i )]) * ynorm.transpose()
    zstore = Matrix([coords.getRow( i )]) * znorm.transpose()
    dpx.append(xstore.getRow(0))
    dpy.append(ystore.getRow(0))
    dpz.append(zstore.getRow(0))

  #get it back in array form (get rid of list in list of Jarray)

  dpx=[ x[0] for x in dpx]
  dpy=[ x[0] for x in dpy]
  dpz=[ x[0] for x in dpz]
  zipped=zip(dpx, dpy, dpz)
  
  return zipped
Пример #2
0
# print the map of nodes and the number of trees each connects to:
targetcontainer=[]
for node, targets in outgoing.iteritems():
  targetcontainer+=targets

#Save the IDs of treelines to an array and exclude connectors as well as duplicates
IDs=[]
for i in range(0, len(targetcontainer)):
  if targetcontainer[i].getClass() == Connector:
    continue
  if targetcontainer[i].size() == 0:
    continue
  else:
    ID=(targetcontainer[i].toArray()[0]).getId()
    IDs.append(int(ID))

#Get rid of duplicates and sort the list
ordered=list(set(IDs))

#filter out small fragments <=500 nodes
filtered=[]
for ID in ordered:
  tree = Display.getFront().getLayerSet().findById(ID)
  if len(getNodeCoordinates(tree)) >= 500:
    filtered.append(ID)
  else:
    continue
    
print filtered