bool CParrot::MouseDragStartMsg(CMouseDragStartMsg *msg) { if (_field118 && !_v4 && checkPoint(msg->_mousePos, false, true)) { setVisible(false); CRoomItem *room = findRoom(); moveUnder(room); startTalking(this, 280129); performAction(true); CCarry *item = dynamic_cast<CCarry *>(getRoot()->findByName(_string2)); if (item) { item->_fieldE0 = 1; CPassOnDragStartMsg passMsg; passMsg._mousePos = msg->_mousePos; passMsg.execute(item); msg->_dragItem = item; CActMsg actMsg("LoseParrot"); actMsg.execute("ParrotLobbyController"); } } return true; }
bool isObscured(QWidget* w) { return !(checkPoint(QPoint(0, 0), w) && checkPoint(QPoint(w->width() - 1, 0), w) && checkPoint(QPoint(0, w->height() - 1), w) && checkPoint(QPoint(w->width() - 1, w->height() - 1), w) && checkPoint(QPoint(w->width() / 2, w->height() / 2), w)); }
/* [cffread path callback] Add curveto to path */ static void caretoffCurveto(void *ctx, int flex, cffFixed x1, cffFixed y1, cffFixed x2, cffFixed y2, cffFixed x3, cffFixed y3) { hotCtx g = ctx; checkPoint(g, x3, y3); }
double Benchmarker::checkPointSetResult() { const double result = checkPoint(); m_resultsTable->setValue(result); return result; }
/* [cffread path callback] Add lineto to path */ static void caretoffLineto(void *ctx, cffFixed x1, cffFixed y1) { hotCtx g = ctx; checkPoint(g, x1, y1); }
void computeForceField(struct world *jello) { // loop for all the nodes in the JCube, for every node check for the surrounding FFCube // find the min and max of all the coords , find th jello node offset inside FFCube // find the FFCube 8 nodes positions ans node index values, validate them. Invoke interpolation // to find the value at the Jello node. int x = 0, y = 0, z = 0, X = 0, Y = 0, Z = 0; int xPos = 0, yPos = 0, zPos = 0, i = 0, flag = 0; point curP; node curN; for(x = 0; x < 8; x++) for(y = 0; y < 8; y++) for(z = 0; z < 8; z++) { for(i = 0; i < 8 ; i++) { memset( (void*)&FFCube[i], 0, sizeof(FFCube[i])); memset( (void*)&FFCubePos[i], 0, sizeof(FFCubePos[i])); } memset( (void*)&curP, 0, sizeof(curP)); memset( (void*)&curN, 0, sizeof(curN)); // position of the current jello node in the bounding box curP.x = jello->p[x][y][z].x; curP.y = jello->p[x][y][z].y; curP.z = jello->p[x][y][z].z; if(checkPoint(curP)) continue; curN.x = x; curN.y = y; curN.z = z; if(checkNode(curN)) continue; // find the jello node offset inside the surrounding FFCube xPos = fmod(jello->p[x][y][z].x, forceFieldCubeSize); yPos = fmod(jello->p[x][y][z].y, forceFieldCubeSize); zPos = fmod(jello->p[x][y][z].z, forceFieldCubeSize); X = jello->p[x][y][z].x - xPos; Y = jello->p[x][y][z].y - yPos; Z = jello->p[x][y][z].z - zPos; // Store the positions of all the 8 corners of the FF cube // left bottom front FFCubePos[0].x = X; FFCubePos[0].y = Y; FFCubePos[0].z = Z; if(checkPoint(FFCubePos[0])) continue; // right bottom front FFCubePos[1].x = X + forceFieldCubeSize; FFCubePos[1].y = Y; FFCubePos[1].z = Z; if(checkPoint(FFCubePos[1])) continue; // left bottom back FFCubePos[2].x = X; FFCubePos[2].y = Y; FFCubePos[2].z = Z + forceFieldCubeSize; if(checkPoint(FFCubePos[2])) continue; // right bottom back FFCubePos[3].x = X + forceFieldCubeSize; FFCubePos[3].y = Y; FFCubePos[3].z = Z + forceFieldCubeSize; if(checkPoint(FFCubePos[3])) continue; // left top front FFCubePos[4].x = X; FFCubePos[4].y = Y + forceFieldCubeSize; FFCubePos[4].z = Z; if(checkPoint(FFCubePos[4])) continue; // right top front FFCubePos[5].x = X + forceFieldCubeSize; FFCubePos[5].y = Y + forceFieldCubeSize; FFCubePos[5].z = Z; if(checkPoint(FFCubePos[5])) continue; // left top back FFCubePos[6].x = X; FFCubePos[6].y = Y + forceFieldCubeSize; FFCubePos[6].z = Z + forceFieldCubeSize; if(checkPoint(FFCubePos[6])) continue; // right top back FFCubePos[7].x = X + forceFieldCubeSize; FFCubePos[7].y = Y + forceFieldCubeSize; FFCubePos[7].z = Z + forceFieldCubeSize; if(checkPoint(FFCubePos[7])) continue; for(i = 0; i < 8; i++) { FFCube[i].x = FFCubePos[i].x / forceFieldCubeSize; FFCube[i].y = FFCubePos[i].y / forceFieldCubeSize; FFCube[i].z = FFCubePos[i].z / forceFieldCubeSize; if(checkNode(FFCube[i])) { flag = 1; break; } } if(flag) continue; Interpolate(curP, curN, jello); } }
/******************************************************************* Function: ScoreCompThread Score Computation Input/Output: m: Process Data Structure *******************************************************************/ void * ScoreCompThread (ProcessData * pData, ScoringData * sData, WavesData * wData) { MOATypeDimn k, j; long ocWave; #ifndef NDEBUG int dbglevel = 1; char msg[MID_MESSAGE_SIZE]; #endif #ifndef NDEBUG sprintf (msg, "[%d]>ScoreCompThread: Loop To Compute Scores for total [%ld] Partitions in this process\nEnter loop ******************************************\n", myProcid, pData->partitionsCount); mprintf (dbglevel, msg, 1); #endif //while ((pData->waveNo < wData->wavesTotal) && (pData->partitionsCount > 0)) { sData->waveNo = pData->waveNo; pData->mpi_requests = NULL; pData->sendRequests = 0; while (pData->globalWaveNo < wData->wavesTotal) { while (pData->waveNo == pData->globalWaveNo) { getPartition (wData->partsInWaveIndices[pData->waveNo][pData->partNo], pData->seqNum, pData->seqLen, &pData->msaAlgn, wData->partitionSize); /* Compute Scored for Current Partition*/ #ifndef NDEBUG sprintf (msg, "[%d]>ScoreCompThread[%ld]: Will call ComputePartitionScores\n", myProcid, pData->computedPartitions); mprintf (dbglevel, msg, 1); #endif if (Algorithm == DP) DPComputeScores (pData, sData, wData); else if (Algorithm == SP) SPComputeScores (pData, sData, wData); //printMOA_scr(pData->msaAlgn, 0); #ifndef NDEBUG sprintf (msg, "[%d]>ScoreCompThread[%ld]: Will call printMOA\n", myProcid, pData->computedPartitions); mprintf (dbglevel, msg, 1); /* Print elements ======================================================= */ printMOA(2, pData->msaAlgn, pData->sequences, 0); /* Print Indexes ========================================================*/ printMOA(2, pData->msaAlgn, pData->sequences, 1); sprintf (msg, "[%d]>ScoreCompThread[%ld]: - wave: %ld order: %ld has %lld elm\n", myProcid, pData->computedPartitions-1, pData->waveNo, pData->partNo, pData->msaAlgn->elements_ub); mprintf (dbglevel, msg, 1); sprintf (msg, "[%d]>ScoreCompThread[%ld]: Will call getNextPartition\n", myProcid, pData->computedPartitions-1); mprintf (dbglevel, msg, 1); #endif /****** For testing checkpoint resume **************************** if (!RestoreFlag && pData->computedPartitions == force_exit) { sprintf (msg, "[%d]>ScoreCompThread[%ld]: Forced to exit\n", myProcid, pData->computedPartitions); mprintf (dbglevel, msg, 1); break; } *****************************************************************/ printf ("[%d]W %ld/%ld PO %ld/%ld Part %ld/%ld(T:%ld) PI {%lld ", myProcid, pData->waveNo, wData->wavesTotal, pData->partNo, wData->partsInWave[pData->waveNo], pData->computedPartitions+1, pData->partitionsCount, wData->partsTotal, pData->msaAlgn->indexes[0][0]); for (k=1;k<pData->seqNum;k++) printf (", %lld", pData->msaAlgn->indexes[0][k]); printf ("}\n"); fflush(stdout); getNextPartition (wData, &pData->waveNo, &pData->partNo); checkPoint (pData, sData); pData->computedPartitions ++; } if ((pData->waveNo > sData->waveNo) || (pData->waveNo != pData->globalWaveNo)) { #ifndef NDEBUG sprintf (msg, "[%d]>ScoreCompThread[%ld] w%ld: Will communicate\n", myProcid, pData->computedPartitions, pData->waveNo); mprintf (dbglevel, msg, 1); #endif if (pData->waveNo > sData->waveNo) { prepareWaveOC (sData->waveNo, pData); sendOCtoHigherProcessors(pData); } MPI_Barrier(MOAMSA_COMM_WORLD); receiveOC(pData, sData); if (pData->waveNo > sData->waveNo) sendOCtoLowerProcessors(pData); MPI_Barrier(MOAMSA_COMM_WORLD); receiveOC(pData, sData); pData->globalWaveNo ++; /*Delete OC in waves before k (dimn or seqNum) waves from the current wave.*/ if (pData->waveNo > pData->seqNum + 1) { ocWave = pData->waveNo - pData->seqNum - 1; if (pData->OCin != NULL) { if ((pData->OCin[ocWave].WOCI != NULL) && (pData->OCin[ocWave].wavesOC > 0)) { for (j=0;j<pData->OCin[ocWave].wavesOC;j++) { if (pData->OCin[ocWave].WOCI[j].cellIndex != NULL) { free (pData->OCin[ocWave].WOCI[j].cellIndex); pData->OCin[ocWave].WOCI[j].cellIndex = NULL; } } free (pData->OCin[ocWave].WOCI); pData->OCin[ocWave].WOCI = NULL; } pData->OCin[ocWave].wavesOC = 0; } if (pData->OCout != NULL) { if ((pData->OCout[ocWave].WOCO != NULL) && (pData->OCout[ocWave].wavesOC > 0)) { for (j=0;j<pData->OCout[ocWave].wavesOC;j++) { if (pData->OCout[ocWave].WOCO[j].cellIndex != NULL) { free (pData->OCout[ocWave].WOCO[j].cellIndex); pData->OCout[ocWave].WOCO[j].cellIndex = NULL; } if ((pData->OCout[ocWave].WOCO[j].depProc_ub > 0) && (pData->OCout[ocWave].WOCO[j].depProc != NULL)) { free(pData->OCout[ocWave].WOCO[j].depProc); pData->OCout[ocWave].WOCO[j].depProc = NULL; } } free (pData->OCout[ocWave].WOCO); pData->OCout[ocWave].WOCO = NULL; } pData->OCout[ocWave].wavesOC = 0; } } } //if ((pData->computedPartitions >= pData->partitionsCount) || (pData->partNo < 0)){ if (pData->partNo < 0) { pData->waveNo = wData->wavesTotal; /*to get out of the main loop*/ } } //PrintPrevChains (pData->msaAlgn); pData->compFinished = 1; return NULL; }
/* ============================================================================ function MainProcess: seqNum: Number of sequences in string sequences (ex. 3) sequences: holds the sequences. (ex. [GTGCAACGTACT]) seqLen: Array of the length of each sequence in sequences. (ex. 5,4,3) ======= which means that we have three sequences GTGCA, ACGT, and ACT. stype: Scoring type (1: linear score, 2: PAM250 if protein, 3: BLOSUM if protein) partitionSize: Partion Size ============================================================================== */ void MainProcess (MOATypeDimn seqNum, char * * sequences, char * * seqName, MOATypeShape * seqLen, int stype, long partitionSize) { ProcessData * pData = NULL; ScoringData * sData = NULL; WavesData * wData = NULL; MOATypeDimn k; MOATypeInd i; int ret, startflag; struct rusage usageRec; double utime, stime; MPI_Status status; double t_start, t_finish; char command[2000]; #ifndef NDEBUG char msg[SHORT_MESSAGE_SIZE]; int dbglevel = 0; MOATypeInd j; #endif t_start = MPI_Wtime(); /* print the input arguments ============================================*/ //PrintSequencies (0, seqNum, sequences, seqLen); #ifndef NDEBUG sprintf(msg, ">>>>MainProcess: Scoring Type: %d\n>>>>Partition Size: %ld\n", stype, partitionSize); mprintf(dbglevel, msg, 1); #endif /* Initialize Process Memory pData (function located in partitioning.c*/ ret = initProcessMemory(&pData, &sData, &wData, seqNum, seqLen, sequences, seqName, stype, partitionSize); if (ret != 0) { mprintf (0, ">>>>MainProcess: Error Initializing Process Data, Exiting\n", 1); fflush (stdout); return; } /* if restore previouse run read check point data here, do not calculate waves */ pData->OCout = NULL; pData->OCin = NULL; if (Mode != Distributed) { /* Construct MOA record */ pData->msaAlgn = NULL; createMOAStruct(&pData->msaAlgn); if (createMOA(seqLen, seqNum, pData->msaAlgn, 0, 0) < 0) return; wData->wavesTotal = 1; wData->AllpartsInWave = mmalloc((MOATypeInd) sizeof *wData->AllpartsInWave); wData->AllpartsInWave[0] = 1; pData->waveNo = 0; pData->partNo = 0; pData->partitionsCount = 1; /*pData->OCout = mmalloc((MOATypeInd) sizeof *(pData->OCout)); if (pData->OCout == NULL) { mprintf(1, "Couldn't create memory for OCout while adding an OC. Exiting.\n", 3); printf("Couldn't create memory for OCout while . Exiting.\n",); return; } pData->OCout[0].wavesOC = 0; pData->OCout[0].WOCO = NULL; */ #ifndef NDEBUG sprintf (msg, "[%d]>ScoreCompThread[%ld]: Will call ComputePartitionScores\n", myProcid, pData->computedPartitions); mprintf (dbglevel, msg, 1); #endif /* Compute Scored for Current Partition*/ if (Algorithm == DP) DPComputeScores (pData, sData, wData); else if (Algorithm == SP) DPComputeScores (pData, sData, wData); /* Print elements ======================================================= */ //printMOA_scr(pData->msaAlgn, 0); /* Print Indexes ========================================================*/ //printMOA_scr(pData->msaAlgn, 1); pData->computedPartitions ++; checkPoint (pData, sData); } else { if (RestoreFlag == 1) { /* restore data */ restoreCheckPoint (pData, wData); pData->globalWaveNo = pData->waveNo; } else { pData->partNo = 0; pData->waveNo = 0; if (myProcid == 0) { printf ("[%d] Calculating waves and partitions .... ", myProcid); calcWaves (pData, wData); currNow = getTime(); printf("[%d] Done Calculating waves and partitions time (%d, %d, %d, %d)\n", myProcid, currNow->tm_yday, currNow->tm_hour, currNow->tm_min, currNow->tm_sec); fflush(stdout); if( checkPointWavesCalculations (pData, wData) == 0) { startflag = 1; for (i=1; i<ClusterSize; i++) MPI_Send(&startflag, 1, MPI_INT, i, 0, MOAMSA_COMM_WORLD); } else { printf ("[%d]Couldn't write Waves calculations, Exiting\n", myProcid); return; } } else { //printf ("[%d] waiting for start flag\n", myProcid); MPI_Recv(&startflag, 1, MPI_INT, 0, 0, MOAMSA_COMM_WORLD, &status); //printf ("[%d] received start flag = %d\n", myProcid, startflag); printf ("[%d] Reading waves and partitions .... ", myProcid); if (restoreWavesCalculations(pData, wData) != 0) { printf ("[%d]Couldn't read Waves calculations, Exiting\n", myProcid); return; } printf ("done.\n"); fflush(stdout); } } #ifndef NDEBUG sprintf(msg, "[%d]>MainProcess: Current Wave: %ld - Current Partition: %ld - Total Partitions in Process: %ld\n", myProcid, pData->waveNo, pData->partNo, pData->partitionsCount); mprintf(dbglevel, msg, 1); #endif ScoreCompThread (pData, sData, wData); } if (myProcid == 0) { t_finish = MPI_Wtime(); /* Getting Process Resources Usage ===================== */ ret = getrusage(RUSAGE_SELF, &usageRec); if (ret == 0) { //printf ("[%d]Resources Usage: UTime %ld, STime %ld, Mem %ld, Virt %ld\n", myProcid, usageRec.ru_utime.tv_sec, usageRec.ru_stime.tv_sec, usageRec.ru_maxrss, usageRec.ru_ixrss); utime = (double) usageRec.ru_utime.tv_sec + 1.e-6 * (double) usageRec.ru_utime.tv_usec; stime = (double) usageRec.ru_stime.tv_sec + 1.e-6 * (double) usageRec.ru_stime.tv_usec; //printf ("[%d]Resources Usage: UTime %f, STime %f\n", myProcid, utime, stime); } else printf ("[%d]Failed to retrieve Process Resources Usage, errno %d\n", myProcid, errno); //struct mallinfo info; //info = mallinfo(); //printf("[%d] STime\tUTime\theap\tMemory\t\n",myProcid); //printf("[%d] %f\t%f\t%d\t%d\n", myProcid, stime, utime, info.arena, info.usmblks + info.uordblks); printf("STime\tUTime\n"); printf("%f\t%f\n", stime, utime); printf ("Elsp-time: %f\n", t_finish - t_start); fflush(stdout); sprintf (command, "prstat 1 1 > /export/home/mhelal1/thesis/exp/run/prstatus/prst_%s", outputfilename); i = system (command); } /* Free allocated memory and exit routine ===================== */ freeProcessMemory (&pData, &sData, &wData); }
int testPlane() { int numErr = 0; logMessage(_T("TESTING - class GM_3dPlane ...\n\n")); // Default constructor, plane must be invalid GM_3dPlane p; if (p.isValid()) { logMessage(_T("\tERROR - Default constructor creates valid plane\n")); numErr++; } else { logMessage(_T("\tOK - Default constructor creates invalid plane\n")); } // Constructor (coeff) GM_3dPlane p1(getRandomDouble(), getRandomDouble(), getRandomDouble(), getRandomDouble()); GM_3dPlane pNull(0.0, 0.0, 0.0, getRandomDouble()); if (!p1.isValid() || pNull.isValid()) { logMessage(_T("\tERROR - Coeff. constructor not working\n")); numErr++; } else { logMessage(_T("\tOK - Coeff. constructor working\n")); } // Copy constructor GM_3dPlane copyPlane(p1); if (!copyPlane.isValid() || copyPlane != p1) { logMessage(_T("\tERROR - Copy constructor not working\n")); numErr++; } else { logMessage(_T("\tOK - Copy constructor working\n")); } // Constructor (coeff vector) double pointsVect[4]; for (int i = 0 ; i < 4 ; i++) { pointsVect[i] = getRandomDouble(); } GM_3dPlane p2(pointsVect); if (!p2.isValid()) { logMessage(_T("\tERROR - Coeff. vector constructor not working\n")); numErr++; } else { logMessage(_T("\tOK - Coeff. vector constructor working\n")); } // Constructor (points) GM_3dPoint pt1(getRandomDouble(), getRandomDouble(), getRandomDouble()); GM_3dPoint pt2(getRandomDouble(), getRandomDouble(), getRandomDouble()); GM_3dPoint pt3(getRandomDouble(), getRandomDouble(), getRandomDouble()); GM_3dLine ln(getRandomDouble(), getRandomDouble(), getRandomDouble(),getRandomDouble(), getRandomDouble(), getRandomDouble()); GM_3dPoint ptLn1 = ln.begin(); GM_3dPoint ptLn2 = ln.center(); GM_3dPoint ptLn3 = ln.end(); GM_3dPlane p3(pt1, pt2, pt3); GM_3dPlane pLine(ptLn2, ptLn2, ptLn3); double distPt1 = pt1.x()*p3[0] + pt1.y()*p3[1] + pt1.z()*p3[2] + p3[3]; double distPt2 = pt2.x()*p3[0] + pt2.y()*p3[1] + pt2.z()*p3[2] + p3[3]; double distPt3 = pt3.x()*p3[0] + pt3.y()*p3[1] + pt3.z()*p3[2] + p3[3]; if (!p3.isValid() || pLine.isValid() || fabs(distPt1) > GM_NULL_TOLERANCE || fabs(distPt2) > GM_NULL_TOLERANCE || fabs(distPt3) > GM_NULL_TOLERANCE) { logMessage(_T("\tERROR - Points constructor not working\n")); numErr++; } else { logMessage(_T("\tOK - Points constructor working\n")); } // Point distance GM_3dPlane p4(getRandomDouble(), getRandomDouble(), getRandomDouble(),getRandomDouble()); GM_3dPoint checkPoint(getRandomDouble(), getRandomDouble(), getRandomDouble()); if (fabs(p4[0]) > GM_NULL_TOLERANCE) { checkPoint.x(-(checkPoint.y()*p4[1] + checkPoint.z()*p4[2] + p4[3]) / p4[0]); } else if (fabs(p4[1]) > GM_NULL_TOLERANCE) { checkPoint.y(-(checkPoint.x()*p4[0] + checkPoint.z()*p4[2] + p4[3]) / p4[1]); } else if (fabs(p4[2]) > GM_NULL_TOLERANCE) { checkPoint.z(-(checkPoint.x()*p4[0] + checkPoint.y()*p4[1] + p4[3]) / p4[2]); } else { p4.invalidate(); } double checkSignedDist = getRandomDouble(); double checkDist = fabs(checkSignedDist); GM_3dVector p4Norm = p4.normalVector(); checkPoint = (GM_3dVector)checkPoint + (p4Norm * checkSignedDist); GM_3dPoint checkPointOnPlane1; GM_3dPoint checkPointOnPlane2; double dist = p4.pointDistance(checkPoint); double signedDist = p4.pointDistanceSgn(checkPoint); double signedDistOnPlane = p4.pointDistanceSgn(checkPoint, checkPointOnPlane1); double distOnPlane = p4.pointDistance(checkPoint, checkPointOnPlane2); distPt1 = checkPointOnPlane1.x()*p4[0] + checkPointOnPlane1.y()*p4[1] + checkPointOnPlane1.z()*p4[2] + p4[3]; distPt2 = checkPointOnPlane2.x()*p4[0] + checkPointOnPlane2.y()*p4[1] + checkPointOnPlane2.z()*p4[2] + p4[3]; if (!p4.isValid() || !checkPointOnPlane1.isValid() || !checkPointOnPlane2.isValid() || fabs(distPt1) > GM_NULL_TOLERANCE || fabs(distPt2) > GM_NULL_TOLERANCE || fabs(distOnPlane - checkDist) > GM_NULL_TOLERANCE || fabs(signedDistOnPlane - checkSignedDist) > GM_NULL_TOLERANCE || fabs(dist - checkDist) > GM_NULL_TOLERANCE || fabs(signedDist - checkSignedDist) > GM_NULL_TOLERANCE) { logMessage(_T("\tERROR - Point distance computation not working\n")); numErr++; } else { logMessage(_T("\tOK - Point distance computation working\n")); } // XY Angle double angle = ((((double)rand()) / ((double)RAND_MAX)) * GM_PI) - (GM_PI / 2.0); GM_3dVector normVector(angle/* + GM_HALFPI*/); normVector.z(normVector.y()); normVector.y(0.0); GM_3dPlane angleP(normVector, GM_3dPoint(getRandomDouble(), getRandomDouble(), getRandomDouble())); double checkAngle = angleP.xyAngle(); if (checkAngle > GM_PI) { checkAngle -= 2.0 * GM_PI; } if (!angleP.isValid() || fabs(angle - checkAngle) > GM_NULL_TOLERANCE) { logMessage(_T("\tERROR - XY angle computation not working\n")); numErr++; } else { logMessage(_T("\tOK - XY angle computation working\n")); } return numErr; }