Пример #1
0
EXPORT	void check_double_cone_point(
	INTERFACE *intfc)
{
	SURFACE **s;
	TRI *tri,*ptris[30],**tris;
	int i,j,num_ptris,num_tris;
	POINT *p; 
	HYPER_SURF *hs;
	HYPER_SURF_ELEMENT *hse;
	bool ptri_in_tri_list;

	(void) printf("Start checking double cone point\n");
	next_point(intfc,NULL,NULL,NULL);
	while (next_point(intfc,&p,&hse,&hs))
	{
	    num_ptris = 0;
	    num_tris = set_tri_list_around_point(p,Tri_of_hse(hse),
	    	&tris,intfc);
	    for (s = intfc->surfaces; s && *s; ++s)
	    {
	    	for (tri = first_tri(*s); !at_end_of_tri_list(tri,*s);
				tri = tri->next)
		{
		    if (Point_of_tri(tri)[0] == p ||
		    	Point_of_tri(tri)[1] == p ||
			Point_of_tri(tri)[2] == p)
			ptris[num_ptris++] = tri;
		}
	    }
	    for (i = 0; i < num_ptris; ++i)
	    {
	    	ptri_in_tri_list = NO;
	    	tri = ptris[i];
		for (j = 0; j < num_tris; ++j)
		{
		    if (tri == tris[j])
		    {
		    	ptri_in_tri_list = YES;
			break;
		    }
		}
		if (!ptri_in_tri_list)
		{
		    (void) printf("double cone point found:\n");
		    (void) printf("double cone point p(%d) = %f %f %f\n",p,
		    		Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		}
	    }
	}
	(void) printf("End checking double cone point\n");
}	/* end check_double_cone_point */
Пример #2
0
LOCAL	bool check_consistency_of_tris_on_surface(
	SURFACE		*s)
{
	TRI       *t, *tri;
	INTERFACE *intfc = s->interface;
	bool      status = YES;
	char      warn[1024];
	int       i;

	(void) sprintf(warn,"WARNING in "
			    "check_consistency_of_tris_on_surface(), "
	                    "surface %llu inconsistent ",surface_number(s));

	for (i=0, t=first_tri(s); !at_end_of_tri_list(t,s); t=t->next, ++i)
	{
	    if (t == NULL)
	    {
		(void) printf("%s null tri found in tri list\n",warn);
		status = NO;
		break;
	    }
	}
	if (i != s->num_tri)
	{
	    (void) printf("%s number of tris on surface inconsistent\n",warn);
	    (void) printf("counted = %d	s->num_tri = %d\n",i,s->num_tri);
	    (void) printf("head = 0x%p  tail = 0x%p  first = 0x%p\n",
	    	          head_of_tri_list(s),
	    	          tail_of_tri_list(s), 
	    	          first_tri(s));
	    (void) printf("first->prev = 0x%p  first->next = 0x%p\n",
	    	          first_tri(s)->prev,first_tri(s)->next);
	    status = NO;
	}

	for (i=0, tri=first_tri(s); i < s->num_tri; ++i, tri=tri->next)
	{
	    if (tri == NULL)
		break;
	    if (!check_tri(tri,intfc))
	    {
		(void) printf("%s check_tri failed\n",warn);
		status = NO;
	    }
	}
	return status;
}		/*end check_consistency_of_tris_on_surface*/
Пример #3
0
EXPORT INTERFACE *remap_interface(
	INTERFACE	*intfc,
	void		(*remap)(POINT*,BOND*,CURVE*,POINT*,
				 BOND*,CURVE*,boolean,RECT_GRID*,POINTER),
	void		(*remap_rect_grid)(INTERFACE*,INTERFACE*,
					   void (*)(POINT*,BOND*,CURVE*,
						    POINT*,BOND*,CURVE*,boolean,
						    RECT_GRID*,POINTER),
					   POINTER),
	POINTER		params)
{
	HYPER_SURF	   *hs, *nhs;
	HYPER_SURF_ELEMENT *hse, *nhse;
	POINT		   *p, *np;
	INTERFACE	   *new_intfc;
	RECT_GRID	   *rgr;
	boolean		   first = YES;
	double              eps;

	if (DEBUG)
	    (void) printf("Entering remap_interface(%llu)\n",
		          (long long unsigned int)interface_number(intfc));
	if (remap == NULL || remap_rect_grid == NULL)
	    return NULL;
	if (exists_interface(intfc) != YES)
	    return NULL;
	if ((new_intfc = copy_interface(intfc)) == NULL)
	    return NULL;
	rgr = &topological_grid(new_intfc);

	/* TODO:  check for validity at hyper surface boundaries */
	(void) next_point(intfc,NULL,NULL,NULL);
	(void) next_point(new_intfc,NULL,NULL,NULL);
	while (next_point(intfc,&p,&hse,&hs) &&
	       next_point(new_intfc,&np,&nhse,&nhs))
	{
	    (*remap)(p,Bond_of_hse(hse),Curve_of_hs(hs),np,
	    	     Bond_of_hse(nhse),Curve_of_hs(nhs),first,rgr,params);
	    first = NO;
	}

		/* Remap the Underlying Grid: */

	(*remap_rect_grid)(intfc,new_intfc,remap,params);

		/* Reset boundary flags */

	eps = grid_tolerance(rgr);
	if (new_intfc->dim == 1)
	{
	    POINT **pt;
	    for (pt = new_intfc->points; pt && *pt; pt++)
	    {
		if (boundary_side(Coords(*pt),rgr,eps) == NOT_A_BDRY)
		    set_not_bdry(*pt);
		else
		    set_is_bdry(*pt);
	    }
	}
	if (new_intfc->dim == 2)
	{
	    CURVE **c;
	    NODE  **n;
	    for (n = new_intfc->nodes; n && *n; n++)
	    {
		if (boundary_side(Coords((*n)->posn),rgr,eps) == NOT_A_BDRY)
		    set_not_bdry(*n);
		else
		    set_is_bdry(*n);
	    }
	    for (c = new_intfc->curves; c && *c; c++)
	    {
	        BDRY_SIDE side_start, side_end, side;
		BOND      *b;
	        NODE      *ns, *ne;

		ns = (*c)->start;
		ne = (*c)->end;
		side_start = boundary_side(Coords(ns->posn),rgr,eps);
		side_end = boundary_side(Coords(ne->posn),rgr,eps);
		if ((side_start != side_end) || (side_start == NOT_A_BDRY))
		{
		    set_not_bdry(*c);
		    continue;
		}
		side = side_start;
		for (b = (*c)->first; b != (*c)->last; b = b->next)
		{
		    if (boundary_side(Coords(b->end),rgr,eps) != side)
		    {
			side = NOT_A_BDRY;
			break;
		    }
		}
		if (side == NOT_A_BDRY)
		    set_not_bdry(*c);
		else
		    set_is_bdry(*c);
	    }
	}
	if (new_intfc->dim == 3)
	{
	    CURVE   **c;
	    NODE    **n;
	    SURFACE **s;
	    for (n = new_intfc->nodes; n && *n; n++)
	    {
		if (boundary_side(Coords((*n)->posn),rgr,eps) == NOT_A_BDRY)
		    set_not_bdry(*n);
		else
		    set_is_bdry(*n);
	    }
	    for (c = new_intfc->curves; c && *c; c++)
	    {
	        BDRY_SIDE side_start, side_end, side;
		BOND      *b;
	        NODE      *ns, *ne;

		ns = (*c)->start;
		ne = (*c)->end;
		side_start = boundary_side(Coords(ns->posn),rgr,eps);
		side_end = boundary_side(Coords(ne->posn),rgr,eps);
		if ((side_start != side_end) || (side_start == NOT_A_BDRY))
		{
		    set_not_bdry(*c);
		    continue;
		}
		side = side_start;
		for (b = (*c)->first; b != (*c)->last; b = b->next)
		{
		    if (boundary_side(Coords(b->end),rgr,eps) != side)
		    {
			side = NOT_A_BDRY;
			break;
		    }
		}
		if (side == NOT_A_BDRY)
		    set_not_bdry(*c);
		else
		    set_is_bdry(*c);
	    }
	    for (s = new_intfc->surfaces; s && *s; s++)
	    {
		TRI       *t;
		BDRY_SIDE side0, side1, side2, side;
		const double     *p0, *p1, *p2;
		t = first_tri(*s);
		p0 = Coords(Point_of_tri(t)[0]);
		p1 = Coords(Point_of_tri(t)[1]);
		p2 = Coords(Point_of_tri(t)[2]);
		side0 = boundary_side(p0,rgr,eps);
		side1 = boundary_side(p1,rgr,eps);
		if ((side0 != side1) || (side0 == NOT_A_BDRY))
		{
		    set_not_bdry(*s);
		    continue;
		}
		side = side0;
		side2 = boundary_side(p2,rgr,eps);
		if (side2 != side0)
		{
		    set_not_bdry(*s);
		    continue;
		}
		for (t = t->next; !at_end_of_tri_list(t,*s); t = t->next)
		{
		    p0 = Coords(Point_of_tri(t)[0]);
		    p1 = Coords(Point_of_tri(t)[1]);
		    p2 = Coords(Point_of_tri(t)[2]);
		    if ((boundary_side(p0,rgr,eps) != side) ||
		        (boundary_side(p1,rgr,eps) != side) ||
		        (boundary_side(p2,rgr,eps) != side))
		    {
			side = NOT_A_BDRY;
			break;
		    }
		}
		if (side == NOT_A_BDRY)
		    set_not_bdry(*s);
		else
		    set_is_bdry(*s);
	    }
	}


	if (DEBUG) (void) printf("Leaving remap_interface()\n\n");
	return new_intfc;
}		/*end remap_interface*/