void Curve::TraceBoundary(HalfEdge * startHe, Vertex * endV) { HalfEdge * che = startHe; if (!che->source()->boundary() || !che->target()->boundary()) { std::cerr << "Error: the input halfedge is not on the boundary!" << std::endl; return; } bool ccw; Vertex * ver = che->source(); HalfEdge * the = ver->most_ccw_out_halfedge(); if (the == che) { //Possiblly ccw is right, except the case that there is only one out halfedge starting from ver //in that case, check one more step forward is enough HalfEdge * tempthe = the->target()->most_ccw_out_halfedge(); if (tempthe->edge()->boundary()) ccw = true; else { assert(ver->most_ccw_out_halfedge() == ver->most_clw_out_halfedge()); ccw = false; } } else { ccw = false; the = ver->most_clw_out_halfedge(); assert(the == che); } the = che; std::vector<HalfEdge *>::iterator finditer; while (the->vertex() != endV) { helist.push_back(the); if (ccw) the = the->target()->most_ccw_out_halfedge(); else the = the->target()->most_clw_out_halfedge(); if (helist.size()>10000000) { assert(0); } } }