当前位置: 首页>>代码示例>>C++>>正文


C++ Constraints类代码示例

本文整理汇总了C++中Constraints的典型用法代码示例。如果您正苦于以下问题:C++ Constraints类的具体用法?C++ Constraints怎么用?C++ Constraints使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Constraints类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: constraintsRemovingRedundantEqualities

Constraints constraintsRemovingRedundantEqualities(Variables const &vars, 
        Constraints const &constraints)
{
    EqualityConstraintSet equalitySets(vars);
    Constraints cs = Constraints(constraints.size());
    int csSize = 0;

    for (unsigned i = 0; i < constraints.size(); ++i)
    {
        Constraint *c = constraints[i];
        if (c->equality)
        {
            if (!equalitySets.isRedundant(c->left, c->right, c->gap))
            {
                // Only add non-redundant equalities
                equalitySets.mergeSets(c->left, c->right, c->gap);
                cs[csSize++] = c;
            }
        }
        else
        {
            // Add all non-equalities
            cs[csSize++] = c;
        }
    }
    cs.resize(csSize);
    return cs;
}
开发者ID:SiteView,项目名称:NNMQT,代码行数:28,代码来源:constraint.cpp

示例2: toLocal

void HAPIHapticShape::getConstraints( const Vec3 &point,
                                      Constraints &constraints,
                                      Collision::FaceType face, 
                                      HAPIFloat radius ) {
  if( have_transform ) {
    unsigned int nr_constraints = constraints.size();
    Vec3 local_point = toLocal( point );
    Vec3 scale = inverse.getScalePart();
    HAPIFloat s = max( scale.x, max( scale.y, scale.z ) );    
    getConstraintsOfShape( local_point, constraints, face, radius * s );
    if( non_uniform_scaling ) {
      for( unsigned int i = nr_constraints; i < constraints.size(); ++i ) {
        PlaneConstraint &pc = constraints[i];
        pc.normal = transform.getRotationPart() * pc.normal;
        pc.normal.x *= scale.x;
        pc.normal.y *= scale.y;
        pc.normal.z *= scale.z;
        pc.normal = inverse.getRotationPart() * pc.normal;
        pc.normal = transform.getRotationPart() * pc.normal;
        pc.normal.normalizeSafe();
        pc.point = transform * pc.point;
      }
    } else {
      for( unsigned int i = nr_constraints; i < constraints.size(); ++i ) {
        PlaneConstraint &pc = constraints[i];
        pc.normal = transform.getRotationPart() * pc.normal;
        pc.point = transform * pc.point;
      }
    }    
  } else {
    getConstraintsOfShape( point, constraints, face, radius );
  }
}
开发者ID:rpavlik,项目名称:hapi,代码行数:33,代码来源:HAPIHapticShape.cpp

示例3: if

Constraints::Constraints (Constraints &cs): std::map <std::string, ConstraintPtr > (cs)
{
	for (Constraints::iterator iter = cs.begin (); iter != cs.end (); iter++)
	{
		Constraint *con = createConstraint (iter->first.c_str ());
		// can "compare" chars, as they are const char*
		if (con->getName () == CONSTRAINT_TIME
			|| con->getName () == CONSTRAINT_AIRMASS
			|| con->getName () == CONSTRAINT_ZENITH_DIST
			|| con->getName () == CONSTRAINT_HA
			|| con->getName () == CONSTRAINT_LDISTANCE
			|| con->getName () == CONSTRAINT_LALTITUDE
			|| con->getName () == CONSTRAINT_LPHASE
			|| con->getName () == CONSTRAINT_SDISTANCE
			|| con->getName () == CONSTRAINT_SALTITUDE)
		{
			((ConstraintInterval *) con)->copyIntervals (((ConstraintInterval *) iter->second->th ()));
		}
		else if (con->getName () == CONSTRAINT_MAXREPEATS)
		{
			((ConstraintMaxRepeat *) con)->copyConstraint (((ConstraintMaxRepeat *) iter->second->th ()));
		}
		else
		{
			std::cerr << "unsuported constraint type in copy constructor " __FILE__ ":" << __LINE__ << std::endl;
			exit (10);
		}

		(*this)[iter->first] = ConstraintPtr (con);
	}
}
开发者ID:welterde,项目名称:rts2,代码行数:31,代码来源:constraints.cpp

示例4: hasConstraint

bool hasConstraint(const ConstraintPtr& c, const Constraints& cs) {
  Constraints r;
  for (Constraints::const_iterator ci = cs.begin(); ci != cs.end(); ++ci) {
    if (*c == **ci) {
      return true;
    }
  }
  return false;
}
开发者ID:lipei0330,项目名称:hobbes,代码行数:9,代码来源:typepreds.C

示例5: removeConstraint

Constraints removeConstraint(const ConstraintPtr& c, const Constraints& cs) {
  Constraints r;
  for (Constraints::const_iterator ci = cs.begin(); ci != cs.end(); ++ci) {
    if (!(*c == **ci)) {
      r.push_back(*ci);
    }
  }
  return r;
}
开发者ID:lipei0330,项目名称:hobbes,代码行数:9,代码来源:typepreds.C

示例6: getConstraintsOfShape

void HapticTriangleSet::getConstraintsOfShape( const Vec3 &point,
                                               Constraints &constraints,
                                               Collision::FaceType face,
                                               HAPIFloat radius ) {
  if( triangles.size() > 0 ) {
    unsigned int size = constraints.size();
    
    if( ( convex == CONVEX_FRONT && 
          face == Collision::FRONT ) ||
        ( convex == CONVEX_BACK && 
          face == Collision::BACK ) ) {
      PlaneConstraint constraint;
      PlaneConstraint best;
      HAPIFloat best_sqr_dist = 0;
      bool first_constraint = true;
      
      // triangle set is convex so only need the closest constraint
      for( std::vector< Collision::Triangle >::iterator i = triangles.begin();
           i != triangles.end(); ++i ) {
        //unsigned int i = 0; i < triangles.size(); ++i ) {
        Collision::Triangle &t = (*i); //*triangles[i];
        
        if( t.getConstraint( point, &constraint, face ) ) {
          if( first_constraint ) {
            best = constraint;
            Vec3 v = point - best.point;
            best_sqr_dist = v * v; 
            first_constraint = false;
          } else {
            Vec3 v = point - constraint.point;
            HAPIFloat sqr_dist = v * v; 
            if( sqr_dist < best_sqr_dist ) {
              best = constraint;
              best_sqr_dist = sqr_dist;
            }
          }
        }
        //constraint.clear();
      }
      if( !first_constraint ) constraints.push_back( best );
    } else {
      // not convex, so add constraints from all triangles.
      for( unsigned int i = 0; i < triangles.size(); ++i ) {
        Collision::Triangle &t = triangles[i];
        t.getConstraints( point, constraints, face, radius  );
      }
    }
    
    for( unsigned int i = size; i < constraints.size(); ++i ) {
      PlaneConstraint &pc = constraints[i];
      pc.haptic_shape.reset(this);
    }
  }
}
开发者ID:ChristianFrisson,项目名称:HAPI,代码行数:54,代码来源:HapticTriangleSet.cpp

示例7: getConstraintsOfShape

void HapticPrimitiveTree::getConstraintsOfShape( const Vec3 &point,
                                             Constraints &constraints,
                                             Collision::FaceType face,
                                             HAPIFloat radius ) {
  unsigned int size = constraints.size();
  tree->getConstraints( point, constraints, face, radius );
  for( unsigned int i = size; i < constraints.size(); ++i ) {
    PlaneConstraint &pc = constraints[i];
    pc.haptic_shape.reset(this);
  }
}
开发者ID:cihrke,项目名称:hapi-lwr,代码行数:11,代码来源:HapticPrimitiveTree.cpp

示例8: print

void print(Constraints constraints) {
    int row = constraints.size() - 1;
    while (!constraints.empty()) {
        auto constraint = constraints.top();
        constraints.pop();

        std::cout << "Constraints[" << row-- << "]: ";
        for (auto c : constraint) {
            std::cout << c << " ";
        }
        std::cout << std::endl;
    }
}
开发者ID:prismskylabs,项目名称:cpp4py-wip,代码行数:13,代码来源:sort-main.cpp

示例9: FPGrowth

void TestFPGrowth::withConstraints() {
    QList<QStringList> transactions;
    transactions.append(QStringList() << "A" << "B" << "C" << "D");
    transactions.append(QStringList() << "A" << "B");
    transactions.append(QStringList() << "A" << "C");
    transactions.append(QStringList() << "A" << "B" << "C");
    transactions.append(QStringList() << "A" << "D");
    transactions.append(QStringList() << "A" << "C" << "D");
    transactions.append(QStringList() << "C" << "B");
    transactions.append(QStringList() << "B" << "C");
    transactions.append(QStringList() << "C" << "D");
    transactions.append(QStringList() << "C" << "E");

    Constraints constraints;
    constraints.addItemConstraint("A", Analytics::CONSTRAINT_POSITIVE_MATCH_ANY);

    FPNode<SupportCount>::resetLastNodeID();
    ItemIDNameHash itemIDNameHash;
    ItemNameIDHash itemNameIDHash;
    ItemIDList sortedFrequentItemIDs;
    FPGrowth * fpgrowth = new FPGrowth(transactions, 0.4 * transactions.size(), &itemIDNameHash, &itemNameIDHash, &sortedFrequentItemIDs);
    fpgrowth->setConstraints(constraints);
    QList<FrequentItemset> frequentItemsets = fpgrowth->mineFrequentItemsets(FPGROWTH_SYNC);

    // Characteristics about the transactions above, and the found results
    // (*after* applying filtering):
    // * support:
    //   - A: 6
    //   - B: 3
    //   - C: 4
    //   - D: 3
    //   - E: 0
    // * minimum support = 0.4
    // * number of transactions: 10
    // * absolute min support: 4
    // * items qualifying: A, C
    // * frequent itemsets: {{A}, {A, C}}

    // Helpful for debugging/expanding this test.
    // Currently, this should match:
    // (({A(0)}, sup: 6), ({C(2), A(0)}, sup: 4))
    //qDebug() << frequentItemsets;

    // Verify the results.
    QCOMPARE(frequentItemsets, QList<FrequentItemset>() << FrequentItemset(ItemIDList() << 0     , 6)
                                                        << FrequentItemset(ItemIDList() << 2 << 0, 4)
    );

    delete fpgrowth;
}
开发者ID:Libardo1,项目名称:master-thesis,代码行数:50,代码来源:TestFPGrowth.cpp

示例10: m

IncSolver::IncSolver(Variables const &vs, Constraints const &cs)
    : m(cs.size()),
      cs(cs),
      n(vs.size()), 
      vs(vs),
      needsScaling(false)
{
    for(unsigned i=0;i<n;++i) {
        vs[i]->in.clear();
        vs[i]->out.clear();

        // Set needsScaling if any variables have a scale other than 1.
        needsScaling |= (vs[i]->scale != 1);
    }
    for(unsigned i=0;i<m;++i) {
        Constraint *c=cs[i];
        c->left->out.push_back(c);
        c->right->in.push_back(c);
        c->needsScaling = needsScaling;
    }
    bs=new Blocks(vs);
#ifdef LIBVPSC_LOGGING
    printBlocks();
    //COLA_ASSERT(!constraintGraphIsCyclic(n,vs));
#endif

    inactive=cs;
    for(Constraints::iterator i=inactive.begin();i!=inactive.end();++i) {
        (*i)->active=false;
    }
}
开发者ID:P-N-L,项目名称:adaptagrams,代码行数:31,代码来源:vpsc.cpp

示例11: getConstraintsOfShape

void HapticPrimitiveSet::getConstraintsOfShape( const Vec3 &point,
                                         Constraints &constraints,
                                         Collision::FaceType face,
                                         HAPIFloat radius ) {
  if( primitives.size() > 0 ) {
    unsigned int size = constraints.size();
    for( unsigned int i = 0; i < primitives.size(); i++ ) {
      Collision::GeometryPrimitive *a_primitive = primitives[i];
      a_primitive->getConstraints( point, constraints, face, radius );
    }

    for( unsigned int i = size; i < constraints.size(); i ++ ) {
      PlaneConstraint &pc = constraints[i];
      pc.haptic_shape.reset(this);
    }
  }
}
开发者ID:vancegroup-mirrors,项目名称:hapi,代码行数:17,代码来源:HapticPrimitiveSet.cpp

示例12: getConstraintsOfShape

void HapticLineSet::getConstraintsOfShape( const Vec3 &point,
                                           Constraints &constraints,
                                           Collision::FaceType face,
                                           HAPIFloat radius ) {
  if( lines.size() > 0 ) {
    unsigned int size = constraints.size();
    for( unsigned int i = 0; i < lines.size(); ++i ) {
      Collision::LineSegment &l = lines[i];
      l.getConstraints( point, constraints, face, radius );
    }

    for( unsigned int i = size; i < constraints.size(); ++i ) {
      PlaneConstraint &pc = constraints[i];
      pc.haptic_shape.reset(this);
    }
  }
}
开发者ID:ChristianFrisson,项目名称:HAPI,代码行数:17,代码来源:HapticLineSet.cpp

示例13: getConstraintsOfShape

void HapticPointSet::getConstraintsOfShape( const Vec3 &point,
                                            Constraints &constraints,
                                            Collision::FaceType face,
                                            HAPIFloat radius ) {
  if( points.size() > 0 ) {
    unsigned int size = constraints.size();
    for( unsigned int i = 0; i < points.size(); i++ ) {
      Collision::Point &temp_p = points[i];
      temp_p.getConstraints( point, constraints, face, radius );
    }
    
    for( unsigned int i = size; i < constraints.size(); i ++ ) {
      PlaneConstraint &pc = constraints[i];
      pc.haptic_shape.reset(this);
    }
  }
}
开发者ID:rpavlik,项目名称:hapi,代码行数:17,代码来源:HapticPointSet.cpp

示例14: getConstraintsOfShape

void HAPIHapticShape::getConstraintsOfShape( const Vec3 &point,
                                             Constraints &constraints,
                                             Collision::FaceType face, 
                                             HAPIFloat radius ) {
  Vec3 cp, n, tc;
  closestPointOnShape( point, cp, n, tc );
  Vec3 v = cp - point;
  if( radius < 0 || v * v <= radius * radius )
    constraints.push_back( PlaneConstraint( cp, n, tc, this ) );
}
开发者ID:rpavlik,项目名称:hapi,代码行数:10,代码来源:HAPIHapticShape.cpp

示例15: getActivePathBetween

/*
 * Returns the active path between variables u and v... not back tracking over w
 */
bool Block::getActivePathBetween(Constraints& path, Variable const* u,
               Variable const* v, Variable const *w) const {
    if(u==v) return true;
    for (Cit_const c=u->in.begin();c!=u->in.end();++c) {
        if (canFollowLeft(*c,w)) {
            if(getActivePathBetween(path, (*c)->left, v, u)) {
                path.push_back(*c);
                return true;
            }
        }
    }
    for (Cit_const c=u->out.begin();c!=u->out.end();++c) {
        if (canFollowRight(*c,w)) {
            if(getActivePathBetween(path, (*c)->right, v, u)) {
                path.push_back(*c);
                return true;
            }
        }
    }
    return false;
}
开发者ID:P-N-L,项目名称:adaptagrams,代码行数:24,代码来源:vpsc.cpp


注:本文中的Constraints类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。