Ejemplo n.º 1
0
EXPORT	bool i_intersections1d(
	INTERFACE	*intfc,
	CROSS		**cross,
	const bool	bdry)
{
	POINT   **points, **p;
	POINT   **usp;
	CROSS   *cr, Cr;
	int     i, j, k, np;

	points = intfc->points;
	if (points == NULL)
	    return FUNCTION_SUCCEEDED;
	np = intfc->num_points;
	p   = (POINT **)store(np*sizeof(POINT*));
	usp = (POINT **)store(np*sizeof(POINT*));
	for (i = 0; i < np; ++i)
	    usp[i] = p[i] = points[i];

	sort_point_list(p,np);

	Cr.prev = NULL;
	Cr.next = NULL;
	cr = &Cr;
	for (i = 0; i < np; ++i)
	{
	    if (is_bdry(p[i]) && !bdry)
		continue;
	    if (p[i] != usp[i])
	    {
		for (j = i+1; j < np; ++j)
		    if (p[j] == usp[j])
			break;
		cr->next = (CROSS *)store(sizeof(CROSS));
		cr->next->prev = cr;
		cr = cr->next;
		cr->next = NULL;
		cr->pt = (POINT **)store((j-i)*sizeof(POINT*));
		for (cr->npt = 0, k = i; k < j; ++k)
		{
	            if (bdry || !is_bdry(usp[k]))
			cr->pt[cr->npt++] = usp[k];
		}
		i = j-1;
	    }
	}
	*cross = Cr.next;
	if (*cross)
	    (*cross)->prev = NULL;
	return FUNCTION_SUCCEEDED;
}		/*end i_intersections1d*/
Ejemplo n.º 2
0
LOCAL 	boolean exterior_curve(
	CURVE		*c,
	RECT_GRID	*grid)
{
	if ((exterior_point(c->start->posn,grid) == YES) ||
	    (exterior_point(c->end->posn,grid) == YES))
		return YES;

	if ((c->num_points > 2) && is_bdry(c->start) && is_bdry(c->end) &&
		(exterior_point(c->first->end,grid) == YES))
	    return YES;

	return NO;
}		/*end exterior_curve*/
Ejemplo n.º 3
0
EXPORT SIDE physical_side_of_bdry_curve(
	CURVE	*c)
{
	if (wave_type(c) >= FIRST_PHYSICS_WAVE_TYPE) 
	{
	    screen("ERROR in physical_side_of_bdry_curve(), non bdry curve\n");
	    print_curve(c);
	    clean_up(ERROR);
	}
	if (is_bdry(c)) 
	{
	    return is_exterior_comp(negative_component(c),c->interface) ?
			POSITIVE_SIDE : NEGATIVE_SIDE;
	}
	else if (is_excluded_comp(negative_component(c),c->interface))
	    return POSITIVE_SIDE;
	else if (is_excluded_comp(positive_component(c),c->interface))
	    return NEGATIVE_SIDE;
	else 
	{
	    screen("ERROR in physical_side_of_bdry_curve(), "
		   "interior boundary not bounded by an excluded component\n");
	    print_curve(c);
	    clean_up(ERROR);
	}
	return UNKNOWN_SIDE; /* for lint */
}		/*end physical_side_of_bdry_curve*/
Ejemplo n.º 4
0
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*/