Results FindWords(const char * board, unsigned width, unsigned height) { Results results = {}; results.Score = 0; results.Count = 0; std::queue<BoardState> queue; std::unordered_set<std::string> foundWords; prepareSearch(queue, board, width, height); // process the queue while (!queue.empty()) { BoardState node = queue.front(); queue.pop(); char sym = board[node.nextIndex]; // only append the character if that path is correct if (node.visited_nodes[node.nextIndex] == empty) { node.word += sym; } // handle the 'q'-> 'qu' case by making a copy of current 'q' node, marking it and pushing it to the queue if (sym == 'q' && node.visited_nodes[node.nextIndex] == empty) { processQnode(node, queue); } node.visited_nodes[node.nextIndex] = used; // if we matched the word, we just add it to the results, but it may be a part of a longer word so continue match_t match = matchPath(node); if (node.word.length() >= MIN_WORD_SIZE && match == full_match) { foundWords.insert(node.word); } if (match == full_match || match == partial_match) { processNeighbourNodes(width, height, node, queue); } } combineResults(results, foundWords); return results; }
void SelectionDialog::combineResultsSelected(){ emit(combineResults(false)); }
qreal QGLBezierPatch::intersection (qreal result, int depth, const QRay3D& ray, bool anyIntersection, qreal xtex, qreal ytex, qreal wtex, qreal htex, QVector2D *tc) { // Check the convex hull of the patch for an intersection. // If no intersection with the convex hull, then there is // no point subdividing this patch further. QBox3D box; for (int point = 0; point < 16; ++point) box.unite(points[point]); if (!box.intersects(ray)) return result; // Are we at the lowest point of subdivision yet? if (depth <= 1) { // Divide the patch into two triangles and intersect with those. QTriangle3D triangle1(points[0], points[3], points[12]); qreal t = triangle1.intersection(ray); if (!qIsNaN(t)) { result = combineResults(result, t); if (result == t) { QVector2D uv = triangle1.uv(ray.point(t)); QVector2D tp(xtex, ytex); QVector2D tq(xtex + wtex, ytex); QVector2D tr(xtex, ytex + htex); *tc = uv.x() * tp + uv.y() * tq + (1 - uv.x() - uv.y()) * tr; } } else { QTriangle3D triangle2(points[3], points[15], points[12]); qreal t = triangle2.intersection(ray); if (!qIsNaN(t)) { result = combineResults(result, t); if (result == t) { QVector2D uv = triangle2.uv(ray.point(t)); QVector2D tp(xtex + wtex, ytex); QVector2D tq(xtex + wtex, ytex + htex); QVector2D tr(xtex, ytex + htex); *tc = uv.x() * tp + uv.y() * tq + (1 - uv.x() - uv.y()) * tr; } } } } else { // Subdivide the patch to find the point of intersection. QGLBezierPatch patch1, patch2, patch3, patch4; subDivide(patch1, patch2, patch3, patch4); --depth; qreal hwtex = wtex / 2.0f; qreal hhtex = htex / 2.0f; result = patch1.intersection (result, depth, ray, anyIntersection, xtex, ytex, hwtex, hhtex, tc); if (anyIntersection && !qIsNaN(result)) return result; result = patch2.intersection (result, depth, ray, anyIntersection, xtex + hwtex, ytex, hwtex, hhtex, tc); if (anyIntersection && !qIsNaN(result)) return result; result = patch3.intersection (result, depth, ray, anyIntersection, xtex, ytex + hhtex, hwtex, hhtex, tc); if (anyIntersection && !qIsNaN(result)) return result; result = patch4.intersection (result, depth, ray, anyIntersection, xtex + hwtex, ytex + hhtex, hwtex, hhtex, tc); } return result; }