bool fme_is_feasible(const Conjunction &space) 
    {
        int n = space.size();   // number of inequalities

        std::vector<Plane> planes = get_normalized_planes(space);
        assert(planes.size() == n);
        int m = planes[0].size();

        //std::cout << "Size is " << n << " x " << m << std::endl;

        for (unsigned k=0; k<m; ++k) {
            // eliminate the k-th variable;
            std::vector<Plane> neg, pos, nix;
            split_planes(planes, k, neg, pos, nix);

            planes.clear();
            for (auto &x : nix) 
                planes.push_back(x);
            
            for (auto &x : neg) {
                for (auto &y : pos) {
                    double xc = x.a[k];
                    double yc = y.a[k];
                    coeff_row_t newrow(m);
                    for (unsigned h=0; h<m; ++h) 
                        newrow[h] = x.a[h] - y.a[h] * xc/yc;
                    int s = Plane::lt; 
                    if (x.sign == Plane::lte && y.sign == Plane::lte) 
                        s = Plane::lte;
                    double b = x.b - y.b *xc/yc;
                    Plane newplane(newrow, s, b);
                    planes.push_back(newplane);
                }
            }
        }
        // all variables have been eliminated, now there remain only
        // tautologies (0 <= b) or contradictions
 
        // look for contradictions
        for (auto &x : planes) {
            if (x.sign == Plane::lte && x.b < 0) return false;
            else if (x.sign == Plane::lt && x.b <=0) return false;
        }
        return true;
    }
Esempio n. 2
0
CRowAtlasAlloc::Row* CRowAtlasAlloc::AddRow(int glyphWidth, int glyphHeight)
{
	const int wantedRowHeight = glyphHeight;
	while (atlasSize.y < (nextRowPos + wantedRowHeight)) {
		if (atlasSize.x>=maxsize.x && atlasSize.y>=maxsize.y) {
			//throw texture_size_exception();
			return nullptr;
		}

		// Resize texture
		atlasSize.x = std::min(maxsize.x, atlasSize.x << 1);
		atlasSize.y = std::min(maxsize.y, atlasSize.y << 1);
	}

	Row newrow(nextRowPos, wantedRowHeight);
	nextRowPos += wantedRowHeight;
	imageRows.push_back(newrow);
	return &imageRows.back();
}