Пример #1
0
const AnimationNode& Animation::GetNode(std::string& inodename)
{
	if (QueryNode(inodename))
	{
		return (*mCurrentFrame)->mNodes[inodename];
	}
	return Animation::InvalidNode;
}
Пример #2
0
void CuDlgMain::OnDropdownComboNode2() 
{
	try
	{
		CString strNode = _T("(local)");
		QueryNode(&m_cComboNode2, strNode);
	}
	catch (CeNodeException e)
	{
		SetForegroundWindow();
		BOOL bStarted = INGRESII_IsRunning();
		if (!bStarted)
			AfxMessageBox (IDS_MSG_INGRES_NOT_START);
		else
			AfxMessageBox (e.GetReason());
	}
	catch(...)
	{
	}
}
Пример #3
0
void PointTree::queryPoints3(const Rect& rect, int count, std::vector<Point>& r)
{
	r.clear();

	std::vector<QueryNode> q;

	for (Node* node : root) {
		if (Rect::Inside(node->bounds, rect)) {
			//printf("root optimization doe\n");
			auto cbn = static_cast<BranchNode*>(node);
			//q.push(QueryNode(cbn->best_pts, cbn->num_best_points, cbn->min_rank));
			//q.make_heap

			auto kef = QueryNode(cbn->best_pts, cbn->num_best_points, cbn->min_rank);
			auto it = std::lower_bound(q.begin(), q.end(), kef);
			q.insert(it, kef);
			//Heap.make_heap(q.begin(), q.end());

			continue;
		}

		if (Rect::Intersects(node->bounds, rect)) {
			//q.push(QueryNode(node, node->min_rank));
			auto kef = QueryNode(node, node->min_rank);
			auto it = std::lower_bound(q.begin(), q.end(), kef);
			q.insert(it, kef);
			//Heap.make_heap(q.begin(), q.end());
		}
	}

	std::make_heap(q.begin(), q.end());

	//printf("We innit dog\n");

	//auto it = q.begin();
	auto it = 0;
	//while (q.size() > 0) {
	while (it < q.size()) {
		auto qn = q[it++];

		//q.erase(q.begin());

		//q.pop();
		//Heap.pop_heap(q.begin(), q.end());
		//std::pop_heap(q.begin(), q.end()); 
		//q.pop_back();

		//printf(" %d", q.size());

		if (qn.count == -1) {
			auto bn = static_cast<BranchNode*>(qn.node);

			//Heap.pop_heap(q.begin(), q.end());
			//q.pop_back();

			auto iit = q.begin() + it;

			auto old = std::distance(iit, q.end());

			for (int i = 0; i < bn->count; i++) {
				auto child = bn->children[i];

				bool completely_inside = Rect::Inside(child->bounds, rect);

				if (completely_inside && child->level > 0) {
					auto cbn = static_cast<BranchNode*>(child);

					auto kef = QueryNode(cbn->best_pts, cbn->num_best_points, cbn->min_rank);

					//iit = std::lower_bound(iit, q.end(), kef);
					//iit = q.insert(iit, kef);
					//q.push_back(kef);
					q.emplace_back(cbn->best_pts, cbn->num_best_points, cbn->min_rank);
					//Heap.push_heap(q.begin(), q.end());
					//std::push_heap(q.begin(), q.end());
					continue;
				}

				if (!completely_inside && !Rect::Intersects(child->bounds, rect))
					continue;

				if (child->level == 0)
				{
					auto leaf = static_cast<LeafNode*>(child);
					//auto kef = QueryNode(leaf->pts, leaf->count, leaf->min_rank);
					//auto iit = std::lower_bound(q.begin() + it, q.end(), kef);
					//iit = std::lower_bound(iit, q.end(), kef);
					//iit = q.insert(iit, kef);
					//q.push_back(kef);
					q.emplace_back(leaf->pts, leaf->count, leaf->min_rank);
				}
				else {
					//auto kef = QueryNode(child, child->min_rank);
					//auto iit = std::lower_bound(q.begin() + it, q.end(), kef);
					//iit = std::lower_bound(iit, q.end(), kef);
					//iit = q.insert(iit, kef);
					//q.push_back(kef);
					q.emplace_back(child, child->min_rank);
				}

				//Heap.push_heap(q.begin(), q.end());
				//std::push_heap(q.begin(), q.end());
			}

			printf("added %d nodes\n", std::distance(q.begin() + it, q.end()) - old);

			//std::sort(q.begin() + it, q.end());
			//Heap.make_heap(q.begin(), q.end());
			//std::make_heap(q.begin(), q.end());
			//printf("Brancherino\n");
		}
		else {
			int32_t worst_rank = std::numeric_limits<int32_t>::max();

			//Heap.restore_heap_after_item_increase(

			if (q.size() > 0)
				worst_rank = q[it].rank;

			//printf("Min ranks doe %d going until %d\n", qn.rank, worst_rank);

			for (int i = 0; i < qn.count; i++) {
				auto& p = qn.pts[i];

				if ((p.x < rect.lx || p.x > rect.hx || p.y < rect.ly || p.y > rect.hy)) {
					//printf("not in bounds :(\n");
					continue;
				}

				if (p.rank > worst_rank) {
					auto kef = QueryNode(qn.pts + i, qn.count - i, p.rank);
					auto iit = std::lower_bound(q.begin() + it, q.end(), kef);

					//if (iit == q.begin() + it)
					//	printf("WOWOWOWO ");

					q.insert(iit, kef);

					//Heap.push_heap(q.begin(), q.end());
					//std::push_heap(q.begin(), q.end());
					break;
				}

				//printf("Add pt %d\n", p.rank);
				r.push_back(p);

				if (r.size() == count) {
					//printf("Left %d nodes\n", q.size());
					return;
				}
			}
		}
	}

	//printf("\n");
}