void ProximityMap::build(const POIvec &pois) { /* how many entries we still have to fill */ int allToDo = widet * hedet * entries, leftToDo = allToDo; int npois = (int)pois.size(); assert(npois < 65536); /* because poiid_t is unsigned short */ assert(entries <= npois); progress(0); /* this is temporary array that keeps track of how many entries were added * to each field. when the algoritm finishes, all fields have 'entries' * entries, so this array can be safely discarded */ usedEntries = Array2D<poiid_t>(widet, hedet); usedEntries.fill(0); std::priority_queue<djk> Q; for(poiid_t i=0; i<npois; i++) { int xi = roundf(pois[i].x*detail), yi = roundf(pois[i].y*detail); Q.push(djk(0, xi, yi, i)); } while(leftToDo) { assert(Q.size()); djk o = Q.top(); Q.pop(); if(!canVisit(o)) continue; pushEntry(o); leftToDo--; if(leftToDo % 20000 == 0) progress((float)(allToDo - leftToDo) / (float)allToDo); for(int dx=-1; dx<=1; dx++) for(int dy=-1; dy<=1; dy++) { djk u; u.xi = o.xi + dx; u.yi = o.yi + dy; u.id = o.id; u.dist = (Point((float)u.xi / detail, (float)u.yi / detail) - pois[u.id]).dist(); if(canVisit(u)) Q.push(u); } } /* free usedEntries' memory */ usedEntries = Array2D<poiid_t>(); }
void LipidHeadVisitor::visit(RigidBody* rb){ Vector3d pos; Vector3d u(0, 0, 1); Vector3d newVec; GenericData* data; AtomData* atomData; AtomInfo* atomInfo; bool haveAtomData; RotMat3x3d rotMatrix; if(!canVisit(rb->getType())) return; pos = rb->getPos(); rotMatrix = rb->getA(); //matVecMul3(rotMatrix, u, newVec); newVec = rotMatrix * u; data = rb->getPropertyByName("ATOMDATA"); if(data != NULL){ atomData = dynamic_cast<AtomData*>(data); if(atomData == NULL){ std::cerr << "can not get Atom Data from " << rb->getType() << std::endl; atomData = new AtomData; haveAtomData = false; } else haveAtomData = true; } else { atomData = new AtomData; haveAtomData = false; } atomInfo = new AtomInfo; atomInfo->atomTypeName = "X"; atomInfo->pos[0] = pos[0]; atomInfo->pos[1] = pos[1]; atomInfo->pos[2] = pos[2]; atomInfo->vec[0] = newVec[0]; atomInfo->vec[1] = newVec[1]; atomInfo->vec[2] = newVec[2]; atomData->addAtomInfo(atomInfo); if(!haveAtomData){ atomData->setID("ATOMDATA"); rb->addProperty(atomData); } }