JNIEXPORT void JNICALL SurfaceData_IntersectBounds(SurfaceDataBounds *dst, SurfaceDataBounds *src) { int t; GETMAX(dst->x1, src->x1); GETMAX(dst->y1, src->y1); GETMIN(dst->x2, src->x2); GETMIN(dst->y2, src->y2); }
JNIEXPORT void JNICALL SurfaceData_IntersectBoundsXYXY(SurfaceDataBounds *bounds, jint x1, jint y1, jint x2, jint y2) { int t; GETMAX(bounds->x1, x1); GETMAX(bounds->y1, y1); GETMIN(bounds->x2, x2); GETMIN(bounds->y2, y2); }
JNIEXPORT void JNICALL SurfaceData_IntersectBlitBounds(SurfaceDataBounds *src, SurfaceDataBounds *dst, jint dx, jint dy) { int t; GETMAX(dst->x1, src->x1 + dx); GETMAX(dst->y1, src->y1 + dy); GETMIN(dst->x2, src->x2 + dx); GETMIN(dst->y2, src->y2 + dy); GETMAX(src->x1, dst->x1 - dx); GETMAX(src->y1, dst->y1 - dy); GETMIN(src->x2, dst->x2 - dx); GETMIN(src->y2, dst->y2 - dy); }
static int RawRead0(t_praw praw, char *pBuffer, uint64_t Seek, uint32_t *pCount) { t_pPiece pPiece; uint64_t i; // Find correct piece to read from // ------------------------------- for (i=0; i<praw->Pieces; i++) { pPiece = &praw->pPieceArr[i]; if (Seek < pPiece->FileSize) break; Seek -= pPiece->FileSize; } if (i >= praw->Pieces) return RAW_READ_BEYOND_END_OF_IMAGE; // Read from this piece // -------------------- CHK (RawSetCurrentSeekPos (pPiece, Seek, SEEK_SET)) *pCount = GETMIN (*pCount, pPiece->FileSize - Seek); if (fread (pBuffer, *pCount, 1, pPiece->pFile) != 1) { return RAW_CANNOT_READ_DATA; } return RAW_OK; }
void AlignColorSpaceGappedBounded(char *colors, int readLength, char *reference, int referenceLength, ScoringMatrix *sm, AlignedEntry *a, AlignMatrix *matrix, int32_t position, char strand, int32_t maxH, int32_t maxV) { //char *FnName = "AlignColorSpaceGappedBounded"; int i, j; int alphabetSize=ALPHABET_SIZE; assert(0 < readLength); assert(0 < referenceLength); alphabetSize = AlignColorSpaceGetAlphabetSize(colors, readLength, reference, referenceLength); AlignColorSpaceInitializeAtStart(colors, matrix, sm, readLength, referenceLength, alphabetSize, COLOR_SPACE_START_NT); /* Fill in the matrix according to the recursive rules */ for(i=0;i<readLength;i++) { /* read/rows */ /* Get the current color */ for(j=GETMAX(0, i - maxV); j <= GETMIN(referenceLength-1, referenceLength - (readLength - maxH) + i); j++) { /* reference/columns */ assert(i-maxV <= j && j <= referenceLength - (readLength - maxH) + i); AlignColorSpaceFillInCell(colors, readLength, reference, referenceLength, sm, matrix, i, j, colors[i], maxH, maxV, alphabetSize); } } AlignColorSpaceRecoverAlignmentFromMatrix(a, matrix, colors, readLength, reference, referenceLength, 0, 0, readLength - maxV, position, strand, alphabetSize, 0); }
/** * Build the animation from Maya AnimCurves */ osg::ref_ptr<osg::AnimationPath> Transform::animCurve2AnimationPath(MObject &obj) { osg::ref_ptr<osg::AnimationPath> anim = new osg::AnimationPath(); // STEP 1. Get the animation curves MFnAnimCurve tx, ty, tz, rx, ry, rz, sx, sy, sz; MFnDependencyNode dn(obj); MPlugArray conns; dn.getConnections(conns); for(int i=0; i<conns.length(); i++){ MPlug conn = conns[i]; MPlugArray connectedTo; // Get the connections having this node as destination conn.connectedTo(connectedTo, true, false); for(int j=0; j<connectedTo.length(); j++){ MPlug origin = connectedTo[j]; MObject origin_node = origin.node(); if(origin_node.hasFn(MFn::kAnimCurve)){ if(conn.name() == dn.name() + ".translateX" ){ tx.setObject(origin_node); } else if(conn.name() == dn.name() + ".translateY" ){ ty.setObject(origin_node); } else if(conn.name() == dn.name() + ".translateZ" ){ tz.setObject(origin_node); } else if(conn.name() == dn.name() + ".rotateX" ){ rx.setObject(origin_node); } else if(conn.name() == dn.name() + ".rotateY" ){ ry.setObject(origin_node); } else if(conn.name() == dn.name() + ".rotateZ" ){ rz.setObject(origin_node); } else if(conn.name() == dn.name() + ".scaleX" ){ sx.setObject(origin_node); } else if(conn.name() == dn.name() + ".scaleY" ){ sy.setObject(origin_node); } else if(conn.name() == dn.name() + ".scaleZ" ){ sz.setObject(origin_node); } else { std::cout << "Animation curve connected to parameter " << conn.name().asChar() << " (not supported)" << std::endl; } } } } // STEP 2. Build the AnimationPath from animation curves // Search the first key in time from all the AnimCurves bool t_present=false; double mint=0; #define VALID_CURVE(f) ( f.object() != MObject::kNullObj ) #define GETMIN(f) if(VALID_CURVE(f)) { \ double t = f.time(0).as(MTime::kSeconds); \ if( !t_present || t < mint ) \ mint = t; \ t_present = true; \ } GETMIN(tx); GETMIN(ty); GETMIN(tz); GETMIN(rx); GETMIN(ry); GETMIN(rz); GETMIN(sx); GETMIN(sy); GETMIN(sz); // Set the right time in Maya timeline so all properties are updated MAnimControl::setCurrentTime(MTime(mint,MTime::kSeconds)); // Create ControlPoint for initial time anim->insert(mint, osg::AnimationPath::ControlPoint( getCPPosition(obj), getCPRotation(obj), getCPScale(obj) )); double t_prev = mint; // Locate the time of the next key (in any curve) #define GET_NEXT(f) if(VALID_CURVE(f)) { \ for(int c=0; c<f.numKeys(); c++){ \ double t = f.time(c).as(MTime::kSeconds); \ if(t > t_prev && !t_present){ \ t_now = t; \ t_present = true; \ break; \ } \ else if(t > t_prev && t < t_now) { \ t_now = t; \ break; \ } \ } \ } // Get next keys cronologically double t_now = t_prev; t_present=false; GET_NEXT(tx); GET_NEXT(ty); GET_NEXT(tz); GET_NEXT(rx); GET_NEXT(ry); GET_NEXT(rz); GET_NEXT(sx); GET_NEXT(sy); GET_NEXT(sz); while(t_now != t_prev){ // Set the right time in Maya timeline so all properties are updated MAnimControl::setCurrentTime(MTime(t_now,MTime::kSeconds)); anim->insert(t_now, osg::AnimationPath::ControlPoint( getCPPosition(obj), getCPRotation(obj), getCPScale(obj) )); t_prev = t_now; t_present=false; GET_NEXT(tx); GET_NEXT(ty); GET_NEXT(tz); GET_NEXT(rx); GET_NEXT(ry); GET_NEXT(rz); GET_NEXT(sx); GET_NEXT(sy); GET_NEXT(sz); } return anim; }