本文整理汇总了C++中FindPath函数的典型用法代码示例。如果您正苦于以下问题:C++ FindPath函数的具体用法?C++ FindPath怎么用?C++ FindPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FindPath函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: OpenFile
CString XMLSerialized::LoadInfo(const CString& sName,TagType tagType,const CString parent=L""){
CMarkup xml = OpenFile();
if(tagType== TagType::Element){
if(FindPath(sName,&xml))
return xml.GetData();
}
if(tagType== TagType::Attribute){
if(FindPath(parent,&xml))
return xml.GetAttrib(sName);
}
return L"";
}
开发者ID:zidane168,项目名称:AutoPlay,代码行数:13,代码来源:Serialize.cpp
示例2: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
unsigned char pMap[] = { 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1 };
int pOutBuffer[12];
const int result1 = FindPath(0, 0, 1, 2, pMap, 4, 3, pOutBuffer, 12);
Output(pOutBuffer, result1);
unsigned char pMap2[] = { 0, 0, 1, 0, 1, 1, 1, 0, 1 };
int pOutBuffer2[7];
const int result2 = FindPath(2, 0, 0, 2, pMap2, 3, 3, pOutBuffer2, 7);
Output(pOutBuffer, result2);
system("PAUSE");
return 0;
}
开发者ID:zimzimdz,项目名称:AStar_FlatMap,代码行数:15,代码来源:PathFinding.cpp
示例3: startPos
bool NavGrid::FindPath(const CU::Vector3f& aStartPoint, const CU::Vector3f& aEndPoint, CU::GrowingArray<CU::Vector2f>& aOutPath)
{
CU::Vector2i startPos(static_cast<int>(aStartPoint.x), static_cast<int>(aStartPoint.z));
CU::Vector2i endPos(static_cast<int>(aEndPoint.x), static_cast<int>(aEndPoint.z));
return FindPath(startPos, endPos, aOutPath);
}
开发者ID:nian0601,项目名称:MagmaEngine,代码行数:7,代码来源:NavGrid.cpp
示例4: TestSparsePerformance
void TestSparsePerformance(bool outputMap)
{
int cellSize = 16;
int w = 40;
int h = 100;
double map = CreateSparseMap(w*cellSize,h*cellSize,cellSize);
//map = CreateMap(w*cellSize,h*cellSize,cellSize);
SetCellMap(map, 4*cellSize, 4*cellSize, 1);
SetCellMap(map, 5*cellSize, 4*cellSize, 1);
SetCellMap(map, 5*cellSize, 5*cellSize, 1);
SetCellMap(map, 5*cellSize, 6*cellSize, 1);
SetCellMap(map, 5*cellSize, 7*cellSize, 1);
SetCellMap(map, 4*cellSize, 7*cellSize, 1);
SetCellMapRegion(map, (w/2)*cellSize, 0*cellSize, 2*cellSize, (h*0.75)*cellSize, 1);
//SetCellMapRegion(map, (w/2)*cellSize, (h/2+1)*cellSize, 2*cellSize, (h/2-2)*cellSize, 1);
#ifndef _DEBUG
double pathFinder = CreatePathFinder(map);
#else
double mapDebug = CreateMap(w*cellSize,h*cellSize,cellSize);
double pathFinder = CreatePathFinderDebug(map, mapDebug);
#endif
double path = FindPath(pathFinder, 2.0*cellSize, 8.0*cellSize, (w-2)*cellSize, 2.0*cellSize);
if (outputMap)
{
OutputPath(map, path);
}
DestroyMap(map);
DestroyPathFinder(pathFinder);
DestroyPath(path);
#ifdef _DEBUG
DestroyMap(mapDebug);
#endif
}
开发者ID:suilevap,项目名称:motion-plan,代码行数:35,代码来源:InterfaceForTest.cpp
示例5: ComputeDir
void CRole::SetDst(Pos pos)
{
m_bBeginFindPath = false;
m_fdst = m_dst = pos;
ComputeDir();
int x = (int)(m_fdst.x/m_pMap->m_tileWidth);
int y = (int)(m_fdst.y/m_pMap->m_tileHeight);
if(!m_pMap->Passable(x, y))//如果目标不可到达
{
int bestx;int besty;
m_bestPosFinder->FindBestPos(x, y, &bestx, &besty, m_pMap->m_map);//寻找最近可走点
m_fdst.x = (float)bestx*m_pMap->m_tileWidth;
m_fdst.y = (float)besty*m_pMap->m_tileHeight;
//printf("%d %d\n", bestx, besty);
}
ClearPath();
//int t=timeGetTime(); //计算寻路时间
FindPath(&m_pos, &m_fdst);
//printf("寻路消耗时间: %d\n",timeGetTime()-t); //
if(GetNextPos(&m_dst,
(float)m_pMap->m_tileWidth/2, (float)m_pMap->m_tileHeight/2))
ComputeDir();
else
SetStop();
}
开发者ID:fg5823820,项目名称:HGEGameDemo2,代码行数:27,代码来源:Role.cpp
示例6: FindPath
void Operator::CalcPEC_Curves()
{
//special treatment for primitives of type curve (treated as wires)
double p1[3];
double p2[3];
struct Grid_Path path;
vector<CSProperties*> vec_prop = CSX->GetPropertyByType(CSProperties::METAL);
for (size_t p=0; p<vec_prop.size(); ++p)
{
CSProperties* prop = vec_prop.at(p);
for (size_t n=0; n<prop->GetQtyPrimitives(); ++n)
{
CSPrimitives* prim = prop->GetPrimitive(n);
CSPrimCurve* curv = prim->ToCurve();
if (curv)
{
for (size_t i=1; i<curv->GetNumberOfPoints(); ++i)
{
curv->GetPoint(i-1,p1);
curv->GetPoint(i,p2);
path = FindPath(p1,p2);
if (path.dir.size()>0)
prim->SetPrimitiveUsed(true);
for (size_t t=0; t<path.dir.size(); ++t)
{
SetVV(path.dir.at(t),path.posPath[0].at(t),path.posPath[1].at(t),path.posPath[2].at(t), 0 );
SetVI(path.dir.at(t),path.posPath[0].at(t),path.posPath[1].at(t),path.posPath[2].at(t), 0 );
++m_Nr_PEC[path.dir.at(t)];
}
}
}
}
}
}
开发者ID:ho-y,项目名称:openEMS,代码行数:34,代码来源:operator.cpp
示例7: start
//移动地图到目的坐标,同可移动对象的移动类似
void CGameMap::MoveTo(Point goal)
{
m_Paths.clear();
std::vector<Point>* Paths = &m_Paths;
Point start((int)m_CurrentXY.x, (int)m_CurrentXY.y);
FindPath(start, goal, Paths, m_pMapAstar);
//寻路失败,寻不到路或者寻路地址即为源地址
if(m_Paths.empty())
{
m_bArrived = true;
}
//寻路成功
else
{
//平滑路径
CActiveObject::SmoothPath(m_Paths, 50);
//当前Paths最后一个元素为当前位置
m_Paths.pop_back();
__Move1Step();
m_bArrived = false;
}
}
开发者ID:xiaohuajiao,项目名称:Demo,代码行数:29,代码来源:CGameMap.cpp
示例8: KillLoop
virtual void KillLoop(VertexId start, VertexId finish, const set<VertexId> &component) {
vector<EdgeId> path = FindPath(start, finish, component);
set<EdgeId> edges(path.begin(), path.end());
if(path.size() > 0 || start == finish) {
// if(start != finish || component.size() > 2)
if(/*!CheckStrong(component) || */!CheckNotMuchRemoved(edges, component)) {
return;
}
/*
cout << this->g().int_id(start) << " " << this->g().int_id(finish) << endl;
cout << this->g().VertexNucls(start) << endl;
for(auto it = component.begin(); it != component.end(); ++it) {
vector<EdgeId> outgoing = this->g().OutgoingEdges(*it);
for(auto eit = outgoing.begin(); eit != outgoing.end(); ++eit) {
if(component.count(this->g().EdgeEnd(*eit)) == 1) {
cout << this->g().int_id(*it) << " -> " << this->g().int_id(this->g().EdgeEnd(*eit)) << " : " << this->g().length(*eit) << " : " << edges.count(*eit) << " : " << this->g().int_id(*eit) << endl;
}
}
}
*/
RemoveExtraEdges(edges, component);
RemoveIsolatedVertices(component);
}
}
开发者ID:fw1121,项目名称:Pandoras-Toolbox-for-Bioinformatics,代码行数:25,代码来源:loop_killer.hpp
示例9: FindPath
void
ProfileListWidget::SelectPath(const TCHAR *path)
{
auto i = FindPath(path);
if (i >= 0)
GetList().SetCursorIndex(i);
}
开发者ID:M-Scholli,项目名称:XCSoar,代码行数:7,代码来源:ProfileListDialog.cpp
示例10: main
void main(void)
{
welcome();
InputMaze();
if (FindPath()) OutputPath();
else cout << "No path" << endl;
}
开发者ID:hzsunzixiang,项目名称:programming,代码行数:7,代码来源:maze.cpp
示例11: FindPath
void BinTree::FindPath(int expectedSum) {
if (pHead == NULL)
return ;
std::vector<int> path;
int currentSum = 0;
FindPath (pHead,expectedSum,path,currentSum);
}
开发者ID:archibaly,项目名称:ToyCollection,代码行数:7,代码来源:BinTree.cpp
示例12: path_check2
void path_check2(){
printf("Testing FindPath(...) on World2\n");
int i, j;
Grid *g;
g = ReadWorld("world2.txt");
Search *s;
s = FindPath(g);
assert_i(s->Length, -1, "Shortest path length - World2");
assert_i(stack_size(s->s), s->Length+1, "Stack size - World2");
int actual[14][17] = {{5000, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT},
{5000, 10, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, MAX_INT, MAX_INT, MAX_INT},
{5000, 9, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, MAX_INT, MAX_INT, MAX_INT},
{5000, 8, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, MAX_INT},
{5000, 7, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, MAX_INT},
{5000, 6, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, MAX_INT},
{5000, 5, 4, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, 16, 17, MAX_INT},
{5000, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, MAX_INT, 17, 18, MAX_INT},
{5000, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, MAX_INT, 18, 19, MAX_INT},
{5000, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, MAX_INT, 19, 20, MAX_INT},
{5000, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT, MAX_INT}};
int correct_dist = 1;
// Compare Calculated Distances to Model Solution.
for(i = 0; i < g->rows; i++){
for(j = 0; j < g->cols; j++){
if(actual[i][j] != s->Distance[i][j]){
correct_dist = 0;
}
}
}
assert_i(correct_dist, 1, "Distance Array - World2");
}
开发者ID:TRex22,项目名称:DDS_Group_Work,代码行数:35,代码来源:main.c
示例13: updateMap
void updateMap() {
for(int i = 0; i < mapWidth; ++i) {
for(int j = 0; j < mapHeight; ++j) {
QGraphicsRectItem* rect = rects[RectsKey(j, i)];
if(pMap[i*mapWidth+j] == 0)
rect->setBrush(QBrush(Qt::blue));
if(pMap[i*mapWidth+j] == 1)
rect->setBrush(QBrush(Qt::red));
}
}
int pOutBuffer[128];
int nNumSteps = FindPath(startX, startY, endX, endY, pMap, mapWidth, mapHeight, pOutBuffer, 128);
for(int i = 0; i < nNumSteps; i++) {
int y = pOutBuffer[i]/mapWidth;
int x = pOutBuffer[i] - y*mapWidth;
QGraphicsRectItem* rect = rects[RectsKey(x, y)];
rect->setBrush(QBrush(Qt::green));
}
if(startX != -1 && startY != -1)
{
QGraphicsRectItem* rect = rects[RectsKey(startX, startY)];
rect->setBrush(QBrush(Qt::green));
}
if(endX != -1 && endY != -1)
{
QGraphicsRectItem* rect = rects[RectsKey(endX, endY)];
rect->setBrush(QBrush(Qt::gray));
}
}
开发者ID:tobiasor,项目名称:PathFinder,代码行数:35,代码来源:mygraphicsscene.cpp
示例14: rand
void Enemy::GenerateRandomPath()
{
pathStatus = PathFinder::NONEXISTENT;
for( int i = 0 ; i < numberOfRandomPathPoints ; i++ )
{
do{
target.x = rand()%( 2 * MovementVector.x ) + ( startPosition.x - MovementVector.x );
target.y = rand()%( 2 * MovementVector.y ) + ( startPosition.y - MovementVector.y );
// std::cout<<target.x<<" "<<target.y<<"\n";
pathSearched = false;
if( (target.x/32 != myPosition.x/32) &&
(target.y/32 != myPosition.y/32) )
{
if( FindPath( target ) == PathFinder::FOUND )
{
pathStatus = PathFinder::NONEXISTENT;
randomPatrolPath[i] = pathfinderPath;
break;
}
}
}while( pathStatus != PathFinder::FOUND );
}
}
开发者ID:KNTGPolygon,项目名称:3Man,代码行数:25,代码来源:Enemy.cpp
示例15: bm_Periodical_1s
void bm_Periodical_1s()
{
for (u32 i=0;i<del_blocks.size();i++)
delete del_blocks[i];
del_blocks.clear();
if (rebuild_counter>0) rebuild_counter--;
#if HOST_OS==OS_WINDOWS && 0
std::sort(all_blocks.begin(),all_blocks.end(),UDgreaterX);
map<u32,u32> vmap;
map<u32,u32> calls;
u32 total_runs=0;
for(int i=0;i<all_blocks.size();i++)
{
RuntimeBlockInfo* rbi=all_blocks[i];
total_runs+=rbi->runs;
if (rbi->BranchBlock!=-1 && rbi->BranchBlock < rbi->addr)
{
if (rbi->BlockType==BET_Cond_0 || rbi->BlockType==BET_Cond_1 || rbi->BlockType==BET_StaticJump)
{
RuntimeBlockInfo* bbi=bm_GetBlock(all_blocks[i]->BranchBlock);
if (bbi && bbi->runs)
{
vmap[all_blocks[i]->BranchBlock]=bbi->runs;
}
}
if (rbi->BlockType==BET_StaticCall)
{
RuntimeBlockInfo* bbi=bm_GetBlock(all_blocks[i]->BranchBlock);
if (bbi && bbi->runs)
{
calls[all_blocks[i]->BranchBlock]+=rbi->runs;
}
}
}
verify(rbi->NextBlock>rbi->addr);
}
map<u32,u32>::iterator iter=vmap.begin();
total_saved=0;
u32 total_l_runs=0;
while(iter!=vmap.end())
{
FindPath(iter->first);
total_l_runs+=iter->second;
iter++;
}
for(int i=0;i<all_blocks.size();i++)
all_blocks[i]->runs=0;
printf("Total Saved: %.2f || Total Loop Runs: %.2f || Total Runs: %.2f\n",total_saved/1000.f,total_l_runs/1000.f,total_runs/1000.f);
#endif
}
开发者ID:zear,项目名称:emulator,代码行数:59,代码来源:blockmanager.cpp
示例16: FindClosestNode
PathPlan* PathingGraph::FindPath(const Vec3& startPoint, const Vec3& endPoint)
{
// Find the closest nodes to the start and end points. There really should be some ray-casting
// to ensure that we can actually make it to the closest node, but this is good enough for now.
PathingNode* pStart = FindClosestNode(startPoint);
PathingNode* pGoal = FindClosestNode(endPoint);
return FindPath(pStart,pGoal);
}
开发者ID:wsantas,项目名称:gamecode4,代码行数:8,代码来源:Pathing.cpp
示例17: main
void main(void)
{
Position s,f, *p;
int l;
InputGrid(s,f);
if (FindPath(s,f,l,p)) OutputPath(l,p);
else cout << "No path" << endl;
}
开发者ID:hzsunzixiang,项目名称:programming,代码行数:8,代码来源:wire.cpp
示例18: OnButtonExecuteClick
void MapOverview::OnButtonExecuteClick(wxCommandEvent& event)
{
signed int res=FindPath(GetWorldHandler(),OURROBOT,100); //TimeMS->GetValue()*10
//floor_plan->FindPathTo(endx,endy,);
if ( res <1 ) { fprintf(stderr,"Could not establish a route.\n"); /*TTS((char *)"Could not establish a route.");*/ } else
{ fprintf(stderr,"New route established."); }
Refresh();
}
开发者ID:AmmarkoV,项目名称:RoboVision,代码行数:8,代码来源:MapOverview.cpp
示例19: GeneratePath
void Player::GeneratePath()
{
path.clear();
next = NULL;
x = nodeMap->GetStart()->x;
y = nodeMap->GetStart()->y;
path = *FindPath();
}
开发者ID:JeffreyMJohnson,项目名称:graphs_trees_exercise,代码行数:8,代码来源:Player.cpp
示例20: FindPath
void FindPath(BinaryTreeNode* pRoot, int expectedSum)
{
if(pRoot == NULL)
return;
std::vector<int> path;
int currentSum = 0;
FindPath(pRoot, expectedSum, path, currentSum);
}
开发者ID:song-syj,项目名称:pro,代码行数:8,代码来源:25.cpp
注:本文中的FindPath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论