Pwh_list_2 GDALParceling::splitter(Polygon_2 &rect) { Pwh_list_2 ress; Point_2 p1 = rect.vertex(0); Point_2 p2 = rect.vertex(1); Point_2 p3 = rect.vertex(2); Point_2 p4 = rect.vertex(3); Vector_2 v1 = (p2-p1)/2; Vector_2 v2 = (p3-p2)/2; bool v1_bigger = true; if (v1.squared_length() < v2.squared_length()) { v1_bigger = false; } //Left if (v1_bigger && v1.squared_length() >= this->length*this->length) { split_left(p3, ress, p2, p4, p1, v1); return ress; } if (!v1_bigger && v2.squared_length() >= this->length*this->length) { split_up(ress, p3, p1, p4, v2, p2); return ress; } if (v1_bigger && v2.squared_length() >= this->width*this->width){ split_up(ress, p3, p1, p4, v2, p2); return ress; } if (!v1_bigger && v1.squared_length() >= this->width*this->width){ split_left(p3, ress, p2, p4, p1, v1); return ress; } return ress; }
static int split_init(struct saucy *s, struct coloring *c, int cf, int ff) { split_left(s, c, cf, ff); /* Maintain nonsingleton list for finding new targets */ if (c->clen[ff]) { s->prevnon[s->nextnon[cf]] = ff; s->nextnon[ff] = s->nextnon[cf]; s->prevnon[ff] = cf; s->nextnon[cf] = ff; } if (!c->clen[cf]) { s->nextnon[s->prevnon[cf]] = s->nextnon[cf]; s->prevnon[s->nextnon[cf]] = s->prevnon[cf]; } /* Always succeeds */ return 1; }