Esempio n. 1
0
	void GridMap::getSuccessorNodes(Navigator& navigator, int nodeID, std::vector<SuccessorNodeInfo>& result) const
	{
		NodeCoord coord = toNodeCoord(nodeID);

		const bool bLeft = tryAddSuccessorNode(navigator, result, NodeCoord(coord.x-1,coord.y), COST_STRAIGHT, nodeID);		
		const bool bTop = tryAddSuccessorNode(navigator, result, NodeCoord(coord.x,coord.y-1), COST_STRAIGHT, nodeID);
		const bool bRight = tryAddSuccessorNode(navigator, result, NodeCoord(coord.x+1,coord.y), COST_STRAIGHT, nodeID);
		const bool bBottom = tryAddSuccessorNode(navigator, result, NodeCoord(coord.x,coord.y+1), COST_STRAIGHT, nodeID);

		if (bLeft && bTop)
		{
			tryAddSuccessorNode(navigator, result, NodeCoord(coord.x-1,coord.y-1), COST_DIAGONAL, nodeID);
		}
		if (bTop && bRight)
		{
			tryAddSuccessorNode(navigator, result, NodeCoord(coord.x+1,coord.y-1), COST_DIAGONAL, nodeID);
		}
		if (bRight && bBottom)
		{
			tryAddSuccessorNode(navigator, result, NodeCoord(coord.x+1,coord.y+1), COST_DIAGONAL, nodeID);
		}
		if (bBottom && bLeft)
		{
			tryAddSuccessorNode(navigator, result, NodeCoord(coord.x-1,coord.y+1), COST_DIAGONAL, nodeID);
		}		
	}
Esempio n. 2
0
DBCoordinate *DBVPolyIF::Vertexes (const DBObjRecord *polyRec) const

	{
	DBInt vertex, i, line;
	DBObjRecord *lineRec, *nodeRec,*firstNodeRec;
	DBCoordinate *lcoords;
	
	vertex = 0;
	lineRec = FirstLine (polyRec);
	firstNodeRec = nodeRec = LineRightPoly (lineRec) == polyRec ? FromNode (lineRec) : ToNode (lineRec);
	for (line = 0;line < LineNum (polyRec);++line)
		{
		if (LineRightPoly (lineRec) == polyRec)
			{
			if (nodeRec != FromNode (lineRec))
				{
				CoordsPTR [vertex++] = NodeCoord (nodeRec);
				if (nodeRec != firstNodeRec) CoordsPTR [vertex++] = NodeCoord (firstNodeRec);
				nodeRec = FromNode (lineRec);
				}
			CoordsPTR [vertex++] = NodeCoord (nodeRec);
			if (DBVLineIF::VertexNum(lineRec) > 0)
				{
				lcoords = DBVLineIF::Vertexes (lineRec);
				for (i = 0;i < DBVLineIF::VertexNum (lineRec);++i) CoordsPTR [vertex++] = lcoords [i];
				}
			nodeRec = ToNode (lineRec);
			lineRec = LineNextLine (lineRec);
			}
		else
			{
			if (nodeRec != ToNode (lineRec))
				{
				CoordsPTR [vertex++] = NodeCoord (nodeRec);
				if (nodeRec != firstNodeRec) CoordsPTR [vertex++] = NodeCoord (firstNodeRec);
				nodeRec = ToNode (lineRec);
				}
			CoordsPTR [vertex++] = NodeCoord (nodeRec);
			if (DBVLineIF::VertexNum (lineRec) > 0)
				{
				lcoords = (DBCoordinate *) (DBVLineIF::Vertexes (lineRec));
				for (i = DBVLineIF::VertexNum (lineRec);i > 0;--i) CoordsPTR [vertex++] = lcoords [i - 1];
				}
			nodeRec = FromNode (lineRec);
			lineRec = LinePrevLine (lineRec);
			}
		}
	CoordsPTR [vertex++] = NodeCoord (nodeRec);
	if (nodeRec != firstNodeRec) CoordsPTR [vertex++] = NodeCoord (firstNodeRec); 
	if (VertexNum (polyRec) != vertex)
		CMmsgPrint (CMmsgAppError, "Warning in Polygon %d VertexNum [%d %d] in: %s %d",polyRec->RowID (), VertexNum (polyRec),vertex,__FILE__,__LINE__);
	return (CoordsPTR);
	}
Esempio n. 3
0
	void GridMap::annotateMap()
	{
		for (int x = m_nodes.size_x()-1; x >= 0; --x)
		{
			for (int y = m_nodes.size_y()-1; y>=0; --y)
			{
				annotateNode(NodeCoord(x, y));
			}
		}
	}
Esempio n. 4
0
	GridEnv::NodeCoord GridEnv::toNodeCoord(int nodeID) const
	{
		FDK_ASSERT(isValidNodeID(nodeID));
		return NodeCoord(nodeID % getSizeX(), nodeID / getSizeX());
	}