Ejemplo n.º 1
0
    def draw(self):

        d = DebugData()

        points = list(self.points)
        if self.hoverPos is not None:
            points.append(self.hoverPos)

        # draw points
        radius = 5
        scale = (2 * self.view.camera().GetParallelScale()) / (
            self.view.renderer().GetSize()[1])
        for p in points:
            d.addSphere(p, radius=radius * scale)

        if self.drawLines and len(points) > 1:
            for a, b in zip(points, points[1:]):
                d.addLine(a, b)

            # connect end points
            # d.addLine(points[0], points[-1])

        if self.annotationObj:
            self.annotationObj.setPolyData(d.getPolyData())
        else:
            self.annotationObj = vis.updatePolyData(
                d.getPolyData(),
                "annotation",
                parent="segmentation",
                color=[1, 0, 0],
                view=self.view,
            )
            self.annotationObj.addToView(self.view)
            self.annotationObj.actor.SetPickable(False)
            self.annotationObj.actor.GetProperty().SetLineWidth(2)
Ejemplo n.º 2
0
    def draw(self):

        d = DebugData()

        points = [p if p is not None else self.hoverPos for p in self.points]

        # draw points
        for p in points:
            if p is not None:
                d.addSphere(p, radius=0.008)

        if self.drawLines:
            # draw lines
            for a, b in zip(points, points[1:]):
                if b is not None:
                    d.addLine(a, b)

            # connect end points
            if points[-1] is not None and self.drawClosedLoop:
                d.addLine(points[0], points[-1])

        self.annotationObj = vis.updatePolyData(
            d.getPolyData(),
            self.annotationName,
            parent=self.annotationFolder,
            view=self.view,
        )
        self.annotationObj.setProperty("Color", [1, 0, 0])
        self.annotationObj.actor.SetPickable(False)
Ejemplo n.º 3
0
    def run(self):

        radius = self.properties.getProperty('Radius')
        thickness = 0.03

        folder = om.getOrCreateContainer('affordances')
        frame = self.computeValveFrame()
        d = DebugData()
        d.addLine(np.array([0, 0, -thickness / 2.0]),
                  np.array([0, 0, thickness / 2.0]),
                  radius=radius)
        mesh = d.getPolyData()
        params = dict(radius=radius,
                      length=thickness,
                      xwidth=radius,
                      ywidth=radius,
                      zwidth=thickness,
                      otdf_type='steering_cyl',
                      friendly_name='valve')

        affordance = vis.showPolyData(mesh,
                                      'valve',
                                      color=[0.0, 1.0, 0.0],
                                      cls=affordanceitems.FrameAffordanceItem,
                                      parent=folder,
                                      alpha=1.0)
        frame = vis.showFrame(frame,
                              'valve frame',
                              parent=affordance,
                              visible=False,
                              scale=radius)
        affordance.actor.SetUserTransform(frame.transform)
        affordance.setAffordanceParams(params)
        affordance.updateParamsFromActorTransform()
Ejemplo n.º 4
0
def rayDebug(position, ray):
    d = DebugData()
    d.addLine(position, position + ray * 5.0)
    drcView = app.getViewManager().findView("DRC View")
    obj = vis.updatePolyData(
        d.getPolyData(), "camera ray", view=drcView, color=[0, 1, 0]
    )
    obj.actor.GetProperty().SetLineWidth(2)
Ejemplo n.º 5
0
    def update(self):

        t = self.frameProvider.getFrame("MULTISENSE_SCAN")

        p1 = [0.0, 0.0, 0.0]
        p2 = [2.0, 0.0, 0.0]

        p1 = t.TransformPoint(p1)
        p2 = t.TransformPoint(p2)

        d = DebugData()
        d.addSphere(p1, radius=0.01, color=[0, 1, 0])
        d.addLine(p1, p2, color=[0, 1, 0])
        self.setPolyData(d.getPolyData())
Ejemplo n.º 6
0
    def updateCursor(self, displayPoint):

        center = self.displayPointToImagePoint(displayPoint,
                                               restrictToImageDimensions=False)
        center = np.array(center)

        d = DebugData()
        d.addLine(center + [0, -3000, 0], center + [0, 3000, 0])
        d.addLine(center + [-3000, 0, 0], center + [3000, 0, 0])
        self.cursorObj = vis.updatePolyData(d.getPolyData(),
                                            "cursor",
                                            alpha=0.5,
                                            view=self.view)
        self.cursorObj.addToView(self.view)
        self.cursorObj.actor.SetUseBounds(False)
        self.cursorObj.actor.SetPickable(False)
        self.view.render()
Ejemplo n.º 7
0
    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')

    #saveConvexHulls(chulls, name)
    #vis.showPolyData(ioUtils.readPolyData(os.path.join(name, 'merged_planes.ply')), 'merged_planes')


applogic.resetCamera([1,1,0])
applogic.setBackgroundColor([1,1,1])
view.orientationMarkerWidget().Off()
app.gridObj.setProperty('Color', [0,0,0])