Esempio n. 1
0
bool
OVERSKETCH::find_matching_sil(CGESTUREptr& g)
{
   err_adv(debug, "OVERSKETCH::find_matching_sil");

   const size_t MIN_GEST_PTS = 10;
   if (!(g && g->pts().size() >= MIN_GEST_PTS))
      return false;

   if (BMESH::_freeze_sils)
      return false;

   VisRefImage *vis_ref = VisRefImage::lookup(VIEW::peek());
   if (!vis_ref)
      return false;

   // 1. see if the gesture runs along a silhouette
   //    of a single mesh.

   SilEdgeFilter sil_filter;
   const  PIXEL_list& pts = g->pts();
   BMESHptr mesh = nullptr;
   for (PIXEL_list::size_type i=0; i<pts.size(); i++) {
      Bedge* e = (Bedge*)
         vis_ref->find_near_simplex(pts[i], SIL_SEARCH_RAD, sil_filter);
      if (!(e && e->mesh())) {
         err_adv(debug, "   gesture too far from silhouette");
         return false;
      }
      if (mesh && mesh != e->mesh()) {
         err_adv(debug, "   found a second mesh, rejecting");
         return false;
      }
      mesh = e->mesh();
   }
   if (!dynamic_pointer_cast<LMESH>(mesh)) {
      err_adv(debug, "   found non-LMESH, rejecting");
      return false;
   }

   err_adv(debug, "   gesture aligns with silhouette");
   err_adv(debug, "   mesh level %d", mesh->subdiv_level());

   // 2. extract the portion of the silhouette that matches
   //    the gesture, store in _selected_sils

   return find_matching_sil(pts, mesh->sil_strip());
}
Esempio n. 2
0
inline double
compute_yardstick(CBedge_list& edges, bool debug=false)
{
   double ret = 0.6 * edges.strong_edges().avg_len();

   BMESHptr mk = edges.mesh();
   BMESHptr m0 = get_top_level(edges.get_faces()).mesh();

   int    lk = 0;       // mesh level of edges
   int    l0 = 0;       // mesh level of edges' control region
   double  s = 1;       // scaling factor
   if (mk && m0) {
      lk = mk->subdiv_level();
      l0 = m0->subdiv_level();
      s = (1 << (lk - l0));
   }
   err_adv(debug, "lk: %d, l0: %d, scaling: %f", lk, l0, s);
   return s * ret;
}