Exemplo n.º 1
0
def createFatPoint(x, y, z, r):
  ico = M.createIcosahedron(2, r)
  for p in ico:
    p.x += x
    p.y += y
    p.z += z
  return ico
def run():
  if 0 == Display.getSelected().size():
    print "Nothing selected!"
    return
  tree = Display.getSelected()[0]
  if not isinstance(tree, AreaTree):
    print "Not an AreaTree!"
    return
  cal = tree.getLayerSet().getCalibration()
  for nd in tree.getRoot().getSubtreeNodes():
    area = nd.getData()
    if area is None:
      continue
    pols = M.getPolygons(area)
    if len(pols) > 1:
      report(nd, pols, tree.getAffineTransform(), cal)
      if remove_all_but_largest:
        removeAllButLargest(area, pols)
    elif len(pols) == 1:
      print "Found a single polygon with bounds: "+str(pols[0].getBounds())
  Display.repaint()
Exemplo n.º 3
0
from jarray import array
from ini.trakem2.utils import M

delta = 1.0

vs1 = VectorString2D(array([0, 1, 2, 3, 4, 5, 6], 'd'),
                     array([0, 0, 0, 0, 0, 0, 0], 'd'), 0, False)

vs2 = VectorString2D(array([0, 1, 2, 3, 4, 5, 6], 'd'),
                     array([0, 0, 0, 0, 0, 0, 0], 'd'), 1, False)

print vs1.length(), vs2.length(), vs1.getPoints(0), vs1.getPoints(1)

vs1.resample(delta)
vs2.resample(delta)

print vs1.length(), vs2.length(), vs1.getPoints(0), vs1.getPoints(1)

editions = Editions(vs1, vs2, delta, False)
match = SkinMaker.Match(vs1, vs2, editions, None)
triangles = match.generateTriangles(False)

print len(triangles)

area = 0.0
for i in xrange(0, len(triangles), 3):
    a = M.measureArea(triangles[i], triangles[i + 1], triangles[i + 2])
    print i, a
    area += a

print area