def getFirstEdgeHit(self, origin: np.array, ray: np.array): minDist = 100000000 hitFound = False edgeHit = None edgeHitId = -1 if not self.hasMetaGraph: return (hitFound, edgeHit, edgeHitId) if self.currentDisplayMode == 0 or self.currentDisplayMode == 2: for edge in self.MetaEdgesGL: if self.minimizedComponentMap[edge.component]: continue p0 = edge.v0 p1 = edge.v1 (doesIntersect, distance) = util.intersectRayCylinder(origin, ray, p0, p1, edge.scale) if not doesIntersect: (doesIntersect, distance) = util.intersectRaySphere( origin, ray, p0, edge.scale) if not doesIntersect: (doesIntersect, distance) = util.intersectRaySphere( origin, ray, p1, edge.scale) if doesIntersect: if distance < minDist: hitFound = True minDist = distance edgeHit = self.graph.edgeConnections[edge.id] edgeHitId = edge.order if self.currentDisplayMode == 1 or self.currentDisplayMode == 2: metaEdgeI = -1 for edgeList in self.SkelEdgesGL: metaEdgeI = metaEdgeI + 1 for edgeGL in edgeList: if self.minimizedComponentMap[edgeGL.component]: continue p0 = edgeGL.v0 p1 = edgeGL.v1 (doesIntersect, distance) = util.intersectRayCylinder( origin, ray, p0, p1, edgeGL.scale) if doesIntersect: if distance < minDist: hitFound = True minDist = distance edgeHit = self.graph.edgeConnections[metaEdgeI] edgeHitId = metaEdgeI if hitFound: print('edge hit') return (hitFound, edgeHit, edgeHitId)
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)
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)
def getFirstNodeHit(self, origin: np.array, ray: np.array): minDist = 1000000000 hitFound = False nodeHit = None nodeHitId = -1 if not self.hasMetaGraph: return (hitFound, nodeHit, nodeHitId) for node in self.MetaNodesGL: if self.minimizedComponentMap[node.component]: continue p = node.v0 (doesIntersect, distance) = util.intersectRaySphere(origin, ray, p, node.scale) if doesIntersect: if distance < minDist: hitFound = True minDist = distance nodeHit = self.graph.nodeLocations[node.id] nodeHitId = node.id if hitFound: print('node hit') return (hitFound, nodeHit, nodeHitId)