int HamiltonianPathFunction::BackBiteLeft(glm::ivec2 step, int n)
{
	//choose left hand end
	int _n = n;
	glm::ivec2 neighbour = glm::ivec2(_path[0].x + step.x, _path[0].x + step.y);

	//check to see if neighbour is in sublattice
	if (InSublattice(neighbour))
	{
		//Now check to see if it's already in _path
		bool inPath = false;
		int j = 0;
		for (j = 1; j < _n; j++)
		{
			if (neighbour == _path[j])
			{
				inPath = true;
				break;
			}
		}
		if (inPath)
		{
			ReversePath(0, j - 1);
		}
		else
		{
			ReversePath(0, _n - 1);
			_n++;
			_path[_n - 1] = neighbour;
		}
	}

	return _n;
}
Пример #2
0
	ClipperLib::Paths polyToClipperPaths(const panda::types::Polygon& poly)
	{
		ClipperLib::Paths paths;
		auto contour = pathToClipperPath(poly.contour);
		if (!Orientation(contour)) // We want the orientation to be CW
			ReversePath(contour);
		paths.push_back(contour);

		for (const auto& hole : poly.holes)
		{
			auto path = pathToClipperPath(hole);
			if (path.size() < 3)
				continue;

			// The orientation of holes must be opposite that of outer polygons.
			if (Orientation(path))
				ReversePath(path);
			paths.push_back(path);
		}

		return paths;
	}
ClipperLib::Path SHAPE_LINE_CHAIN::convertToClipper( bool aRequiredOrientation ) const
{
    ClipperLib::Path c_path;

    for( int i = 0; i < PointCount(); i++ )
    {
        const VECTOR2I& vertex = CPoint( i );
        c_path.push_back( ClipperLib::IntPoint( vertex.x, vertex.y ) );
    }

    if( Orientation( c_path ) != aRequiredOrientation )
        ReversePath( c_path );

    return c_path;
}
Пример #4
0
void BacktrackPath(WorkVertex *source, WorkVertex *goal, Path *path) {
    int counter = 0;
    Path tempPath;
    tempPath.pathVerticeIds = malloc(1024 * sizeof(unsigned int));
    WorkVertex *workPtr = goal;
    do {
        tempPath.pathVerticeIds[counter] = workPtr->vertex->vertexId;
        counter++;
        workPtr = workPtr->previous;
    } while (workPtr->vertex->vertexId != source->vertex->vertexId);
    path->targetId = source->vertex->vertexId;
    path->pathVerticeIds = realloc(path->pathVerticeIds, counter * sizeof(unsigned int));
    tempPath.numVertices = counter;
    tempPath.weight = goal->dist;
    ReversePath(&tempPath, path);
    free(tempPath.pathVerticeIds);
}
Пример #5
0
 virtual void GetPath(int ma,int mb,MilestonePath& path) { sbl->CreatePath(path); if(ma == 1) ReversePath(path); }