/* static */ bool FontUtils::IsAvailableFont(const char* input_query_desc) { string query_desc(input_query_desc); if (PANGO_VERSION <= 12005) { // Strip commas and any ' Medium' substring in the name. query_desc.erase(std::remove(query_desc.begin(), query_desc.end(), ','), query_desc.end()); const string kMediumStr = " Medium"; std::size_t found = query_desc.find(kMediumStr); if (found != std::string::npos) { query_desc.erase(found, kMediumStr.length()); } } PangoFontDescription *desc = pango_font_description_from_string( query_desc.c_str()); PangoFont* selected_font = NULL; { InitFontconfig(); PangoFontMap* font_map = pango_cairo_font_map_get_default(); PangoContext* context = pango_context_new(); pango_context_set_font_map(context, font_map); { DISABLE_HEAP_LEAK_CHECK; selected_font = pango_font_map_load_font(font_map, context, desc); } g_object_unref(context); } PangoFontDescription* selected_desc = pango_font_describe(selected_font); bool equal = pango_font_description_equal(desc, selected_desc); tlog(3, "query weight = %d \t selected weight =%d\n", pango_font_description_get_weight(desc), pango_font_description_get_weight(selected_desc)); char* selected_desc_str = pango_font_description_to_string(selected_desc); tlog(2, "query_desc: '%s' Selected: 's'\n", query_desc.c_str(), selected_desc_str); g_free(selected_desc_str); pango_font_description_free(selected_desc); pango_font_description_free(desc); return equal; }
int special_hit(object atk) { object tp = query_wielded(); int chance; int dmg = 0; if (tp != owner) return 0; chance = 90+(tp->query_stats("dexterity")+tp->query_stats("wisdom"))/9; if (random(1000) < chance) { dmg = (query_wc()+chance)/(3+random(10)); message("info", COL+capitalize(query_desc())+" sizzles and crackles as it strikes!"+RES, environment(tp) ); atk->add_sp(-(dmg/2)); atk->add_mp(-(dmg/2)); atk->add_bleeding(random(dmg/2)+5); } return dmg; }
void heart_beat() { object tp = query_wielded(); string this = query_desc(); if (!owner) { message("magic", capitalize(this)+" sizzles away.", environment()); remove(); return; } if (tp && tp != owner) { message("magic", capitalize(this)+" sizzles away, burning you!", tp); message("magic", capitalize(this)+" sizzles away, burning "+ tp->query_cap_name()+"!", environment(tp), tp); tp->add_hp(-(10+random(25))); if (tp->query_hp() < 5) tp->set_hp(5); remove(); return; } }
void LocalRecognitionPipeline<PointT>::recognize () { models_.clear(); transforms_.clear(); scene_keypoints_.reset(new pcl::PointCloud<PointT>); obj_hypotheses_.clear(); if (feat_kp_set_from_outside_) { pcl::copyPointCloud(*scene_, scene_kp_indices_, *scene_keypoints_); LOG(INFO) << "Signatures and Keypoints set from outside."; feat_kp_set_from_outside_ = false; } else { estimator_->setNormals(scene_normals_); typename pcl::PointCloud<PointT> processed_foo; estimator_->estimate (*scene_, processed_foo, *scene_keypoints_, signatures_); estimator_->getKeypointIndices(scene_kp_indices_); } if (scene_keypoints_->points.size() != signatures_.size()) throw std::runtime_error("Size of keypoint cloud is not equal to number of signatures!"); int size_feat = signatures_[0].size(); flann::Matrix<float> distances (new float[param_.knn_], 1, param_.knn_); flann::Matrix<int> indices (new int[param_.knn_], 1, param_.knn_); flann::Matrix<float> query_desc (new float[size_feat], 1, size_feat); for (size_t idx = 0; idx < signatures_.size (); idx++) { memcpy (&query_desc.ptr()[0], &signatures_[idx][0], size_feat * sizeof(float)); if(param_.distance_metric_==2) flann_index_l2_->knnSearch (query_desc, indices, distances, param_.knn_, flann::SearchParams (param_.kdtree_splits_)); else flann_index_l1_->knnSearch (query_desc, indices, distances, param_.knn_, flann::SearchParams (param_.kdtree_splits_)); if(distances[0][0] > param_.max_descriptor_distance_) continue; for (size_t i = 0; i < param_.knn_; i++) { const flann_model &f = flann_models_[ indices[0][i] ]; float m_dist = param_.correspondence_distance_weight_ * distances[0][i]; typename symHyp::iterator it_map; if ((it_map = obj_hypotheses_.find (f.model->id_)) != obj_hypotheses_.end ()) { ObjectHypothesis<PointT> &oh = it_map->second; pcl::Correspondence c ( (int)f.keypoint_id, (int)idx, m_dist); oh.model_scene_corresp_.push_back(c); oh.indices_to_flann_models_.push_back( indices[0][i] ); } else //create object hypothesis { ObjectHypothesis<PointT> oh; oh.model_ = f.model; oh.model_scene_corresp_.reserve (signatures_.size () * param_.knn_); oh.indices_to_flann_models_.reserve(signatures_.size () * param_.knn_); oh.model_scene_corresp_.push_back( pcl::Correspondence ((int)f.keypoint_id, (int)idx, m_dist) ); oh.indices_to_flann_models_.push_back( indices[0][i] ); obj_hypotheses_[oh.model_->id_] = oh; } } } delete[] indices.ptr (); delete[] distances.ptr (); delete[] query_desc.ptr (); typename symHyp::iterator it_map; for (it_map = obj_hypotheses_.begin(); it_map != obj_hypotheses_.end (); it_map++) it_map->second.model_scene_corresp_.shrink_to_fit(); // free memory if(cg_algorithm_ && !param_.save_hypotheses_) // correspondence grouping is not done outside { correspondenceGrouping(); //Prepare scene and model clouds for the pose refinement step if ( param_.icp_iterations_ > 0 || hv_algorithm_ ) source_->voxelizeAllModels (param_.voxel_size_icp_); if ( param_.icp_iterations_ > 0) poseRefinement(); if ( hv_algorithm_ && models_.size() ) hypothesisVerification(); signatures_.clear(); scene_keypoints_.reset(); scene_kp_indices_.clear(); } }