Example #1
0
def getMergedConvexHullsMesh(chulls):
    d = DebugData()
    for i, chull in enumerate(chulls):
        d.addPolyData(chull.convexHull, color=segmentation.getRandomColor())
    return d.getPolyData()
def getMergedConvexHullsMesh(chulls):
    d = DebugData()
    for i, chull in enumerate(chulls):
        d.addPolyData(chull.convexHull, color=segmentation.getRandomColor())
    return d.getPolyData()
Example #3
0
        chulls.append(
            computePlanarConvexHull(planePoints,
                                    expectedNormal=expectedNormal))

    if removeGround:
        chulls.append(
            computePlanarConvexHull(groundPoints, expectedNormal=[0, 0, 1]))

    d = DebugData()

    for i, result in enumerate(chulls):

        planePoints, chull, plane = result.points, result.convexHull, result.plane

        c = segmentation.getRandomColor()
        vis.showPolyData(planePoints, 'plane %d' % i, color=c)
        chull = vis.showPolyData(chull, 'convex hull %d' % i, color=c)
        chull.setProperty('Surface Mode', 'Surface with edges')
        chull.actor.GetProperty().SetLineWidth(3)

        center = segmentation.computeCentroid(chull.polyData)
        chullPoints = vnp.getNumpyFromVtk(chull.polyData, 'Points')
        d.addLine(plane.GetOrigin(),
                  np.array(plane.GetOrigin()) +
                  0.005 * np.array(plane.GetNormal()),
                  radius=0.0001,
                  color=[0, 0, 0])
        #d.addArrow(plane.GetOrigin(), np.array(plane.GetOrigin()) + 0.01 * np.array(plane.GetNormal()), headRadius=0.001, tubeRadius=0.0002)
        #d.addSphere(chullPoints[0], radius=0.001, color=[1,0,0])
        #d.addSphere(chullPoints[1], radius=0.001, color=[0,1,0])
            expectedNormal = None

        chulls.append(computePlanarConvexHull(planePoints, expectedNormal=expectedNormal))


    if removeGround:
        chulls.append(computePlanarConvexHull(groundPoints, expectedNormal=[0,0,1]))


    d = DebugData()

    for i, result in enumerate(chulls):

        planePoints, chull, plane = result.points, result.convexHull, result.plane

        c = segmentation.getRandomColor()
        vis.showPolyData(planePoints, 'plane %d' % i, color=c)
        chull = vis.showPolyData(chull, 'convex hull %d' % i, color=c)
        chull.setProperty('Surface Mode', 'Surface with edges')
        chull.actor.GetProperty().SetLineWidth(3)

        center = segmentation.computeCentroid(chull.polyData)
        chullPoints = vnp.getNumpyFromVtk(chull.polyData, 'Points')
        d.addLine(plane.GetOrigin(), np.array(plane.GetOrigin()) + 0.005 * np.array(plane.GetNormal()), radius=0.0001, color=[0,0,0])
        #d.addArrow(plane.GetOrigin(), np.array(plane.GetOrigin()) + 0.01 * np.array(plane.GetNormal()), headRadius=0.001, tubeRadius=0.0002)
        #d.addSphere(chullPoints[0], radius=0.001, color=[1,0,0])
        #d.addSphere(chullPoints[1], radius=0.001, color=[0,1,0])


    vis.showPolyData(d.getPolyData(), 'plane normals', colorByName='RGB255')