def createLine(blockDimensions, p1, p2):


    sliceWidth = np.array(blockDimensions).max()/2.0 + 0.02
    sliceThreshold =  [-sliceWidth, sliceWidth]


    # require p1 to be point on left
    if p1[0] > p2[0]:
        p1, p2 = p2, p1

    _, worldPt1 = getRayFromDisplayPoint(app.getCurrentRenderView(), p1)
    _, worldPt2 = getRayFromDisplayPoint(app.getCurrentRenderView(), p2)

    cameraPt = np.array(app.getCurrentRenderView().camera().GetPosition())

    leftRay = worldPt1 - cameraPt
    rightRay = worldPt2 - cameraPt
    middleRay = (leftRay + rightRay) / 2.0


    d = DebugData()
    d.addLine(cameraPt, worldPt1)
    d.addLine(cameraPt, worldPt2)
    d.addLine(worldPt1, worldPt2)
    d.addLine(cameraPt, cameraPt + middleRay)
    updatePolyData(d.getPolyData(), 'line annotation', parent=getDebugFolder(), visible=False)

    inputObj = om.findObjectByName('pointcloud snapshot')
    if inputObj:
        polyData = shallowCopy(inputObj.polyData)
    else:
        polyData = getCurrentRevolutionData()

    origin = cameraPt

    normal = np.cross(rightRay, leftRay)
    leftNormal = np.cross(normal, leftRay)
    rightNormal = np.cross(rightRay, normal)

    normal /= np.linalg.norm(normal)
    leftNormal /= np.linalg.norm(leftNormal)
    rightNormal /= np.linalg.norm(rightNormal)
    middleRay /= np.linalg.norm(middleRay)

    cropped, polyData = cropToPlane(polyData, origin, normal, sliceThreshold)

    updatePolyData(polyData, 'slice dist', parent=getDebugFolder(), colorByName='dist_to_plane', colorByRange=[-0.5, 0.5], visible=False)
    updatePolyData(cropped, 'slice',  parent=getDebugFolder(), colorByName='dist_to_plane', visible=False)

    cropped, _ = cropToPlane(cropped, origin, leftNormal, [-1e6, 0])
    cropped, _ = cropToPlane(cropped, origin, rightNormal, [-1e6, 0])

    updatePolyData(cropped, 'slice segment', parent=getDebugFolder(), colorByName='dist_to_plane', visible=False)

    planePoints, planeNormal = applyPlaneFit(cropped, distanceThreshold=0.005, perpendicularAxis=middleRay, angleEpsilon=math.radians(60))
    planePoints = thresholdPoints(planePoints, 'dist_to_plane', [-0.005, 0.005])
    updatePolyData(planePoints, 'board segmentation', parent=getDebugFolder(), color=getRandomColor(), visible=False)

    '''
    names = ['board A', 'board B', 'board C', 'board D', 'board E', 'board F', 'board G', 'board H', 'board I']
    for name in names:
        if not om.findObjectByName(name):
            break
    else:
        name = 'board'
    '''
    name = 'board'

    segmentBlockByTopPlane(planePoints, blockDimensions, expectedNormal=-middleRay, expectedXAxis=middleRay, edgeSign=-1, name=name)
dataset/ETHPy150Open RobotLocomotion/director/src/python/director/segmentation.py/createLine/original