本文整理汇总了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;
}
示例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 );
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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 ) );
}
示例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;
}