/** * Submit a LinuxRequest. * @param env The JNIEnv. * @param fd The file descriptor. * @param linuxRequest The LinuxRequest. */ static void submitRequest( JNIEnv *env, int fd, jobject linuxRequest ) { int type, err, sync = 0; jclass LinuxRequest; jmethodID getType, setError, setCompleted; LinuxRequest = (*env)->GetObjectClass( env, linuxRequest ); getType = (*env)->GetMethodID( env, LinuxRequest, "getType", "()I" ); setCompleted = (*env)->GetMethodID( env, LinuxRequest, "setCompleted", "(Z)V" ); setError = (*env)->GetMethodID( env, LinuxRequest, "setError", "(I)V" ); (*env)->DeleteLocalRef( env, LinuxRequest ); type = (*env)->CallIntMethod( env, linuxRequest, getType ); dbg(MSG_DEBUG1, "submitRequest : Submitting Request.\n"); switch (type) { case LINUX_PIPE_REQUEST: dbg(MSG_DEBUG1, "submitRequest : Submitting Pipe Request.\n"); err = pipe_request( env, fd, linuxRequest ); break; case LINUX_DCP_REQUEST: dbg(MSG_DEBUG1, "submitRequest : Submitting Dcp Request.\n"); err = dcp_request( env, fd, linuxRequest ); break; case LINUX_SET_INTERFACE_REQUEST: dbg(MSG_DEBUG1, "submitRequest : Submitting SetInterface Request.\n"); err = set_interface( env, fd, linuxRequest ); sync = 1; break; case LINUX_SET_CONFIGURATION_REQUEST: dbg(MSG_DEBUG1, "submitRequest : Submitting SetConfiguration Request.\n"); err = set_configuration( env, fd, linuxRequest ); sync = 1; break; case LINUX_CLAIM_INTERFACE_REQUEST: dbg(MSG_DEBUG1, "submitRequest : Submitting ClaimInterface Request.\n"); err = claim_interface( env, fd, 1, linuxRequest ); sync = 1; break; case LINUX_RELEASE_INTERFACE_REQUEST: dbg(MSG_DEBUG1, "submitRequest : Submitting ReleaseInterface Request.\n"); err = claim_interface( env, fd, 0, linuxRequest ); sync = 1; break; case LINUX_IS_CLAIMED_INTERFACE_REQUEST: dbg(MSG_DEBUG1, "submitRequest : Submitting IsClaimed Request.\n"); err = is_claimed( env, fd, linuxRequest ); sync = 1; break; case LINUX_ISOCHRONOUS_REQUEST: dbg(MSG_DEBUG1, "submitRequest : Submitting Isochronous Request.\n"); err = isochronous_request( env, fd, linuxRequest ); break; default: /* ? */ dbg( MSG_ERROR, "submitRequest : Unknown Request type %d\n", type ); err = -EINVAL; break; } if (err) (*env)->CallVoidMethod( env, linuxRequest, setError, err ); if (sync || err) (*env)->CallVoidMethod( env, linuxRequest, setCompleted, JNI_TRUE ); }
bool TriStrip::build( Bface* start, // build a new strip starting here. Bface_list& stack // used to build nearby parallel strips ) { // a set flag means this face is already in a TriStrip assert(!start->flag()); // start fresh reset(); // repeat 1st vertex if needed if (!start->orient_strip()) start->orient_strip(start->v1()); // get the starting vert. i.e., the strip will // continue onto the next face across the edge // opposite this vertex. Bvert *a = start->orient_strip(), *b, *c; // squash and stretch start = backup_strip(start,a); if (!start) { // should never happen, but can happen // if there are inconsistently oriented faces err_msg("TriStrip::build: error: backup_strip() failed"); err_msg("*** check mesh for inconsistently oriented faces ***"); return 0; } // claim it claim_face(start); // record direction of strip on 1st face: start->orient_strip(a); // faces alternate CCW / CW if (_orientation) { c = start->next_vert_ccw(a); b = start->next_vert_ccw(c); } else { b = start->next_vert_ccw(a); c = start->next_vert_ccw(b); } add(a,start); add(b,start); add(c,start); Bface* opp; if ((opp = start->opposite_face(b)) && is_cleared(opp) && opp->patch() == start->patch()) { opp->orient_strip(_orientation ? a : c); stack.push_back(opp); } int i=_orientation; Bface* cur = start; while ((cur = cur->next_strip_face()) && !is_claimed(cur)) { claim_face(cur); i++; a = b; b = c; c = cur->other_vertex(a,b); cur->orient_strip(a); if ((opp = cur->opposite_face(b)) && is_cleared(opp) && opp->patch() == start->patch()) { opp->orient_strip(i % 2 ? a : c); stack.push_back(opp); } add(c,cur); } return 1; }