static void split_stripe(pdf_tensor_patch *p, pdf_tensor_patch *s0, pdf_tensor_patch *s1) { /* split all horizontal bezier curves in patch, creating two new patches with half the width. */ split_curve(&p->pole[0][0], &s0->pole[0][0], &s1->pole[0][0], 4); split_curve(&p->pole[0][1], &s0->pole[0][1], &s1->pole[0][1], 4); split_curve(&p->pole[0][2], &s0->pole[0][2], &s1->pole[0][2], 4); split_curve(&p->pole[0][3], &s0->pole[0][3], &s1->pole[0][3], 4); /* interpolate the colors for the two new patches. */ memcpy(s0->color[0], p->color[0], sizeof(s0->color[0])); memcpy(s0->color[1], p->color[1], sizeof(s0->color[1])); midcolor(s0->color[2], p->color[1], p->color[2]); midcolor(s0->color[3], p->color[0], p->color[3]); memcpy(s1->color[0], s0->color[3], sizeof(s1->color[0])); memcpy(s1->color[1], s0->color[2], sizeof(s1->color[1])); memcpy(s1->color[2], p->color[2], sizeof(s1->color[2])); memcpy(s1->color[3], p->color[3], sizeof(s1->color[3])); }
static void split_patch(pdf_tensor_patch *p, pdf_tensor_patch *s0, pdf_tensor_patch *s1) { /* split all vertical bezier curves in patch, creating two new patches with half the height. */ split_curve(p->pole[0], s0->pole[0], s1->pole[0], 1); split_curve(p->pole[1], s0->pole[1], s1->pole[1], 1); split_curve(p->pole[2], s0->pole[2], s1->pole[2], 1); split_curve(p->pole[3], s0->pole[3], s1->pole[3], 1); /* interpolate the colors for the two new patches. */ memcpy(s0->color[0], p->color[0], sizeof(s0->color[0])); midcolor(s0->color[1], p->color[0], p->color[1]); midcolor(s0->color[2], p->color[2], p->color[3]); memcpy(s0->color[3], p->color[3], sizeof(s0->color[3])); memcpy(s1->color[0], s0->color[1], sizeof(s1->color[0])); memcpy(s1->color[1], p->color[1], sizeof(s1->color[1])); memcpy(s1->color[2], p->color[2], sizeof(s1->color[2])); memcpy(s1->color[3], s0->color[2], sizeof(s1->color[3])); }
LOCAL void insert_cuts_and_bdry2d( INTERFACE *intfc, /* an orginal intfc */ double **pc) /* given corners of the subdomain */ { COMPONENT comp; CROSS *cross; CURVE **cc, *c[4]; CURVE **curves1, **curves2; POINT *p; INTERFACE *sav_intfc; NODE *n, **nn, *bn[4]; int i; sav_intfc = current_interface(); set_current_interface(intfc); comp = (intfc->modified) ? long_component(pc[0],intfc) : component(pc[0],intfc); redo_curve_list: for (cc = intfc->curves; cc && *cc; cc++) { if (is_bdry(*cc)) { (void) delete_curve(*cc); goto redo_curve_list; } } for (nn = intfc->nodes; nn && *nn; nn++) { if (is_bdry(*nn)) { int num_in, num_out; if (num_curves_at_node(*nn,&num_in,&num_out) == 0) (void) delete_node(*nn); else set_not_bdry(*nn); } } bn[0] = make_node(Point(pc[0])); bn[1] = make_node(Point(pc[2])); bn[2] = make_node(Point(pc[3])); bn[3] = make_node(Point(pc[1])); for (i = 0; i < 4; i++) { c[i] = make_curve(NO_COMP,NO_COMP,bn[i],bn[(i+1)%4]); set_is_bdry(c[0]); } if (intersections(intfc,&cross,YES) == FUNCTION_FAILED) { screen("ERROR in insert_cuts_and_bdry2d(), " "intersections() failed\n"); clean_up(ERROR); } if (cross == NULL) { for (i = 0; i < 4; i++) { positive_component(c[i]) = comp; negative_component(c[i]) = exterior_component(intfc); } return; } for (; cross != NULL; cross = cross->next) { p = cross->p; if (insert_point_in_bond(p,cross->b1,cross->c1)!=FUNCTION_SUCCEEDED) { screen("ERROR in insert_cuts_and_bdry2d(), " "insert_point_in_bond() failed\n"); clean_up(ERROR); } rcl_after_insert_point(cross,p,cross->b1); curves1 = split_curve(p,cross->b1,cross->c1, positive_component(cross->c1), negative_component(cross->c1), positive_component(cross->c1), negative_component(cross->c1)); rcl_after_split(cross,p,cross->b1,cross->c1,curves1); if (insert_point_in_bond(p,cross->b2,cross->c2)!=FUNCTION_SUCCEEDED) { screen("ERROR in insert_cuts_and_bdry2d(), " "insert_point_in_bond() failed\n"); clean_up(ERROR); } rcl_after_insert_point(cross,p,cross->b2); curves2 = split_curve(p,cross->b2,cross->c2, positive_component(cross->c2), negative_component(cross->c2), positive_component(cross->c2), negative_component(cross->c2)); rcl_after_split(cross,p,cross->b2,cross->c2,curves1); n = curves2[0]->end; change_node_of_curve(curves2[0], NEGATIVE_ORIENTATION,curves1[0]->end); change_node_of_curve(curves2[1], POSITIVE_ORIENTATION,curves1[0]->end); (void) delete_node(n); } set_current_interface(sav_intfc); return; } /*end insert_cuts_and_bdry2d*/