//-------------------------------------------------------------- void testApp::keyPressed (int key){ if(key=='c'){ if(drawNodesAndEdges){ drawNodesAndEdges=false; } else{ drawNodesAndEdges=true; } } if(key==' '){ doTriangulation(numPoints); } if(key=='a'){ if(curStep<8){ curStep++; doTriangulation(numPoints); }; } }
//-------------------------------------------------------------- void testApp::setup(){ ofBackground(20,186,204); ofEnableSmoothing(); ofSetCircleResolution(100); circleOut.radius = (ofGetHeight() - 200)/2.0; circleInner.radius = circleOut.radius - 225; circleOut.xPos = ofGetWidth()/2.0; circleOut.yPos = ofGetHeight()/2.0; circleInner.xPos = circleOut.xPos; circleInner.yPos = circleOut.yPos; createApprox(); generateNoisePoints(); numSteps = 8; numPoints = 1040/numSteps; curStep = 0; //add generic clearing and generation of everything doTriangulation(numPoints); c1 = ofColor(10,10,10); c2 = ofColor(250,250,250); drawNodesAndEdges = false; capture = false; }
void ofxPoly2Tri::triangulate(ofMesh bounds) { vector<p2t::Point*> bound; vector<ofPoint>edgepoints = bounds.getVertices(); for (int i=0;i<edgepoints.size();++i) { bound.push_back(new p2t::Point(edgepoints[i].x,edgepoints[i].y)); } doTriangulation(bound); //clear the vector again for (vector<p2t::Point*>::iterator it = bound.begin(); it != bound.end(); ++it) { delete *it; } }
Triangulation::Triangulation(std::vector<std::array<double, 2> > pts) { points = pts; doTriangulation(); }