void CreateMain() { int i, count; int width, height; char name[128]; for ( i = 0, count = 0; i < filenum; i++ ) { if ( in[i].depth ) { printf( "\rProcessing %d of %d (%d missed, %d overlapping, %d nobase)\r", count + 1, valid, missed, overlap, nobaseline ); count++; if ( !FindCoords( &in[i] ) ) { missed++; } else { strcpy( name, sourcedir ); strcat( name, in[i].name ); LoadAnyImage( name, &pixels, NULL, &width, &height ); CheckBaseline( i ); CheckOverlap( &in[i] ); CopyToMain32( &in[i] ); SetUsageMap( &in[i] ); } } } }
// Action_CheckStructure::DoAction() Action::RetType Action_CheckStructure::DoAction(int frameNum, ActionFrame& frm) { int total_problems = CheckOverlap(frameNum+1, frm.Frm(), *CurrentParm_); if (bondcheck_) total_problems += CheckBonds(frameNum+1, frm.Frm(), *CurrentParm_); if (total_problems > 0 && skipBadFrames_) return Action::SUPPRESS_COORD_OUTPUT; return Action::OK; }
BoundingBox CalcOverlap(BoundingBox rhs) { if (!CheckOverlap(rhs)) { return {0, 0, 0, 0}; } BoundingBox ret; ret.x = std::max(x, rhs.x); ret.y = std::max(y, rhs.y); ret.w = std::min(x+w, rhs.x+rhs.w) - ret.x; ret.h = std::min(y+h, rhs.y+rhs.h) - ret.y; return ret; }
BoundingBox BoundingBox::CalcOverlap(BoundingBox rhs) { //TODO: improve efficiency if (!CheckOverlap(rhs)) { return {0, 0, 0, 0}; } BoundingBox ret; ret.x = std::max(x, rhs.x); ret.y = std::max(y, rhs.y); ret.w = std::min(x+w, rhs.x+rhs.w) - ret.x; ret.h = std::min(y+h, rhs.y+rhs.h) - ret.y; return ret; }
// adds an alignment to the set bool CNaiveAlignmentSet::Add(Alignment& al) { // check if this is a long alignment const unsigned short pairwiseLength = (unsigned short)al.Reference.Length(); if((al.QueryEnd > 255) || (pairwiseLength > 255)) mHasLongAlignment = true; // check to see if any of the other entries are similar bool foundSubset = false; AlignmentSet::iterator setIter; // TODO: update this with an interval tree if(!mAlignments.empty()) { for(setIter = mAlignments.begin(); setIter != mAlignments.end(); setIter++) { if(CheckOverlap(al, setIter)) { foundSubset = true; break; } } } // add the alignment to the alignment set if(!foundSubset) { mAlignments.push_back(al); if ( al.SwScore > highestSmithWatermanScore ) highestSmithWatermanScore = al.SwScore; return true; } // handle the subset: choose the bigger alignment //unsigned int alLen = al.ReferenceEnd - al.ReferenceBegin + 1; //unsigned int axLen = setIter->ReferenceEnd - setIter->ReferenceBegin + 1; //if(alLen > axLen) *setIter = al; if ( al.SwScore > setIter->SwScore ) { *setIter = al; if ( al.SwScore > highestSmithWatermanScore ) highestSmithWatermanScore = al.SwScore; } return false; }
void PhysicsWorld::FindAllCollisions() { contactManager.numOldContacts = contactManager.numContacts; assert(contactManager.numOldContacts < MaxNumContacts ); memcpy(contactManager.oldContacts, contactManager.contacts, contactManager.numOldContacts * sizeof(Contact)); contactManager.numContacts = 0; /* O(n^2) collsion detection ( or worse LOL ) Check all fixtures vs all fixtures for collisions, We dont collide fixtures that are from the same body */ for ( size_t i = 0; i < numBodies; i++ ) { for ( size_t j = i + 1; j < numBodies; j++ ) { if ( (bodies[i]->type != eDynamic && bodies[j]->type != eDynamic) ) { continue; } if ( contactManager.contactFilter && !contactManager.contactFilter->ShouldCollide(bodies[i], bodies[j]) ) { continue; } Fixture *fi = bodies[i]->GetFixtureList(); while ( fi ) { Fixture *fj = bodies[j]->GetFixtureList(); while ( fj ) { if ( fi->IsSensor( ) || fj->IsSensor( ) ) { if ( CheckOverlap(fi->GetShape(), bodies[i]->GetPosition(), fj->GetShape(), bodies[j]->GetPosition()) ) { contactManager.contactListener->OnSensor(fi, fj); } } else { // check collision and add to the contact list if they intersect contactManager.AddPair(fi, fj); } fj = fj->GetNext(); } fi = fi->GetNext(); } } } contactManager.MergeContacts(); }
//--------------------------------------------------------------------------- void __fastcall TFileViewDlg::OnMove(TMessage *Message) { CheckOverlap(); }