//private bool Slice::TestIntersection(QVector2D &vec,Segment* seg1, Segment* seg2) { bool intersection; // return false; intersection= SegmentIntersection(vec, seg1->p1, seg1->p2, seg2->p1, seg2->p2); if(intersection) { if(IsZero(Distance2D(seg1->p2, seg2->p1),0.001) || IsZero(Distance2D(seg1->p1, seg2->p2),0.001)) return false; if(IsZero(Distance2D(seg1->p1, seg2->p1),0.001) || IsZero(Distance2D(seg1->p2, seg2->p2),0.001)) return false; return true; } return false; }
bool Loop::AttemptSplitUp(Slice* pslice) { unsigned int s1; unsigned int s2; unsigned int s; QVector2D intersectpoint; Segment* currSeg; std::vector<Segment*> keeplist; for(s1 = 0; s1 < segListp.size(); s1++) { for(s2 = 0; s2 < segListp.size(); s2++) { if(s1 == s2) continue; if(segListp[s2] == segListp[s1]->leadingSeg || segListp[s2] == segListp[s1]->trailingSeg) continue; if(SegmentsAffiliated(segListp[s1], segListp[s2], 0.00001)) continue; if(SegmentIntersection(intersectpoint, segListp[s1]->p1, segListp[s1]->p2, segListp[s2]->p1, segListp[s2]->p2)) { Segment* seg1 = new Segment(intersectpoint, segListp[s1]->p2); Segment* seg2 = new Segment(segListp[s2]->p1, intersectpoint); seg1->trailingSeg = seg2; seg2->leadingSeg = seg1; seg1->leadingSeg = segListp[s1]->leadingSeg; seg2->trailingSeg = segListp[s2]->trailingSeg; segListp[s1]->leadingSeg->trailingSeg = seg1; segListp[s2]->trailingSeg->leadingSeg = seg2; segListp[s1]->p2 = intersectpoint; segListp[s2]->p1 = intersectpoint; segListp[s1]->FormNormal(); segListp[s2]->FormNormal(); segListp[s1]->leadingSeg = segListp[s2]; segListp[s2]->trailingSeg = segListp[s1]; pslice->segmentList.push_back(seg1); pslice->segmentList.push_back(seg2); segListp.push_back(seg1); segListp.push_back(seg2); currSeg = seg1; //fill the list of segments for the new loop do { currSeg->pLoop = NULL; currSeg->chucked = true; currSeg = currSeg->leadingSeg; } while(currSeg != seg1); keeplist.clear(); for(s = 0; s < segListp.size(); s++) { if(segListp[s]->chucked) { segListp[s]->chucked = false; } else { keeplist.push_back(segListp[s]); } } segListp.clear(); segListp = keeplist; numSegs = segListp.size(); //make a new loop, growing it off of the seg1; Loop newLoop(seg1->leadingSeg, pslice); if(newLoop.Grow() >= 3) { pSlice->loopList.push_back(newLoop); } else { newLoop.Destroy(); } return true; } } } return false; }