コード例 #1
0
ファイル: query_clusterer.cpp プロジェクト: apavlo/peloton
void QueryClusterer::MergeClusters() {
  // Merge two clusters that are within the threshold in similarity
  // Iterate from left to right and merge the left one into right one and mark
  // the left one for deletion
  std::vector<Cluster *> to_delete;
  for (auto i = clusters_.begin(); i != clusters_.end(); i++) {
    for (auto j = i; ++j != clusters_.end();) {
      auto left = *i;
      auto right = *j;
      auto r_centroid = right->GetCentroid();
      auto similarity = left->CosineSimilarity(r_centroid);

      if (similarity > threshold_) {
        auto templates = left->GetTemplates();
        for (auto &fingerprint : templates) {
          right->AddTemplate(fingerprint);
          template_cluster_[fingerprint] = right;
        }
        right->UpdateCentroid(features_);
        to_delete.push_back(left);
        break;
      }
    }
  }

  // Delete the clusters that are empty
  for (auto cluster : to_delete) {
    clusters_.erase(cluster);
    delete cluster;
  }

  // Rebuild the KDTree to account for changed clusters
  kd_tree_.Build(clusters_);
}
コード例 #2
0
std::vector<TemplateDescriptor>TemplateDescriptor::GetTemplateList(
  const string           & userId,
  IAuthenticationCallback& authenticationCallback)
{
  TIterable<TemplateDescriptor> result;
  auto authenticationCallbackImpl =
    AuthenticationCallbackImpl { authenticationCallback, userId };

  auto pTemplatesClient = ITemplatesClient::Create();
  auto response         = pTemplatesClient->GetTemplates(
    authenticationCallbackImpl,
    userId);

  for_each(
    begin(response.templates),
    end(response.templates),
    [&](const TemplateResponse& templateResponse)
      {
        result.push_back(move(TemplateDescriptor(templateResponse.id,
                                                 templateResponse.name,
                                                 templateResponse.description)));
      });

  return result;
}
コード例 #3
0
ファイル: OBJ_usdcamera.cpp プロジェクト: lvxejay/USD
void
GusdOBJ_usdcamera::Register(OP_OperatorTable* table)
{
    OP_Operator* op = new OP_Operator("pixar::usdcamera",
                                      "USD Camera",
                                      creator,
                                      GetTemplates(),
#if UT_MAJOR_VERSION_INT >= 16
                                      SOP_TABLE_NAME,
#endif
                                      /* min inputs*/ 0,
                                      /* max inputs*/ 1,
                                      GetVariables());
    op->setIconName("pxh_gusdIcon.png");
    op->setOpTabSubMenuPath( "Pixar" );
    table->addOperator(op);
    table->setOpFirstName("pixar::usdcamera", "usdcam");
}