int
SELECT_WIDGET::stroke_cb(CGESTUREptr& g, DrawState*&)
{
   assert(g);

   select_faces(g->pts()) || select_edges(g->pts());

   return 1;
}
Exemple #2
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());
}
Exemple #3
0
bool
PatternPen::compute_target_cell(CGESTUREptr& gest){
   if (_target_cell) {
      print_target_cell();
   }

   int nb_pts = gest->pts().num();
   if (nb_pts < 2) return false;
  
   if (_current_cell_type == BBOX_CELL){
      _target_cell = new BBoxCell(gest->pts()[0], gest->pts()[nb_pts-1]);
   } else if (_current_cell_type == RECT_CELL){
      double thickness;
      GESTUREptr axis_gesture;
      update_rect_drawer(gest, axis_gesture, thickness);
      if (axis_gesture) {
         _target_cell = new RectCell(axis_gesture, thickness);
      } else {
         return false;
      }
   } else if (_current_cell_type == PATH_CELL){
      double thickness;
      GESTUREptr axis_gesture;
      update_path_drawer(gest, axis_gesture, thickness);
      if (axis_gesture) {
         _target_cell = new PathCell(axis_gesture, thickness);
      } else {
         return false;
      }
   } else if (_current_cell_type == CARRIER_CELL){
      GESTUREptr first_gesture;
      GESTUREptr second_gesture;
      update_carrier_drawer(gest, first_gesture, second_gesture);
      if (first_gesture) {
         _target_cell = new CarriersCell(first_gesture, second_gesture);
      } else {
         return false;
      }
   } else {
      return false;    
   }

   _target_cell->set_global_scale(_current_global_scale);
   return true;
}
Exemple #4
0
int  
OVERSKETCH::stroke_cb(CGESTUREptr& gest, DrawState*& s)
{
   err_adv(debug, "OVERSKETCH::stroke_cb");
   assert(gest);

   try_oversketch(gest->pts());

   return 1; // This means we did use up the gesture
}
Exemple #5
0
bool 
PAPER_DOLL::init(CGESTUREptr& g)
{
   if (!(g && g->is_stroke()))
      return false;

   if (g->below_min_length() || g->below_min_spread())
      return false;

   if (!g->is_ellipse()) {
      err_adv(debug, "PAPER_DOLL::init: non-ellipse");
      return false;
   }
   Panel* p = dynamic_cast<Panel*>(
      Bsurface::get_surface(get_top_level(VisRefImage::get_faces(g->pts())))
      );
   err_adv(debug, "PAPER_DOLL::init: %s panel", p?"found":"could not find");
   if (!(p && p->is_selected())) {
      err_adv(debug, "PAPER_DOLL::init: ellipse not over selected panel");
      return false;
   }
   assert(p && p->bfaces().size() > 0);
   Bface_list faces = Bface_list::reachable_faces(p->bfaces().front());
   assert(!faces.empty());
   if (!faces.is_planar(deg2rad(1.0))) {
      err_adv(debug, "PAPER_DOLL::init: region is not planar");
      return false;
   }

   EdgeStrip boundary = faces.get_boundary();
   if (boundary.empty()) {
      err_adv(debug, "PAPER_DOLL::init: region has no boundary");
      return false;
   }

   Bsurface_list surfs = Bsurface::get_surfaces(faces);
   if (!are_all_bsurfaces<Panel>(surfs)) {
      err_adv(debug, "PAPER_DOLL::init: region not all panels");
      return 0;
   }

   err_adv(debug, "PAPER_DOLL::init: proceeding...");

   err_adv(debug, "  boundary edges: %d, components: %d, panels: %d",
           boundary.edges().size(), boundary.num_line_strips(), surfs.num()
      );

   if (get_instance()->build_primitive(faces)) {
      err_adv(debug, "  ... succeeded");
      return true;
   }
   err_adv(debug, "  ... failed");
   return false;
}
Exemple #6
0
///////////////////
// Proxy methods
///////////////////
void 
PatternPen::add_stroke_to_proxy(CGESTUREptr& gest)
{
   if (gest->pts().num() < 2) {
      WORLD::message("Failed to generate hatch stroke (too few samples)...");
      return;
   }
   //NDCpt_list ndcpts = gest->pts();
   //if (_pattern_texture)
   //_pattern_texture->proxy_surface()->add(
   //   gest->pts(),gest->pressures(), _gesture_drawer->base_stroke_proto());
}