Example #1
0
TEST_F(MatchResultTest, AuthorRulesMultipleScopes)
{
    const StylePropertySet* authorSets[] = { propertySet(0), propertySet(1), propertySet(2), propertySet(3) };

    MatchResult result;

    result.finishAddingUARules();

    result.addMatchedProperties(authorSets[0]);
    result.addMatchedProperties(authorSets[1]);
    result.finishAddingAuthorRulesForTreeScope();

    result.addMatchedProperties(authorSets[2]);
    result.addMatchedProperties(authorSets[3]);
    result.finishAddingAuthorRulesForTreeScope();

    testMatchedPropertiesRange(result.allRules(), 4, authorSets);
    testMatchedPropertiesRange(result.uaRules(), 0, nullptr);
    testMatchedPropertiesRange(result.authorRules(), 4, authorSets);

    ImportantAuthorRanges important(result);

    auto iter = important.begin();
    EXPECT_NE(important.end(), iter);
    testMatchedPropertiesRange(*iter, 2, &authorSets[2]);

    ++iter;
    EXPECT_NE(important.end(), iter);
    testMatchedPropertiesRange(*iter, 2, authorSets);

    ++iter;
    EXPECT_EQ(important.end(), iter);
}
Example #2
0
TEST_F(MatchResultTest, AuthorRules) {
  const StylePropertySet* authorSets[] = {propertySet(0), propertySet(1)};

  MatchResult result;

  result.finishAddingUARules();
  result.addMatchedProperties(authorSets[0]);
  result.addMatchedProperties(authorSets[1]);
  result.finishAddingAuthorRulesForTreeScope();

  testMatchedPropertiesRange(result.allRules(), 2, authorSets);
  testMatchedPropertiesRange(result.uaRules(), 0, nullptr);
  testMatchedPropertiesRange(result.authorRules(), 2, authorSets);

  ImportantAuthorRanges important(result);
  EXPECT_EQ(important.end(), ++important.begin());
}
Example #3
0
TEST_F(MatchResultTest, UARulesAndAuthorRulesMultipleScopes) {
  const StylePropertySet* allSets[] = {propertySet(0), propertySet(1),
                                       propertySet(2), propertySet(3),
                                       propertySet(4), propertySet(5)};
  const StylePropertySet** uaSets = &allSets[0];
  const StylePropertySet** authorSets = &allSets[2];

  MatchResult result;

  result.addMatchedProperties(uaSets[0]);
  result.addMatchedProperties(uaSets[1]);
  result.finishAddingUARules();

  result.addMatchedProperties(authorSets[0]);
  result.addMatchedProperties(authorSets[1]);
  result.finishAddingAuthorRulesForTreeScope();

  result.addMatchedProperties(authorSets[2]);
  result.addMatchedProperties(authorSets[3]);
  result.finishAddingAuthorRulesForTreeScope();

  testMatchedPropertiesRange(result.allRules(), 6, allSets);
  testMatchedPropertiesRange(result.uaRules(), 2, uaSets);
  testMatchedPropertiesRange(result.authorRules(), 4, authorSets);

  ImportantAuthorRanges important(result);

  ImportantAuthorRangeIterator iter = important.begin();
  EXPECT_NE(important.end(), iter);
  testMatchedPropertiesRange(*iter, 2, &authorSets[2]);

  ++iter;
  EXPECT_NE(important.end(), iter);
  testMatchedPropertiesRange(*iter, 2, authorSets);

  ++iter;
  EXPECT_EQ(important.end(), iter);
}
Example #4
0
TEST_F(MatchResultTest, UAAndAuthorRules)
{
    const StylePropertySet* allSets[] = { propertySet(0), propertySet(1), propertySet(2), propertySet(3) };
    const StylePropertySet** uaSets = &allSets[0];
    const StylePropertySet** authorSets = &allSets[2];

    MatchResult result;

    result.addMatchedProperties(uaSets[0]);
    result.addMatchedProperties(uaSets[1]);
    result.finishAddingUARules();

    result.addMatchedProperties(authorSets[0]);
    result.addMatchedProperties(authorSets[1]);
    result.finishAddingAuthorRulesForTreeScope();

    testMatchedPropertiesRange(result.allRules(), 4, allSets);
    testMatchedPropertiesRange(result.uaRules(), 2, uaSets);
    testMatchedPropertiesRange(result.authorRules(), 2, authorSets);

    ImportantAuthorRanges important(result);
    EXPECT_EQ(important.end(), ++important.begin());
}
Example #5
0
void vertex_mat(Mesh &m , float vW0, CCS& ccs , std::vector<double> & bb)
{
  //weight for vertices at the intersection of at least three clusters
  //weight for regular vertices is 1

  //maximum number of clusters adjacent to a vertex
  size_t maxLabel=3;

  std::vector<bool>processed (m.v.size());
  std::vector<bool>important(m.v.size());
  std::vector<real_t > vertArea(m.v.size());
  for(size_t ii=0; ii<m.t.size(); ii++) {
    for(int vidx = 0; vidx<3; vidx++) {
      int idx = m.t[ii][vidx];
      vertArea[idx]+=m.t[ii].A;
      if(processed[idx]) {
        continue;
      }
      std::set<int>labels;
      processed[idx]=1;
      labels.insert(m.t[ii].label);
      bool found = 1;
      std::set<int>visited_t;
      visited_t.insert(ii);
      int cur=ii;
      while(found) {
        found =0 ;
        for (size_t nbr = 0; nbr<m.adjMat[cur].size(); nbr++) {
          size_t nbrIdx = m.adjMat[cur][nbr];
          if(visited_t.find(nbrIdx)!=visited_t.end()) {
            continue;
          }
          if(find(m.t[nbrIdx].x,idx,3)>=0) {
            found=1;
            cur=nbrIdx;
            visited_t.insert(nbrIdx);
            break;
          }
        }
        if(found) {
          int lab = m.t[cur].label;
          labels.insert(lab);
          if(labels.size()>=maxLabel) {
            break;
          }
        }
      }

      if(labels.size()>=maxLabel) {
        important[idx]=true;
      }

    }
  }
  for(int axis=0; axis<3; axis++) {

  for(size_t idx=0;idx<m.v.size();idx++){
    real_t f;
    std::map<int,real_t>val;
    if(important[idx]){
      f=vW*vW0;
    } else {
       f=vW0;
    }
    f*=vertArea[idx];
    val[idx]=f;
    addrow(val,ccs,axis*nvar);
    bb.push_back(f*m.v0[idx][axis]);

  }
  }
}
Example #6
0
void MessageBuffer::addImportantMessage(string msg) {
  addMessage(important(msg));
}