int SELECT_WIDGET::tap_cb(CGESTUREptr& g, DrawState*& s) { err_adv(debug, "SELECT_WIDGET::tap_cb()"); assert(g && g->is_tap()); if (_mode==SLASH_SEL) { //pattern editing Bface* f = find_face(g->start(),0.25,MIN_PIX_AREA); if (f) { if (select_list.contains(f)||select_list.contains(f->quad_partner())) { //get whichever part of the quad is in the selection list int temp = select_list.contains(f) ? select_list.get_index(f)+1 : select_list.get_index(f->quad_partner())+1 ; if (temp>end_face) //user selected the end face { end_face=temp; } else //user is selecting a pattern { if (pattern<temp) pattern=temp; //select/deselect face if (temp < MAX_PATTERN_SIZE) pattern_array[temp]=!pattern_array[temp]; } return 1; } else cerr << "tap found a NULL face !" << endl; } return cancel_cb(g,s); } else { // Tap a selected face near the middle to deselect it: if (try_deselect_face(g->center(), 0.25)) return 1; // Tap edge to deselect if (try_deselect_edge(g->center())) return 1; } // Otherwise, turn off SELECT_WIDGET return cancel_cb(g,s); }
// 2 // 3|_|1 // 0 Bface* ProxySurface::neighbor_face(int dir, Bface* face) { UVpt base_uv = baseUVpt(face); UVpt uv1, uv2, uv3, uv4; switch (dir) { case 0: uv1 = UVpt(base_uv[0], base_uv[1]); uv2 = UVpt(base_uv[0]+1, base_uv[1]); uv3 = UVpt(base_uv[0], base_uv[1]-1); uv4 = UVpt(base_uv[0]+1, base_uv[1]-1); break; case 1: uv1 = UVpt(base_uv[0]+1, base_uv[1]); uv2 = UVpt(base_uv[0]+2, base_uv[1]); uv3 = UVpt(base_uv[0]+1, base_uv[1]+1); uv4 = UVpt(base_uv[0]+2, base_uv[1]+1); break; case 2: uv1 = UVpt(base_uv[0], base_uv[1]+1); uv2 = UVpt(base_uv[0]+1, base_uv[1]+1); uv3 = UVpt(base_uv[0], base_uv[1]+2); uv4 = UVpt(base_uv[0]+1, base_uv[1]+2); break; case 3: uv1 = UVpt(base_uv[0]-1, base_uv[1]); uv2 = UVpt(base_uv[0], base_uv[1]); uv3 = UVpt(base_uv[0], base_uv[1]+1); uv4 = UVpt(base_uv[0]-1, base_uv[1]+1); break; default: cerr << "ProxySurface::neighbor_face: invalid diraction" << endl; assert(0); } Bvert* v1 = get_vert_grid(uv1); Bvert* v2 = get_vert_grid(uv2); Bvert* v3 = get_vert_grid(uv3); Bvert* v4 = get_vert_grid(uv4); if(!v1 || !v2 || !v3 || !v4) return 0; Bface* n = lookup_quad(v1, v2, v3, v4); assert(n); assert(n->is_quad()); n = (n->is_quad_rep()) ? n : n->quad_partner(); return n; }
inline void get_other_face(CBedge* e, CBface* f, Bsimplex_list& ret) { assert(e && f && f->contains(e)); if (e->is_weak()) return; Bface* g = e->other_face(f); if (!g) return; ret.push_back(g); g = g->quad_partner(); if (g) ret.push_back(g); }