LinkDialogGraphicsScene::LinkDialogGraphicsScene(QWidget* parent, ProcessorNetwork* network, Processor* srcProcessor, Processor* dstProcessor) : QGraphicsScene(parent) , currentScrollSteps_(0) , linkCurve_(nullptr) , startProperty_(nullptr) , endProperty_(nullptr) , srcProcessor_(nullptr) , dstProcessor_(nullptr) , network_(network) , expandProperties_(false) , mouseOnLeftSide_(false) { // The default bsp tends to crash... setItemIndexMethod(QGraphicsScene::NoIndex); network_->addObserver(this); srcProcessor_ = new LinkDialogProcessorGraphicsItem(LinkDialogParent::Side::Left, srcProcessor); dstProcessor_ = new LinkDialogProcessorGraphicsItem(LinkDialogParent::Side::Right, dstProcessor); float xPos1 = linkdialog::dialogWidth / 10.0 + linkdialog::processorWidth/2; addItem(srcProcessor_); srcProcessor_->setPos(QPointF(xPos1, 2*linkdialog::processorHeight)); srcProcessor_->show(); float xPos2 = linkdialog::dialogWidth * 9.0 / 10.0 - linkdialog::processorWidth/2; addItem(dstProcessor_); dstProcessor_->setPos(QPointF(xPos2, 2*linkdialog::processorHeight)); dstProcessor_->show(); std::function<void(LinkDialogPropertyGraphicsItem*)> buildCache = [this, &buildCache]( LinkDialogPropertyGraphicsItem* item) { propertyMap_[item->getItem()] = item; for (auto i : item->getSubPropertyItemList()) { buildCache(i); } }; for (auto item : srcProcessor_->getPropertyItemList()) buildCache(item); for (auto item : dstProcessor_->getPropertyItemList()) buildCache(item); // add links auto links = network_->getLinksBetweenProcessors(srcProcessor, dstProcessor); for (auto& link : links) { initializePropertyLinkRepresentation(link); } update(); }
int loadCursor(char *path, int hotx, int hoty, float tail_dist, float angle) { if (buildCache(path) != 0) return 1; // create a cursor image and set it wormy.xci = XcursorImageCreate (2*wormy.radius, 2*wormy.radius); wormy.xci->xhot = (2.0*wormy.radius-wormy.width)/2 + hotx; wormy.xci->yhot = (2.0*wormy.radius-wormy.height)/2 + hoty; wormy.xci->pixels = wormy.cache[0]; wormy.original = XCreateFontCursor(wormy.disp, XC_left_ptr); XDefineCursor(wormy.disp, DefaultRootWindow(wormy.disp), wormy.original); wormy.cursor = XcursorImageLoadCursor(wormy.disp, wormy.xci); XFixesChangeCursor(wormy.disp, wormy.cursor, wormy.original); // using cairo coordinates (inverted y axis) wormy.hot_a = atan2f(wormy.xci->yhot - wormy.radius, wormy.xci->xhot - wormy.radius); wormy.hot_d = sqrt((wormy.xci->xhot - wormy.radius) * (wormy.xci->xhot - wormy.radius) + (wormy.xci->yhot - wormy.radius) * (wormy.xci->yhot - wormy.radius)); wormy.tail_d = tail_dist; wormy.angle = angle * M_PI / 180.0; return 0; }
void CachingPyramidFeatureExtractor::update(shared_ptr<VersionedImage> image) { extractor->update(image); if (version != image->getVersion()) { buildCache(); version = image->getVersion(); } }
void Daemon::becomeChild( Channel rope ) { net().unbind(); _state = State::Grouped; _rope = std::move( rope ); _rope->rank( rank() ); Logger::becomeChild(); Logger::log( "child born" ); buildCache(); }
MStatus vixo_hairCacheExport::doIt(const MArgList& args) { MString vixoHairNode; int startFrame,endFrame; unsigned index; index=args.flagIndex("vhn","vixoHairNode"); if(MArgList::kInvalidArgIndex!=index) { args.get(index+1,vixoHairNode); } index=args.flagIndex("sf","startFrame"); if(MArgList::kInvalidArgIndex!=index) { args.get(index+1,startFrame); } index=args.flagIndex("ef","endFrame"); if(MArgList::kInvalidArgIndex!=index) { args.get(index+1,endFrame); } //get hairCacheFileName MSelectionList slist; MGlobal::getSelectionListByName(vixoHairNode,slist); MDagPath vixoHairNodeDag; slist.getDagPath(0,vixoHairNodeDag); vixoHairNodeDag.extendToShape(); MFnDagNode fnVixoHair(vixoHairNodeDag); MPlug plugCacheFileName=fnVixoHair.findPlug("hairCacheFileName"); MString cacheFileName=plugCacheFileName.asString(); //~get hairCacheFileName //get staticMesh MPlug plugStaticMesh=fnVixoHair.findPlug("staticInMesh"); MObject staticMeshObj=MFnMeshData(plugStaticMesh.asMObject()).object(); //~get staticMesh //build out dataBase MFnMesh fnStaticMesh(staticMeshObj); map<int,set<outInVertexRelationInfo>> outVertexDataBase; map<int,vector<outVIDCtrlInfo>> outVertexControlData; for(int i=0;i<fnStaticMesh.numVertices();i++) { set<outInVertexRelationInfo> temp; temp.clear(); outVertexDataBase.insert(pair<int,set<outInVertexRelationInfo>>(i,temp)); } //build out dataBase //get inCurveVID map<int,int> plugMapVID; map<int,int> VIDMapPlug; map<int,inVertexBasicInfo> inVIDMapInVertexDataBase; MPlug plugAllInCurve=fnVixoHair.findPlug("inCtrlCurveData"); MIntArray existIndex; plugAllInCurve.getExistingArrayAttributeIndices(existIndex); for(int i=0;i<existIndex.length();i++) { MPlugArray arr; plugAllInCurve.elementByLogicalIndex(existIndex[i]).connectedTo(arr,true,false); MFnDependencyNode fnHairSystem(arr[0].node()); MPlug inputHairs=fnHairSystem.findPlug("inputHair"); arr.clear(); inputHairs.elementByLogicalIndex(existIndex[i]).connectedTo(arr,true,false); MFnDependencyNode fnFolli(arr[0].node()); int vid=fnFolli.findPlug("vertexID").asInt(); plugMapVID.insert(pair<int,int>(existIndex[i],vid)); VIDMapPlug.insert(pair<int,int>(vid,existIndex[i])); initBasicStepInfo(vid,staticMeshObj,inVIDMapInVertexDataBase); } //~get inCurveVID //build in out relation map<int,inVertexBasicInfo>::iterator inDBIter; for(inDBIter=inVIDMapInVertexDataBase.begin();inDBIter!=inVIDMapInVertexDataBase.end();inDBIter++) { buileRelationBetweenInOut(inDBIter->first,inVIDMapInVertexDataBase,outVertexDataBase); } map<int,set<outInVertexRelationInfo>>::iterator outDBIter; for(outDBIter=outVertexDataBase.begin();outDBIter!=outVertexDataBase.end();outDBIter++) { sortControlOrder(outDBIter->first,outVertexDataBase,outVertexControlData); } //~build in out relation for(int i=startFrame;i<=endFrame;i++) { MString currentTime; currentTime.set(i); MGlobal::executeCommand("currentTime "+currentTime); MGlobal::executeCommand("dgeval "+vixoHairNode+".hiddenOutput"); //get dynamic mesh MPlug plugDynamicMesh=fnVixoHair.findPlug("dynamicInMesh"); MObject dynamicMeshObj=MFnMeshData(plugDynamicMesh.asMObject()).object(); //~get dynamic mesh //export cache //faceid triid vid position normal tangent vector<forExportHairCache> exportData; exportBasicData(dynamicMeshObj,exportData); //curve tangent //get in curve infos map<int,MVectorArray> inCurveShape; getInCurveInfo(plugMapVID,vixoHairNode,inCurveShape); //~get in curve infos vector<vec3> outCurveCacheData; vec3 init; init.x=0; init.y=0; init.z=0; outCurveCacheData.resize(fnStaticMesh.numVertices()*inCurveShape.begin()->second.length(),init); buildCache(inCurveShape.begin()->second.length(),dynamicMeshObj,outCurveCacheData,inCurveShape,outVertexControlData); //~export cache //write to file MString fileName=getFileName(cacheFileName,i); fstream fout(fileName.asChar(),ios_base::out|ios_base::binary); int triNumvertexNum[3]; triNumvertexNum[0]=exportData.size(); triNumvertexNum[1]=fnStaticMesh.numVertices(); triNumvertexNum[2]=inCurveShape.begin()->second.length(); fout.write((char*)triNumvertexNum,sizeof(int)*3); fout.write((char*)&exportData[0],sizeof(forExportHairCache)*exportData.size()); fout.write((char*)&outCurveCacheData[0],sizeof(vec3)*outCurveCacheData.size()); fout.flush(); fout.close(); /* MString fileNameDebug=fileName+".dbg"; fout.open(fileNameDebug.asChar(),ios_base::out); for(int i=0;i<outCurveCacheData.size();i++) { fout<<outCurveCacheData[i].x<<" "<<outCurveCacheData[i].y<<" "<<outCurveCacheData[i].z<<endl; } fout.flush(); fout.close(); */ //~write to file } return MS::kSuccess; }
int main(int argc, const char * argv[]) { int i; FILE *trace = NULL; for (i = 0; i < argc; i++) { char arg = *++argv[i]; switch (arg) { case 'h': help = 1; break; case 'v': verbose = 1; break; case 's': sbits = atoi(argv[i+1]); S = 1 << sbits; break; case 'E': E = atoi(argv[i+1]); break; case 'b': bbits = atoi(argv[i+1]); break; case 't': trace = fopen(argv[i+1], "r"); break; default: break; } } if (help == 1) { printHelpAndExit(argv[0]); } CacheSet cacheSets[S]; buildCache(cacheSets); if (trace != NULL) { long address; int bufLen = 30; char buffer[bufLen], instruction, blockSize; while (fgets(buffer, bufLen, trace) != NULL) { sscanf(buffer, " %c %lx,%c", &instruction, &address, &blockSize); if (instruction != INSTRUCTION) { for (i = 0; i < bufLen; i++) { if (buffer[i] == '\n') { buffer[i] = '\0'; } } char hitType = 0; if (instruction == MODIFY) { for (i = 0; i < 2; i++) { hitType += cacheOperation(cacheSets, address); } } else { hitType = cacheOperation(cacheSets, address); } if (verbose == 1) { printVerbose(hitType, buffer); } } } fclose(trace); } else { printf("Error: Must specify trace file, see usage\n"); printHelpAndExit(argv[0]); } for (i = 0; i < S; i++) { free(cacheSets[i].lines); } printSummary(hits, misses, evictions); return 0; }
/*Main function to run the cache simulator *@return 0 if success, 1 if fail */ int main(int argc, char** argv) { int verbose = 0; // verbose flag int s; // Number of set index bits int E; // Number of lines per set int b; // Number of block bits char* trace; //the trace file name cache* Cache; char c; while ((c = getopt(argc, argv, "s:E:b:t:vh")) != -1){ switch(c){ case 's': s = atoi(optarg); break; case 'E': E = atoi(optarg); break; case 'b': b = atoi(optarg); break; case 't': trace = optarg; break; case 'v': verbose = 1; break; case 'h': printUsage(); exit(0); default: printUsage(); exit(1); } } if (s == 0 || E == 0 || b == 0 || trace == NULL){ puts("Missing arguments"); printUsage(); return 1; } //Create the cache Cache = buildCache(s, E, b); //Read from the trace memAddr address; char act; int byteSize; FILE * traceFile = fopen(trace, "r"); //initilize cache tracker cacheParam param; param.s = s; param.b= b; param.E = E; param.S = 1 << s; param.B = 1 << b; param.hit =0; param.miss = 0; param.evict = 0; //Usage int state, state1, state2; if (traceFile != NULL) { while (fscanf(traceFile, " %c %llx,%d", &act, &address, &byteSize) == 3){ switch(act){ case 'I': break; case 'L': param = rSim(Cache, param, address, &state); if (verbose == 1) { printf("%c %llx,%d", act, address, byteSize); printState(state); printf("\n"); } break; case 'S': param = rSim(Cache, param, address, &state); if (verbose == 1) { printf("%c %llx,%d", act, address, byteSize); printState(state); printf("\n"); } break; case 'M': param = rSim(Cache, param, address, &state1); param = rSim(Cache, param, address, &state2); if (verbose == 1) { printf("%c %llx,%d", act, address, byteSize); printState(state1); printState(state2); printf("\n"); } break; default: break; } } } printSummary(param.hit, param.miss, param.evict); return 0; }