예제 #1
0
/*!
	Find the nearest Bface at the given screen location pix,
	(within the search radius rad), then re-map it to the
	corresponding edit-level face and barycentric
	coordinates bc.
 */
inline Bface*
find_face(CPIXEL& pix, double rad, Wvec& bc)
{

   Bface* f = VisRefImage::get_edit_face(bc, pix, rad);

   // Only select faces belonging to a TEXBODY
   if (!(f && f->mesh() && TEXBODY::isa(f->mesh()->geom())))
      return 0;

   return f;
}
예제 #2
0
/////////////////////////////////////
// store_visibility()
/////////////////////////////////////
bool
HatchingGroupFixed::store_visibility(HatchingLevelBase *hlb)
{
   assert(!_complete);

   HatchingLevelBase::size_type k;
   NDCZpt_list::size_type j;

   NDCZpt_list pts, hull;

   //One side
   for (k=0; k<hlb->size(); k++)
      for (j=0; j<(*hlb)[k]->get_pts().size(); j++)
         pts.push_back(NDCZpt( _patch->xform() * ((*hlb)[k]->get_pts()[j]) ));

   compute_convex_hull(pts,hull);

   if (hull.size() == 0) {
      err_mesg(ERR_LEV_WARN, 
         "HatchingGroupFixed:store_visibility() - Error!! There were %d convex hull verts found from %d hatch verts.",
         hull.size(), pts.size());
      return false;
   } else {
      err_mesg(ERR_LEV_INFO, 
         "HatchingGroupFixed:store_visibility() - There were %d convex hull verts found from %d hatch verts.",
         hull.size(), pts.size());
   }

   Bface *f = nullptr;
   XYpt center = NDCpt(hull.average());
   BMESHray r(center);
   VIEW::peek()->intersect(r);
   f = r.face();

   if (!f) 
   {
      err_mesg(ERR_LEV_WARN, "HatchingGroupFixed:store_visibility() - Seed face intersect failed (hull center)!");
   }
        
   if (!(_patch == f->patch())) 
   {
      err_mesg(ERR_LEV_WARN, "HatchingGroupFixed:store_visibility() - Seed face intersected wrong patch (hull center)!!");
      return false;
   }

   CBface_list & faces = f->mesh()->faces();
   for (k=0; k < faces.size(); k++) faces[k]->clear_bit(1);

   int ctr = 0;
        
   ctr = recurse_visibility(f,hull);

   err_mesg(ERR_LEV_INFO, "HatchingGroupFixed:store_visibility() - There were %d faces in the visible region (from %d).", ctr, faces.size());

   _group->patch()->changed();

   if (ctr>0) return true;
   else return false;
}
예제 #3
0
int
XformPen::tap_cb(CGESTUREptr& tap, DrawState*& s)
{
   assert(tap);
   if (tap->is_double_tap()) {
      // should never happen given order of arcs in XformPen constructor
      cerr << "XformPen::tap_cb: error: gesture is double tap"
           << endl;
      return 0;
   }

   // tap on cursor?
   BMESHray ray(tap->center());
   _view->intersect(ray);
   Cursor3D* c = Cursor3D::upcast(ray.geom());
   if (c) {
      err_adv(debug, "XformPen::tap_cb: hit axis");
      c->handle_gesture(tap);
      return 0;
   }

   // tap on mesh?
   _mesh = 0;
   Bface* f = cur_face();
   if (!f) {
      err_adv(debug, "XformPen::tap_cb: missed face");
      return cancel_cb(tap, s);
   }
   BMESH* m = f->mesh();
   if (!m) {
      err_adv(debug, "XformPen::tap_cb: hit face, no mesh");
      return cancel_cb(tap, s);
   }
   GEOMptr g = bmesh_to_geom(m);
   if (!g) {
      err_adv(debug, "XformPen::tap_cb: hit mesh, no geom");
      return cancel_cb(tap, s);
   }
   // skip floor:
   if (FLOOR::isa(g)) {
      err_adv(debug, "XformPen::tap_cb: hit floor, skipping...");
      return cancel_cb(tap, s);
   }

   // tap on ordinary mesh (not floor):
   _mesh = m;
   assert(_mesh);
   BMESH::set_focus(_mesh, f->patch());
   FLOOR::show();
   FLOOR::realign(_mesh,0); // 0 = no undo command

   Cursor3D::attach(g);

   return 0;
}