void ofxSimplifyPath(ofPath &path, int iterations, float amount, float distance) { //wat doet amount?? should be distance??? for (int iteration=0; iteration<iterations; iteration++) { vector<ofSubPath> &subpaths = path.getSubPaths(); for (int i=0; i<subpaths.size(); i++) { vector<ofSubPath::Command> &commands = subpaths[i].getCommands(); if (commands.size()<amount) continue; for (int j=1; j<commands.size()-2; j++) { //laat eerste en laatste punt met rust if (commands[j].to.distance(commands[j+1].to)<distance) { commands[j].to = (commands[j].to+commands[j+1].to)/2; commands.erase(commands.begin()+j+1); } } } } path.flagShapeChanged(); }
void ofxSimplifyPath(ofPath &path, int iterations, float amount) { for (int iteration=0; iteration<iterations; iteration++) { vector<ofSubPath> &subpaths = path.getSubPaths(); for (int i=0; i<subpaths.size(); i++) { vector<ofSubPath::Command> &commands = subpaths[i].getCommands(); if (commands.size()<amount) continue; for (int j=0; j<commands.size()-1; j++) { if (commands[j].to.distance(commands[j+1].to)<3) { commands[j].to = (commands[j].to+commands[j+1].to)/2; commands.erase(commands.begin()+j+1); } } } } path.flagShapeChanged(); }
void keyPressed(int key) { switch (key) { case '/': case '\\': case '$': case '#': case '|': case '%': case '@': case '^': case '&': case '_': side.setShape(key); break; case '3': side.is3D=!side.is3D; break; case '<': twists-=.5; break; case '>': twists+=.5; break; case '\'': twists=0; break; case '?': showHelp(); break; case 'a': side.toggle(); break; case 'b': useSubpathColors=!useSubpathColors; break; case 'C': canvas.createCircle(); break; case 'c': canvas.clear(); files.unloadFile(); break; case 'd': debug=!debug; refreshDebugInfo(); break; case 'e': print(true); break; case 'f': ofToggleFullscreen(); break; case 'k': path.setFilled(!path.isFilled()); path.flagShapeChanged(); break; case 'h': objectHeight+=5; if (objectHeight>maxObjectHeight) objectHeight=maxObjectHeight; break; case 'H': objectHeight-=5; if (objectHeight<3) objectHeight=3; break; case 'G': ultimaker.sendCommand("G28 X0 Y0 Z0\nM84",2); break; case 'A': ultimaker.sendCommand("M84"); break; case 'T': ultimaker.sendCommand("M109 S230"); break; case 'l': files.loadNext(); break; case 'L': files.loadPrevious(); break; case 'o': files.load(); break; case 'p': case 'm': case OF_KEY_RETURN: print(); break; case 'q': stop(); break; // case 'r': ultimaker.setRelative(); break; case 'S': files.save(); break; case 's': files.saveAs(); break; case '`': showSubPathLines=!showSubPathLines; case 't': ultimaker.sendCommand("M105",1); break; case 'u': case 'z': canvas.undo(); break; case '~': files.deleteCurrentFile(); break; case ' ': files.listDir(); break; case 'x': files.saveSvg(resourceFolder+"template.svg",documentFolder+"output.svg"); break; case 27: if (ultimaker.isThreadRunning()) ultimaker.stopThread(); break; case 'n': cloneApp(); break; //run new instance of Doodle3D case 'i': cout << getNumInstances() << endl; break; } }