예제 #1
0
파일: vpsc.cpp 프로젝트: P-N-L/adaptagrams
/*
 * Symmetrical to mergeLeft
 */
void Blocks::mergeRight(Block *l) {    
#ifdef LIBVPSC_LOGGING
    ofstream f(LOGFILE,ios::app);
    f<<"mergeRight called on "<<*l<<endl;
#endif    
    l->setUpOutConstraints();
    Constraint *c = l->findMinOutConstraint();
    while (c != NULL && c->slack()<0) {        
#ifdef LIBVPSC_LOGGING
        f<<"mergeRight on constraint: "<<*c<<endl;
#endif
        l->deleteMinOutConstraint();
        Block *r = c->right->block;
        r->setUpOutConstraints();
        double dist = c->left->offset + c->gap - c->right->offset;
        if (l->vars->size() > r->vars->size()) {
            dist=-dist;
            std::swap(l, r);
        }
        l->merge(r, c, dist);
        l->mergeOut(r);
        removeBlock(r);
        c=l->findMinOutConstraint();
    }    
#ifdef LIBVPSC_LOGGING
    f<<"merged "<<*l<<endl;
#endif
}
예제 #2
0
void RGFlow<Two_scale>::run_up()
{
   VERBOSE_MSG("> running tower up (iteration " << iteration << ") ...");
   const size_t number_of_models = models.size();
   for (size_t m = 0; m < number_of_models; ++m) {
      TModel* model = models[m];
      model->model->set_precision(get_precision());
      VERBOSE_MSG("> \tselecting model " << model->model->name());
      // apply all constraints
      const size_t n_upwards_constraints = model->upwards_constraints.size();
      for (size_t c = 0; c < n_upwards_constraints; ++c) {
         Constraint<Two_scale>* constraint = model->upwards_constraints[c];
         const double scale = constraint->get_scale();
         VERBOSE_MSG("> \t\tselecting constraint " << c << " at scale " << scale);
         VERBOSE_MSG("> \t\t\trunning model to scale " << scale);
         if (model->model->run_to(scale))
            throw NonPerturbativeRunningError(scale);
         VERBOSE_MSG("> \t\t\tapplying constraint");
         constraint->apply();
      }
      // apply matching condition if this is not the last model
      if (m != number_of_models - 1) {
         VERBOSE_MSG("> \tmatching to model " << models[m + 1]->model->name());
         Matching<Two_scale>* mc = model->matching_condition;
         mc->match_low_to_high_scale_model();
      }
   }
   VERBOSE_MSG("> running up finished");
}
예제 #3
0
void ClusterPlanarity::outputCons(ofstream &os,
	StandardPool<Constraint, Variable> *connCon,
	StandardPool<Variable, Constraint> *stdVar)
{
	int i;
	for ( i = 0; i < connCon->number(); i++)
		{
			PoolSlot< Constraint, Variable > * sloty = connCon->slot(i);
			Constraint *mycon = sloty->conVar();
			OGDF_ASSERT(mycon != 0);
			int count;
			for (count = 0; count < stdVar->size(); count++)
			{
				PoolSlot< Variable, Constraint > * slotv = stdVar->slot(count);
				Variable *myvar = slotv->conVar();
				double d = mycon->coeff(myvar);
				if (d != 0.0) //precision!
				{
					os <<"+"<< d <<"x"<<count+1;
				}
			}//for
			switch (mycon->sense()->sense())
			{
				case CSense::Less: os << " <= "; break;
				case CSense::Greater: os << " >= "; break;
				case CSense::Equal: os << " = "; break;
				default: os << "Inequality sense doesn't make any sense \n";
						 cerr << "Inequality sense unknown \n";
						break;
			}//switch
			os << mycon->rhs();
			os << "\n";
		}
}
예제 #4
0
void VACExtension::enforcePass1()
{
    //  VACVariable* xi;
    VACVariable *xj;
    VACBinaryConstraint *cij;
    //if (ToulBar2::verbose > 1) cout << "VAC Enforce Pass 1" << endl;

    while (!VAC.empty()) {
        xj = (VACVariable *) VAC.pop_first();
        //list<Constraint*> l;
        for (ConstraintList::iterator itc = xj->getConstrs()->begin();
                itc != xj->getConstrs()->end(); ++itc) {
            Constraint *c = (*itc).constr;
            if (c->arity() == 2 && !c->isSep()) {
                cij = (VACBinaryConstraint *) c;
                //        xi = (VACVariable *)cij->getVarDiffFrom(xj);
                //if(xj->getMaxK(nbIterations) > 2) l.push_back(cij); else
                if (enforcePass1(xj, cij))
                    return;
            }
        }

        /*for (list<Constraint*>::iterator itl = l.begin(); itl != l.end(); ++itl) {
		   cij = (VACConstraint *) *itl;
		   if(enforcePass1(xj,cij)) return;
		   } */
    }
    inconsistentVariable = -1;
}
예제 #5
0
void PropertyConstraintList::Restore(Base::XMLReader &reader)
{
    // read my element
    reader.readElement("ConstraintList");
    // get the value of my attribute
    int count = reader.getAttributeAsInteger("count");

    std::vector<Constraint*> values;
    values.reserve(count);
    for (int i = 0; i < count; i++) {
        Constraint *newC = new Constraint();
        newC->Restore(reader);
        // To keep upward compatibility ignore unknown constraint types
        if (newC->Type < Sketcher::NumConstraintTypes) {
            values.push_back(newC);
        }
        else {
            // reading a new constraint type which this version cannot handle
            delete newC;
        }
    }

    reader.readEndElement("ConstraintList");

    // assignment
    setValues(values);
    for (Constraint* it : values)
        delete it;
}
예제 #6
0
void ConstraintSet::enforce_r(const vector<vector<double> > &r0,
                              vector<vector<double> > &rp)
{
  const bool oncoutpe = ctxt_.oncoutpe();
  int iter = 0;
  bool done = false;
  while ( !done && (iter < constraints_maxiter) )
  {
    done = true;
    for ( int i = 0; i < constraint_list.size(); i++ )
    {
      Constraint *c = constraint_list[i];
      bool b = c->enforce_r(r0,rp);
      done &= b;
    }
    iter++;
  }

  if ( !done )
  {
    if ( oncoutpe )
      cout << " ConstraintSet: could not enforce position constraints in "
           << constraints_maxiter << " iterations" << endl;
  }
}
/*! \return The bounding rectangle for the graphics used to represent
 * a constraint between points \a start and \a end (typically an
 * arrow)
 */
QRectF ItemDelegate::constraintBoundingRect( const QPointF& start, const QPointF& end, const Constraint &constraint ) const
{
    QPolygonF poly;
    QPointF e = end;
    switch ( constraint.relationType() ) {
        case Constraint::FinishStart:
            if ( constraint.endIndex().data( KDGantt::ItemTypeRole ).toInt() == KDGantt::TypeEvent ) {
                e.setX( e.x() - TURN );
            }
            poly = finishStartLine( start, e ) + finishStartArrow( start, e );
            break;
        case Constraint::FinishFinish:
            if ( constraint.endIndex().data( KDGantt::ItemTypeRole ).toInt() == KDGantt::TypeEvent ) {
                e.setX( e.x() + TURN );
            }
            poly = finishFinishLine( start, e ) + finishFinishArrow( start, e );
            break;
        case Constraint::StartStart:
            if ( constraint.endIndex().data( KDGantt::ItemTypeRole ).toInt() == KDGantt::TypeEvent ) {
                e.setX( e.x() - TURN );
            }
            poly = startStartLine( start, e ) + startStartArrow( start, e );
            break;
        case Constraint::StartFinish:
            if ( constraint.endIndex().data( KDGantt::ItemTypeRole ).toInt() == KDGantt::TypeEvent ) {
                e.setX( e.x() + TURN );
            }
            poly = startFinishLine( start, e ) + startFinishArrow( start, e );
            break;
        default:
            break;
    }
    return poly.boundingRect().adjusted( -PW, -PW, PW, PW );
}
예제 #8
0
void VACExtension::printTightMatrix()
{
    ofstream ofs("problem.dat");

    Cost Top = wcsp->getUb();
    for (unsigned int i = 0; i < wcsp->numberOfVariables(); i++) {
        for (unsigned int j = 0; j < wcsp->numberOfVariables(); j++) {
            if (i != j) {
                EnumeratedVariable *x =
                        (EnumeratedVariable *) wcsp->getVar(i);
                EnumeratedVariable *y =
                        (EnumeratedVariable *) wcsp->getVar(j);
                Constraint *bctr = x->getConstr(y);
                double t = 0;
                if (bctr)
                    t = bctr->getTightness();
                if (t > to_double(Top))
                    t = to_double(Top);
                t = t * 256.0 / to_double(Top);
                ofs << t << " ";
            } else
                ofs << 0 << " ";
        }
        ofs << endl;
    }
}
    void MainWindow::onConstraintItemSelectionChanged( ) {
        getSimulationThread().getSimulator().getLock().lockForRead();
        Creature* creature = getSimulationThread().getSimulator().currentCreature();
        if (creature) {
            for (int i = 0; i < getUiInspector().lst_constraints->count(); ++i) {
                if (!getUiInspector().lst_constraints->item(i)->isSelected()) {
                    continue;
                }
                Constraint* constraint = &creature->getConstraint(i);
                btVector3 angular_limits = constraint->getAngularLowerLimits();
                getUiInspector().sbx_lower_angular_dof_x->setValue(angular_limits.x());
                getUiInspector().sbx_lower_angular_dof_y->setValue(angular_limits.y());
                getUiInspector().sbx_lower_angular_dof_z->setValue(angular_limits.z());
                angular_limits = constraint->getAngularUpperLimits();
                getUiInspector().sbx_upper_angular_dof_x->setValue(angular_limits.x());
                getUiInspector().sbx_upper_angular_dof_y->setValue(angular_limits.y());
                getUiInspector().sbx_upper_angular_dof_z->setValue(angular_limits.z());

                if (getUiInspector().rbt_motor_x->isChecked()) {
                    loadConstraintValues(constraint, 0);
                }
                if (getUiInspector().rbt_motor_y->isChecked()) {
                    loadConstraintValues(constraint, 1);
                }
                if (getUiInspector().rbt_motor_z->isChecked()) {
                    loadConstraintValues(constraint, 2);
                }
            }
        }
        getSimulationThread().getSimulator().getLock().unlock();
    }
예제 #10
0
void TextWindow::ShowStepDimension(void) {
    Constraint *c = SK.constraint.FindByIdNoOops(shown.constraint);
    if(!c) {
        shown.screen = SCREEN_LIST_OF_GROUPS;
        Show();
        return;
    }

    Printf(true, "%FtSTEP DIMENSION%E %s", c->DescriptionString());

    if(shown.dimIsDistance) {
        Printf(true,  "%Ba   %Ftstart%E    %s", SS.MmToString(c->valA));
        Printf(false, "%Bd   %Ftfinish%E   %s %Fl%Ll%f[change]%E",
            SS.MmToString(shown.dimFinish), &ScreenStepDimFinish);
    } else {
        Printf(true,  "%Ba   %Ftstart%E    %@", c->valA);
        Printf(false, "%Bd   %Ftfinish%E   %@ %Fl%Ll%f[change]%E",
            shown.dimFinish, &ScreenStepDimFinish);
    }
    Printf(false, "%Ba   %Ftsteps%E    %d %Fl%Ll%f%D[change]%E",
        shown.dimSteps, &ScreenStepDimSteps);

    Printf(true, " %Fl%Ll%fstep dimension now%E", &ScreenStepDimGo);

    Printf(true, "(or %Fl%Ll%fcancel operation%E)", &ScreenHome);
}
예제 #11
0
int main(int argc, char** argv)
{
  const std::vector<FNVParam> fnvParams = FNVParam::getAll();
  const std::vector<FNVAlgo> fnvAlgos = FNVAlgo::getAll();
  const std::vector<Constraint> constraints = Constraint::getAll();

  BOOST_FOREACH(const FNVParam& fnvParam, fnvParams)
  {
    std::cout << "Problem size: " << fnvParam.getWidth() << std::endl;

    BOOST_FOREACH(const FNVAlgo& fnvAlgo, fnvAlgos)
    {
      std::cout << "Algorithm: FNV-" << fnvAlgo.getName() << std::endl;

      const Constraint nullConstraint = Constraint::getNull();
      std::cout << "Constraint: " << nullConstraint.getName() << std::endl;
      FNVSolver solver(fnvParam, fnvAlgo, nullConstraint);
      solver.solve();
      const int solutionLength = solver.getSolutionLength();

      BOOST_FOREACH(const Constraint& constraint, constraints)
      {
        std::cout << "Constraint: " << constraint.getName() << std::endl;
        FNVSolver solver(fnvParam, fnvAlgo, constraint, solutionLength);
        solver.solve();
      }
void naryRandom::generateNaryCtr( vector<int>& indexs, long nogoods, Cost costMin, Cost costMax)
{
    int i;
    int arity = indexs.size();
    EnumeratedVariable** scopeVars = new EnumeratedVariable * [arity];
    int* scopeIndexs = new int [arity];
    Char* tuple = new Char [arity+1];
    Cost Top = wcsp.getUb();
    if(costMax < Top) Top = costMax;

    for(i = 0; i<arity; i++) {
        scopeIndexs[i] = indexs[i];
        scopeVars[i] = (EnumeratedVariable*) wcsp.getVar(indexs[i]);
        tuple[i] = 0 + CHAR_FIRST;
    }
    tuple[arity] = '\0';

    Constraint* nctr =  wcsp.getCtr( wcsp.postNaryConstraintBegin(scopeIndexs, arity, Top) );

    String s(tuple);
    while(nogoods>0) {
        for(i = 0; i<arity; i++) s[i] = myrand() % scopeVars[i]->getDomainInitSize() + CHAR_FIRST;
        Cost c = ToulBar2::costMultiplier * randomCost(MIN_COST, costMax);
        nctr->setTuple(s, c, scopeVars);
        nogoods--;
    }
    nctr->propagate();

    delete [] scopeIndexs;
    delete [] scopeVars;
    delete [] tuple;
}
예제 #13
0
//this function does 2 things
//1. Fills this bipartition with the bitwise intersection of a backbone mask and a mask
//representing a subset of taxa in a growing tree.  Note that it is safe to call this when the
//constraint is not a backbone and/or when the partialMask is NULL.  In that case it will fill
//the bipartition with one or the other, or with all bits on if their if neither 
//2. Checks if there is a meaningful intersection between the created joint mask and 
//the constraint.  That means at least 2 bits are "on" on each site of the constrained bipartition
bool Bipartition::MakeJointMask(const Constraint &constr, const Bipartition *partialMask){
	if(constr.IsBackbone()){
		//this just uses Bipartition::Operator=()
		*this = *(constr.GetBackboneMask());
		if(partialMask != NULL)//in this case we'll need to test for meaningful intersection below
			this->AndEquals(*partialMask);
		else//here we don't need to check, since a backbone constraint and its own mask must be meaningful
			return true;
		}
	else if(partialMask != NULL){
		//in this case we'll need to test for meaningful intersection below
		*this = *(partialMask);
		}
	else{
		FillAllBits();
		return true;
		}

	Bipartition temp;
	temp = constr.GetBipartition();
	temp.AndEquals(*this);
	if(temp.MoreThanOneBitSet() == false)
		return false;

	temp = constr.GetBipartition();
	temp.Complement();
	temp.AndEquals(*this);
	if(temp.MoreThanOneBitSet() == false)
		return false;

	return true;
	}
void ItemDelegate::paintStartFinishConstraint( QPainter* painter, const QStyleOptionGraphicsItem& opt, const QPointF& start, const QPointF& end, const Constraint &constraint )
{
    Q_UNUSED( opt );

    QPen pen;
    QVariant dataPen;

    // default pens
    if ( start.x() <= end.x() ) {
        pen = QPen( Qt::black );
        dataPen = constraint.data( Constraint::ValidConstraintPen );
    } else {
        pen = QPen( Qt::red );
        dataPen = constraint.data( Constraint::InvalidConstraintPen );
    }

    // data() pen
    if( qVariantCanConvert< QPen >( dataPen ) )
        pen = qVariantValue< QPen >( dataPen );

    painter->setPen( pen );
    painter->setBrush( pen.color() );

    QPointF e = end;
    if ( constraint.endIndex().data( KDGantt::ItemTypeRole ).toInt() == KDGantt::TypeEvent ) {
        e.setX( e.x() + TURN );
    }
    painter->drawPolyline( startFinishLine( start, e ) );
    painter->drawPolygon( startFinishArrow( start, e ) );
}
  void SteepestDescentSolver<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::Iterate(const Matrix& Aref, const Constraint& C, const Matrix& P0, RCP<Matrix>& P) const {
    RCP<const Matrix> A = rcpFromRef(Aref);
    RCP<Matrix> AP, G;

    Teuchos::FancyOStream& mmfancy = this->GetOStream(Statistics2, 0);

    Teuchos::ArrayRCP<const SC> D = Utils::GetMatrixDiagonal(*A);

    RCP<CrsMatrix> Ptmp_ = CrsMatrixFactory::Build(C.GetPattern());
    Ptmp_->fillComplete(P0.getDomainMap(), P0.getRangeMap());
    RCP<Matrix>    Ptmp  = rcp(new CrsMatrixWrap(Ptmp_));

    // Initial P0 would only be used for multiplication
    P = rcp_const_cast<Matrix>(rcpFromRef(P0));

    for (size_t k = 0; k < nIts_; k++) {
      AP = Utils::Multiply(*A, false, *P, false, mmfancy, true, false);
#if 0
      // gradient = -2 A^T * A * P
      SC stepLength = 2*stepLength_;
      G = Utils::Multiply(*A, true, *AP, false, true, true);
      C.Apply(*G, *Ptmp);
#else
      // gradient = - A * P
      SC stepLength = stepLength_;
      Utils::MyOldScaleMatrix(*AP, D, true, false, false);
      C.Apply(*AP, *Ptmp);
#endif

      RCP<Matrix> newP;
      Utils2::TwoMatrixAdd(*Ptmp, false, -stepLength, *P, false, Teuchos::ScalarTraits<Scalar>::one(), newP, mmfancy);
      newP->fillComplete(P->getDomainMap(), P->getRangeMap() );
      P = newP;
    }
  }
예제 #16
0
    inline void save(Constraint r) {

#ifdef _DEBUG_BACKTRACK
      int id = r.id();
      if(_DEBUG_BACKTRACK) {
	for(int i=0; i<level; ++i) std::cout << " ";
	std::cout << "c save [" << r.id() << "]" ;
	r.display(std::cout);
	
	int info = r.info();
	if(info & ACTIVITY) {
	  std::cout << " (change on activity)";
	}
	if(info & RELAXED) {
	  std::cout << " (was relaxed)";
	}
	if(info & POSTED) {
	  std::cout << " (was posted)";
	}
	
	std::cout << std::endl;
      }
#endif

      saved_cons.add(r);


    }
예제 #17
0
파일: draw.cpp 프로젝트: tmpvar/solvespace
void GraphicsWindow::Selection::Draw(void) {
    Vector refp = Vector::From(0, 0, 0);
    if(entity.v) {
        Entity *e = SK.GetEntity(entity);
        e->Draw();
        if(emphasized) refp = e->GetReferencePos();
    }
    if(constraint.v) {
        Constraint *c = SK.GetConstraint(constraint);
        c->Draw();
        if(emphasized) refp = c->GetReferencePos();
    }
    if(emphasized && (constraint.v || entity.v)) {
        // We want to emphasize this constraint or entity, by drawing a thick
        // line from the top left corner of the screen to the reference point
        // of that entity or constraint.
        double s = 0.501/SS.GW.scale;
        Vector topLeft =       SS.GW.projRight.ScaledBy(-SS.GW.width*s);
        topLeft = topLeft.Plus(SS.GW.projUp.ScaledBy(SS.GW.height*s));
        topLeft = topLeft.Minus(SS.GW.offset);

        glLineWidth(40);
        RgbColor rgb = Style::Color(Style::HOVERED);
        glColor4d(rgb.redF(), rgb.greenF(), rgb.blueF(), 0.2);
        glBegin(GL_LINES);
            ssglVertex3v(topLeft);
            ssglVertex3v(refp);
        glEnd();
        glLineWidth(1);
    }
}
예제 #18
0
/**
 * incremental version of satisfy that allows refinement after blocks are
 * moved.
 *
 *  - move blocks to new positions
 *  - repeatedly merge across most violated constraint until no more
 *    violated constraints exist
 *
 * Note: there is a special case to handle when the most violated constraint
 * is between two variables in the same block.  Then, we must split the block
 * over an active constraint between the two variables.  We choose the
 * constraint with the most negative lagrangian multiplier.
 */
void IncSolver::satisfy() {
#ifdef RECTANGLE_OVERLAP_LOGGING
  ofstream f(LOGFILE,ios::app);
  f<<"satisfy_inc()..."<<endl;
#endif
  splitBlocks();
  long splitCtr = 0;
  Constraint* v = NULL;

  while((v=mostViolated(inactive))&&(v->equality || v->slack() < ZERO_UPPERBOUND)) {
    assert(!v->active);
    Block *lb = v->left->block, *rb = v->right->block;

    if(lb != rb) {
      lb->merge(rb,v);
    }
    else {
      if(lb->isActiveDirectedPathBetween(v->right,v->left)) {
        // cycle found, relax the violated, cyclic constraint
        v->gap = v->slack();
        continue;
      }

      if(splitCtr++>10000) {
        throw "Cycle Error!";
      }

      // constraint is within block, need to split first
      inactive.push_back(lb->splitBetween(v->left,v->right,lb,rb));
      lb->merge(rb,v);
      bs->insert(lb);
    }
  }

#ifdef RECTANGLE_OVERLAP_LOGGING
  f<<"  finished merges."<<endl;
#endif
  bs->cleanup();

  for(unsigned i=0; i<m; i++) {
    v=cs[i];

    if(v->slack() < ZERO_UPPERBOUND) {
      ostringstream s;
      s<<"Unsatisfied constraint: "<<*v;
#ifdef RECTANGLE_OVERLAP_LOGGING
      ofstream f(LOGFILE,ios::app);
      f<<s.str()<<endl;
#endif
      throw s.str().c_str();
    }
  }

#ifdef RECTANGLE_OVERLAP_LOGGING
  f<<"  finished cleanup."<<endl;
  printBlocks();
#endif
}
예제 #19
0
static void getCollisionIndices( const Constraint& con, std::pair<int,int>& indices )
{
  con.getBodyIndices( indices );
  if( indices.second == -1 )
  {
    const unsigned static_object_index{ con.getStaticObjectIndex() };
    indices.second = - int( static_object_index ) - 2;
  }
}
예제 #20
0
void TableSettings::GetConstraints(SerializableList& keys, const wxString& localcol)
{
    for( SerializableList::iterator it = m_lstKeys.begin();
         it != m_lstKeys.end(); ++it ) {

        Constraint *c = wxDynamicCast( *it, Constraint );
        if( c && ( c->GetLocalColumn() == localcol ) ) keys.Append( *it );
    }
}
예제 #21
0
void GraphConstraints::nodeDeleted(node v)  
{
	ListConstIterator<Constraint *> it;
	for(it = m_List.begin(); it.valid(); ++it)
	{
		Constraint *c = *it;
		c->nodeDeleted(v);
	};			
};
예제 #22
0
int UtcDaliShaderConstraint02(void)
{
  TestApplication application;

  tet_infoline("Test that a uniform map shader property can be constrained");

  Shader shader = Shader::New(VertexSource, FragmentSource);
  Material material = Material::New( shader );
  material.SetProperty(Material::Property::COLOR, Color::WHITE);

  Geometry geometry = CreateQuadGeometry();
  Renderer renderer = Renderer::New( geometry, material );

  Actor actor = Actor::New();
  actor.AddRenderer(renderer);
  actor.SetSize(400, 400);
  Stage::GetCurrent().Add(actor);
  application.SendNotification();
  application.Render(0);

  Vector4 initialColor = Color::WHITE;
  Property::Index colorIndex = shader.RegisterProperty( "uFadeColor", initialColor );

  TestGlAbstraction& gl = application.GetGlAbstraction();

  application.SendNotification();
  application.Render(0);

  Vector4 actualValue(Vector4::ZERO);
  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );

  // Apply constraint
  Constraint constraint = Constraint::New<Vector4>( shader, colorIndex, TestConstraintNoBlue );
  constraint.Apply();
  application.SendNotification();
  application.Render(0);

   // Expect no blue component in either buffer - yellow
  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );

  application.Render(0);
  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );

  shader.RemoveConstraints();
  shader.SetProperty(colorIndex, Color::WHITE );
  application.SendNotification();
  application.Render(0);

  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
  DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );

  END_TEST;
}
예제 #23
0
// complex logic to force to correct sorted order in CONSTRDB
// the intent of the test is to return the tighter constraint, based
// first on the number of criteria, and second on the precedence of
// the criteria
bool Constraint::operator < (const Constraint& p_const) const
{
    int thisCriteria = getCriteriaCount();
	int otherCriteria = p_const.getCriteriaCount();

    if (thisCriteria == otherCriteria)
        return getTotalPrecedence() > p_const.getTotalPrecedence();
    else
        return thisCriteria > otherCriteria;
}
예제 #24
0
bool RecordEnumerator::simplify(Solver& s, bool r) {
	ConstraintDB::size_type i, j, end = nogoods_.size();
	for (i = j = 0; i != end; ++i) {
		Constraint* c = nogoods_[i];
		if (c->simplify(s, r))  { c->destroy(); }
		else                    { nogoods_[j++] = c;  }
	}
	nogoods_.erase(nogoods_.begin()+j, nogoods_.end());
	return false;
}
예제 #25
0
    void Creature::loadConnectionTransform(const BodyPart& body, const Constraint& constraint, btTransform & trans) {
        if (body.getId() == constraint.getIdBodyA()) {
            Constraint::locateConnectionOrigin(body, constraint.getConnectionA(), trans);
        } else {

            assert(body.getId() == constraint.getIdBodyB());
            Constraint::locateConnectionOrigin(body, constraint.getConnectionB(), trans);
        }
        trans = body.getRigidBody()->getCenterOfMassTransform() * trans;
    }
END_TEST

START_TEST ( test_Constraint )
{
  Constraint* c = new Constraint(2, 4);
  
  fail_unless (c->hasRequiredAttributes());

  delete c;
}
/*!\returns true if the startpoint is before the endpoint
 * of the constraint \a c.
 */
bool AbstractGrid::isSatisfiedConstraint( const Constraint& c ) const
{
    // First check if the data is valid,
    // TODO: review if true is the right choice
    if ( !c.startIndex().isValid() || !c.endIndex().isValid() ) return true;

    Span ss = mapToChart( c.startIndex() );
    Span es = mapToChart( c.endIndex() );
    return ( ss.end() <= es.start() );
}
예제 #28
0
void CreateRagdoll::CreateRagdollConstraint(const String& boneName, const String& parentName, ConstraintType type,
    const Vector3& axis, const Vector3& parentAxis, const Vector2& highLimit, const Vector2& lowLimit,
    bool disableCollision)
{
    Node* boneNode = node_->GetChild(boneName, true);
    Node* parentNode = node_->GetChild(parentName, true);
    if (!boneNode)
    {
        URHO3D_LOGWARNING("Could not find bone " + boneName + " for creating ragdoll constraint");
        return;
    }
    if (!parentNode)
    {
        URHO3D_LOGWARNING("Could not find bone " + parentName + " for creating ragdoll constraint");
        return;
    }

    Constraint* constraint = boneNode->CreateComponent<Constraint>();
    constraint->SetConstraintType(type);
    // Most of the constraints in the ragdoll will work better when the connected bodies don't collide against each other
    constraint->SetDisableCollision(disableCollision);
    // The connected body must be specified before setting the world position
    constraint->SetOtherBody(parentNode->GetComponent<RigidBody>());
    // Position the constraint at the child bone we are connecting
    constraint->SetWorldPosition(boneNode->GetWorldPosition());
    // Configure axes and limits
    constraint->SetAxis(axis);
    constraint->SetOtherAxis(parentAxis);
    constraint->SetHighLimit(highLimit);
    constraint->SetLowLimit(lowLimit);
}
예제 #29
0
void Mistral::ConsolidateListener::notify_add_con(Constraint c) {

  //std::cout << "ADD CON " << c << std::endl;

  Variable *scope = c.get_scope();
  int arity = c.arity();
  for(int i=0; i<arity; ++i) {
    constraints[scope[i].id()].add(c);
    constraints[scope[i].id()].back().set_index(i);
  }
}
예제 #30
0
Constraint* TableSettings::GetConstraint(Constraint::constraintType type,const wxString& localcol)
{
    for( SerializableList::iterator it = m_lstKeys.begin();
         it != m_lstKeys.end(); ++it ) {

        Constraint *c = wxDynamicCast( *it, Constraint );
        if( c && c->GetType() == type && c->GetLocalColumn() == localcol ) return c;
    }

    return NULL;
}