// It's slightly awkward, but we assume that the PointSet we're // given is constant for rest of DAG; DirectedGraph::DirectedGraph(const PointSetArray& inputPointSet) { // TODO: If keep a separate copy of inputPointSet, // then wouldn't need delaunay.cpp to use `- 3` magic. // XXX Should use copy-c'tor for PointSetArray (test first?). // Copy points from the input set to Delaunay point set for (int i = 1; i <= inputPointSet.noPt(); i++) { LongInt x, y; inputPointSet.getPoint(i, x, y); pointSet_.addPoint(x, y); } int numPoints = pointSet_.noPt(); // Add a triangle which bounds all the points. findBoundingTri(pointSet_); // Construct root DAGNode as the bounding triangle. // (Delaunay Iteration algorithm can 'add' the 'actual' points, // which is also slightly awkward, but whatever). // Points of bounding tri are the last three, // so, numPoints+1, numPoints+2, numPoints+3 int boundingTriPt1 = numPoints + 1; TriRecord boundingTri(boundingTriPt1, boundingTriPt1 + 1, boundingTriPt1 + 2); root_ = shared_ptr<DAGNode>(new DAGNode(boundingTri)); root_->fIndex_ = trist_.addLinkedTri(boundingTri); dagNodes_.push_back(root_); }
void drawPointSetArray(const PointSetArray& pointSet) { // Draw input points for (int i = 1; i <= pointSet.noPt(); i++){ LongInt px, py; pointSet.getPoint(i, px, py); drawAPoint(px.doubleValue(), py.doubleValue()); } }
void display(void) { int i, ix1, ix2, ix3; LongInt x1,y1; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); for (i=1;i<=myTrist.noTri();i++){ myTrist.getVertexIdx(i<<3,ix1,ix2,ix3); drawATriangle(ix1,ix2,ix3); } for (i=1;i<=myPointSet.noPt();i++){ myPointSet.getPoint(i,x1,y1); drawAPoint(atof(x1.printOut().c_str()),atof(y1.printOut().c_str())); } glPopMatrix(); glutSwapBuffers (); }