void
CGDBGraspProcessor::run()
{
	std::vector<db_planner::Model*> models;
	//get the old-style for which the McGrip grasps work
	mDbMgr->ModelList(&models, db_planner::FilterList::OLD_STYLE_IV);
	std::vector<db_planner::Model*>::iterator it;
	GraspableBody *currentModel = NULL;
	//reset the stats and the results
	mProcessor->reset();
	for (it=models.begin(); it!=models.end(); it++) {
		if (mMaxGrasps >=0 && mProcessedGrasps >= mMaxGrasps) break;

		//delete the previous model; careful, don't delete it
		if (currentModel) {
			mHand->getWorld()->destroyElement(currentModel, false);
			currentModel = NULL;
		}
		GraspitDBModel *gModel = dynamic_cast<GraspitDBModel*>(*it);
		if (!gModel) {
			assert(0);
			continue;
		}
		//load the current model
		if (!gModel->geometryLoaded()) {
			gModel->load(mHand->getWorld());
		}
		gModel->getGraspableBody()->addToIvc();
		mHand->getWorld()->addBody(gModel->getGraspableBody());
		currentModel = gModel->getGraspableBody();
		//get all the grasps
		std::vector<db_planner::Grasp*> grasps;
		if(!mDbMgr->GetGrasps(*gModel,mHand->getDBName().toStdString(), &grasps)){
			DBGP("Load grasps failed - no grasps found for model " << gModel->ModelName());
			continue;
		}
		//keep the human ones
		std::vector<db_planner::Grasp*>::iterator it2 = grasps.begin();
		while (it2!=grasps.end()) {
			if( QString((*it2)->GetSource().c_str()) == "HUMAN_REFINED") {
				it2++;
			} else {
				delete (*it2);
				it2 = grasps.erase(it2);
			}
		}
		//and process them
		processGrasps(&grasps);
		//clean up
		while (!grasps.empty()) {
			delete grasps.back();
			grasps.pop_back();
		}
	}

	mProcessor->finalize();

	if (currentModel) {
		mHand->getWorld()->destroyElement(currentModel, false);
	}
	while(!models.empty()) {
		DBGA("Deleting model");
		delete models.back();
		DBGA("Model deleted");
		models.pop_back();
	}
}