Пример #1
0
    def printMetaEdge(self, edge: MetaEdge3d):
        p0 = self.metaGraph.nodeLocations[edge.node0]
        p1 = self.metaGraph.nodeLocations[edge.node1]

        p0 = drawingUtil.p3d2arr(p0)
        p1 = drawingUtil.p3d2arr(p1)
        print(p0, p1)
Пример #2
0
    def getFirstEdgeHit(self, origin: np.array, ray: np.array):
        """
        determines the first edge that is hit by a picking ray
        returns a tuple of (hitDetected, edgeHit, edgeHitId)
        hitDetected : boolean indicator of hit detection
        edgeHit : MetaEdge3d that is hit
        edgeHitId : id of the edge in the skeletons edgeList
        """
        print('detecting hits')
        minDist = 100000000
        hitFound = False
        edgeHit = None
        edgeHitId = -1
        if not self.hasMetaGraph:
            return (hitFound, edgeHit, edgeHitId)
        i = 0
        for edge in self.metaGraph.edgeConnections:

            p0 = self.metaGraph.nodeLocations[edge.node0]
            p1 = self.metaGraph.nodeLocations[edge.node1]
            if isinstance(p0, Point3d) or isinstance(p0, MetaNode3d):
                p0 = drawingUtil.p3d2arr(p0)
                p1 = drawingUtil.p3d2arr(p1)

            (doesIntersect,
             distance) = util.intersectRayCylinder(origin, ray, p0, p1,
                                                   edge.thickness)
            if not doesIntersect:
                (doesIntersect,
                 distance) = util.intersectRaySphere(origin, ray, p0,
                                                     edge.thickness)
            if not doesIntersect:
                (doesIntersect,
                 distance) = util.intersectRaySphere(origin, ray, p1,
                                                     edge.thickness)

            if doesIntersect:
                if distance < minDist:
                    hitFound = True
                    minDist = distance
                    edgeHit = edge
                    edgeHitId = edge.order
            i = i + 1

        if hitFound:
            print('hit detected')
            self.printMetaEdge(edgeHit)
        else:
            print('no hit detected')
        return (hitFound, edgeHit, edgeHitId)
Пример #3
0
    def getFirstNodeHit(self, origin: np.array, ray: np.array):
        print('detecting node hits')
        minDist = 1000000000
        hitFound = False
        nodeHit = None
        nodeHitId = -1

        if not self.hasMetaGraph:
            return (hitFound, nodeHit, nodeHitId)

        i = 0
        for node in self.metaGraph.nodeLocations:
            p = drawingUtil.p3d2arr(node)
            (doesIntersect,
             distance) = util.intersectRaySphere(origin, ray, p,
                                                 self.nodeSizeMap[i])

            if doesIntersect:
                if distance < minDist:
                    hitFound = True
                    minDist = distance
                    nodeHit = node
                    nodeHitId = i
            i = i + 1

        if hitFound:
            print('hit detected')
            self.printMetaNode(nodeHit)
        else:
            print('no hit detected')

        return (hitFound, nodeHit, nodeHitId)
Пример #4
0
 def printMetaNode(self, node: MetaNode3d):
     p = drawingUtil.p3d2arr(node)
     print(p)