/*public*/ string LineIntersector::toString() const { string str=inputLines[0][0]->toString()+"_" +inputLines[0][1]->toString()+" " +inputLines[1][0]->toString()+"_" +inputLines[1][1]->toString()+" : "; if (isEndPoint()) { str+=" endpoint"; } if (isProperVar) { str+=" proper"; } if (isCollinear()) { str+=" collinear"; } return str; }
// // Swap the common edge between two triangles t1 and t2. The common // edge should always be edge ac, abc are part of t1 and acd are part // of t2. // void edgeSwap(TRIANGLE *t1, TRIANGLE *t2, R_POINT *a, R_POINT *b, R_POINT *c, R_POINT *d, double e, TIN_TILE *tt){ // Common edge must be ac assert(isEndPoint(t1,a) && isEndPoint(t1,b) && isEndPoint(t1,c) && isEndPoint(t2,a) && isEndPoint(t2,c) && isEndPoint(t2,d)); assert(a != b && a != c && a != d && b != c && b != d && c != d); assert(t1 != t2); // Add the two new triangles with the swapped edge TRIANGLE *tn1, *tn2; tn1 = addTri(tt,a, b, d,whichTri(t1,a,b,tt),whichTri(t2,a,d,tt),NULL); tn2 = addTri(tt,c, b, d,whichTri(t1,c,b,tt),whichTri(t2,c,d,tt),tn1); assert(isEndPoint(tn1,a) && isEndPoint(tn1,b) && isEndPoint(tn1,d) && isEndPoint(tn2,b) && isEndPoint(tn2,c) && isEndPoint(tn2,d)); assert(tn1->p2p3 == tn2 && tn2->p2p3 == tn1); if(tn1->p1p2 != NULL) assert(whichTri(tn1->p1p2,a,b,tt) == tn1); if(tn1->p1p3 != NULL) assert(whichTri(tn1->p1p3,a,d,tt) == tn1); if(tn2->p1p2 != NULL) assert(whichTri(tn2->p1p2,c,b,tt) == tn2); if(tn2->p1p3 != NULL) assert(whichTri(tn2->p1p3,c,d,tt) == tn2); // Debug DEBUG{ printf("EdgeSwap: \n"); printTriangle(t1); printTriangle(t2); printTriangle(tn1); printTriangle(tn2); } // Distribute point list from t1 and t2 to tn1 and tn2. Distribute // points requires that the fourth argument (s) be a valid triangle // with a point list so we must check that t1 and t2 are not already // done and thus do not have a point list. If at least one does then // call distribute points with s = the trinagle with the valid point // list. If both are done then the newly created triangles are done // tooand need to be marked accordingly if(t1->maxE != DONE && t2->maxE != DONE) distrPoints(tn1,tn2,NULL,t1,t2,e,tt); else if(t1->maxE != DONE){ distrPoints(tn1,tn2,NULL,t1,NULL,e,tt); } else if(t2->maxE != DONE){ distrPoints(tn1,tn2,NULL,t2,NULL,e,tt); } else{ tn1->maxE = tn2->maxE = DONE; tn1->points = tn2->points= NULL; } // Update the corner if the corner is being swapped. Distrpoints // will not always catch this so it must be done here if(t1 == tt->t || t2 == tt->t){ updateTinTileCorner(tt,tn1,tn2,NULL); } // mark triangles for deletion from the PQ t1->p1p2 = t1->p1p3 = t1->p2p3 = NULL; t2->p1p2 = t2->p1p3 = t2->p2p3 = NULL; PQ_delete(tt->pq,t1->pqIndex); PQ_delete(tt->pq,t2->pqIndex); removeTri(t1); removeTri(t2); DEBUG{checkPointList(tn1); checkPointList(tn2);} // We have created two different triangles, we need to check // delaunay on their 2 edges enforceDelaunay(tn1,a,d,b,e,tt); enforceDelaunay(tn2,c,d,b,e,tt); }