示例#1
0
bool DisjointRectCollection::Add(const Rect &r)
{
	// Degenerate rectangles are ignored.
	if (r.width == 0 || r.height == 0)
		return true;

	if (!Disjoint(r))
		return false;
	rects.push_back(r);
	return true;
}
示例#2
0
bool DisjointRectCollection::Disjoint(const Rect &r) const
{
	// Degenerate rectangles are ignored.
	if (r.width == 0 || r.height == 0)
		return true;

	for(size_t i = 0; i < rects.size(); ++i)
		if (!Disjoint(rects[i], r))
			return false;
	return true;
}
示例#3
0
//----------------------------------------------------------------------------
// Intersection of an interval 'X' and an extended interval 'Y'. The result
// is given as a pair (vector) of intervals, where one or both of them can
// be empty intervals.
//----------------------------------------------------------------------------
ivector operator& ( const interval& X, const xinterval& Y )
{
  interval H;
  ivector  IS(2);

  IS[1] = EmptyIntval();
  IS[2] = EmptyIntval();

  switch (Y.kind) {
    case Finite     : // [X.inf,X.sup] & [Y.inf,Y.sup]
                      //------------------------------
                      H = _interval(Y.inf,Y.sup);
                      if ( !Disjoint(X,H) ) IS[1] = X & H;
                      break;
    case PlusInfty  : // [X.inf,X.sup] & [Y.inf,+oo]
                      //----------------------------
                      if (Sup(X) >= Y.inf) {
                        if (Inf(X) > Y.inf)
                          IS[1] = X;
                        else
                          IS[1] = _interval(Y.inf,Sup(X));
                      }
                      break;
    case MinusInfty : // [X.inf,X.sup] & [-oo,Y.sup]
                      //----------------------------
                      if (Y.sup >= Inf(X)) {
                        if (Sup(X)<Y.sup)
                          IS[1] = X;
                        else
                          IS[1] = _interval(Inf(X),Y.sup);
                      }
                      break;
    case Double     : if ( (Inf(X) <= Y.sup) && (Y.inf <= Sup(X)) ) {
                        IS[1] = _interval(Inf(X),Y.sup);    // X & [-oo,Y.sup]
                        IS[2] = _interval(Y.inf,Sup(X));    // X & [Y.inf,+oo]
                      }
                      else if (Y.inf <= Sup(X)) // [X.inf,X.sup] & [Y.inf,+oo]
                        if (Inf(X) >= Y.inf)    //----------------------------
                          IS[1] = X;
                        else
                          IS[1] = _interval(Y.inf,Sup(X));
                      else if (Inf(X) <= Y.sup){// [X.inf,X.sup] & [-oo,Y.sup]
                        if (Sup(X) <= Y.sup)    //----------------------------
                          IS[1] = X;
                        else
                          IS[1] = _interval(Inf(X),Y.sup);
                      }
                      break;
    case Empty      : break;                           // [X.inf,X.sup] ** [/]
  } // switch                                          //---------------------

  return IS;
} // operator&
示例#4
0
文件: dag.hpp 项目: baharev/asol
bool Minus<T>::propagate() {

    T& x = *arg1;
    T& y = *arg2;
    const T& z = *(this->val);

    // Inverse operator
    const T x_new( z+y );
    if ( Disjoint(x, x_new) )
        return true;
    else {
        x = Intersect(x, x_new);
    }

    const T y_new( x-z );
    if ( Disjoint(y, y_new) )
        return true;
    else {
        y = Intersect(y, y_new);
    }

    return false;
}
示例#5
0
文件: dag.hpp 项目: baharev/asol
bool Neg<T>::propagate() {

    T& x = *arg;
    const T& y = *(this->val);

    // Inverse operator
    const T x_new( -y );
    if ( Disjoint(x, x_new) )
        return true;
    else {
        x = Intersect(x, x_new);
        return false;
    }
}
示例#6
0
文件: dag.hpp 项目: baharev/asol
bool Div<T>::propagate() {

    T& x = *arg1;
    T& y = *arg2;
    const T& z = *(this->val);

    // Inverse operator
    const T x_new( z*y );
    if ( Disjoint(x, x_new) )
        return true;
    else {
        x = Intersect(x, x_new);
    }

    return ext_div(y, x, z);
}
示例#7
0
int Disjoint ( ivector& a, ivector& b )             // Test for disjointedness
{   //------------------------
    int al = Lb(a), au = Ub(a), bl = Lb(b);
    int disjointed, i, d;

    d = bl - al;

    i = al;
    disjointed = 0;
    do {
        if (Disjoint(a[i],b[i+d]))
            disjointed = 1;
        else
            i++;
    } while ( !(disjointed || i > au) );
    return disjointed;
}
示例#8
0
文件: dag.hpp 项目: baharev/asol
bool PowInt<T>::propagate() {

    T& x = *arg1;
    const T& y = *(this->val);

    // Inverse operator
    T x_new( sqrt(y) );

    if      (Inf(x) >= 0.0)
        ;
    else if (Sup(x) <= 0.0)
        x_new = T(-Sup(x_new), -Inf(x_new));
    else
        x_new = T(-Sup(x_new), Sup(x_new));

    if ( Disjoint(x, x_new) )
        return true;
    else {
        x = Intersect(x, x_new);
    }

    return false;
}