static void loopTheLoop(std::list<GEdge*> &wire, std::list<GEdgeSigned> &loop, GEdge **degeneratedToInsert) { GEdgeSigned *prevOne = 0; GEdgeSigned ges(0,0); while(wire.size()){ if (prevOne && (*degeneratedToInsert) && (*degeneratedToInsert)->getBeginVertex () == prevOne->getEndVertex()){ ges = GEdgeSigned(1,*degeneratedToInsert); *degeneratedToInsert = 0; // printf("second degenerated edge inserted\n"); } else ges = nextOne(prevOne, wire); if(ges.getSign() == 0){ // oops if (0){ Msg::Error("Something wrong in edge loop of size=%d, no sign !", wire.size()); for (std::list<GEdge* >::iterator it = wire.begin(); it != wire.end(); it++){ Msg::Error("GEdge=%d begin=%d end =%d", (*it)->tag(), (*it)->getBeginVertex()->tag(), (*it)->getEndVertex()->tag()); } } break; } prevOne = ⩾ // ges.print(); loop.push_back(ges); } }
static void loopTheLoop(std::list<GEdge *> &wire, std::list<GEdgeSigned> &loop, GEdge **degeneratedToInsert) { GEdgeSigned *prevOne = 0; GEdgeSigned ges(0, 0); while(wire.size()) { if(prevOne && (*degeneratedToInsert) && (*degeneratedToInsert)->getBeginVertex() == prevOne->getEndVertex()) { ges = GEdgeSigned(1, *degeneratedToInsert); *degeneratedToInsert = 0; // printf("second degenerated edge inserted\n"); } else ges = nextOne(prevOne, wire); if(ges.getSign() == 0) { // oops Msg::Warning("Something wrong in curve loop of size=%d, no sign!", wire.size()); break; } prevOne = ⩾ // ges.print(); loop.push_back(ges); } }
GEdgeSigned nextOne(GEdgeSigned *thisOne, std::list<GEdge*> &wire) { if(!thisOne){ GEdge *ge = *(wire.begin()); wire.erase(wire.begin()); return GEdgeSigned(1, ge); } GVertex *gv = thisOne->getEndVertex(); std::list<GEdge*> possibleChoices; std::list<GEdge*>::iterator it = wire.begin(); std::list<GEdge*>::iterator ite = wire.end(); while(it != ite){ GEdge *ge = *it; GVertex *v1 = ge->getBeginVertex(); GVertex *v2 = ge->getEndVertex(); if(v1 == gv || v2 == gv) possibleChoices.push_back(ge); ++it; } it = possibleChoices.begin(); ite = possibleChoices.end(); while(it != ite){ GEdge *ge = *it; if(countInList(possibleChoices, ge) == 2){ wire.erase(std::remove_if(wire.begin(), wire.end(), std::bind2nd(std::equal_to<GEdge*>(), ge)), wire.end()); wire.push_back(ge); GVertex *v1 = ge->getBeginVertex(); GVertex *v2 = ge->getEndVertex(); if(v1 == gv) return GEdgeSigned(1, ge); if(v2 == gv) return GEdgeSigned(-1, ge); Msg::Error("Something wrong in edge loop 1"); thisOne->print(); } ++it; } it = possibleChoices.begin(); ite = possibleChoices.end(); while(it != ite){ GEdge *ge = *it; if(ge != thisOne->ge){ wire.erase(std::remove_if(wire.begin(),wire.end(), std::bind2nd(std::equal_to<GEdge*>(), ge)), wire.end()); GVertex *v1 = ge->getBeginVertex(); GVertex *v2 = ge->getEndVertex(); if(v1 == gv) return GEdgeSigned(1, ge); if(v2 == gv) return GEdgeSigned(-1, ge); Msg::Error("Something wrong in edge loop 2"); thisOne->print(); } ++it; } // should never end up here return GEdgeSigned(0, 0); }