EXPORT COMPONENT nearest_interior_comp( boolean multiple_comps, COMPONENT dflt_comp, double *coords, INTERFACE *intfc) { COMPONENT comp; double t[MAXD], coords_on[MAXD]; HYPER_SURF *hs; HYPER_SURF_ELEMENT *hse; if ((multiple_comps == NO) || (intfc->hss == NULL)) return dflt_comp; comp = component(coords,intfc); if (!is_exterior_comp(comp,intfc)) return comp; if (nearest_interface_point(coords,comp,intfc,INCLUDE_BOUNDARIES,NULL, coords_on,t,&hse,&hs) != YES) { screen("ERROR in nearest_interior_comp(), " "nearest_interface_point() failed\n"); clean_up(ERROR); } return (is_exterior_comp(negative_component(hs),intfc)) ? positive_component(hs) : negative_component(hs); } /*end nearest_interior_comp*/
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*/
/*ARGSUSED*/ LOCAL boolean i_is_excluded_comp( COMPONENT comp, COMP_LIST *comp_list, INTERFACE *intfc) { if (is_exterior_comp(comp,intfc)) return YES; return i_is_comp_in_list(comp,&excluded_comps(intfc)); } /*end i_is_excluded_comp*/
EXPORT COMPONENT new_component( COMPONENT comp) { COMPONENT mincomp, maxcomp; HYPER_SURF **hs; INTERFACE *intfc; struct Table *firstIT, *T; static COMPONENT last_reused_comp = NO_COMP; if (comp != NO_COMP) { firstIT = interface_table_list(); switch (comp) { case UNUSED_COMP: maxcomp = INT_MIN; mincomp = INT_MAX; for (T = firstIT; T != NULL; T = T->next) { intfc = T->interface; maxcomp = max(maxcomp,max_component(intfc)); mincomp = min(mincomp,min_component(intfc)); } ++maxcomp; for (comp = mincomp; comp <= maxcomp; ++comp) { if (comp == last_reused_comp) continue; for (T = firstIT; T != NULL; T = T->next) { intfc = T->interface; if (is_exterior_comp(comp,intfc) || is_excluded_comp(comp,intfc)) break; if (intfc->hss != NULL) { for (hs = intfc->hss; *hs; ++hs) { if ((positive_component(*hs) == comp) || (negative_component(*hs) == comp)) break; } if (*hs) break; } } if (T == NULL) break; } last_reused_comp = comp; break; case NEW_COMP: comp = INT_MIN; for (T = firstIT; T != NULL; T = T->next) { intfc = T->interface; comp = max(comp,max_component(intfc)); } ++comp; last_reused_comp = NO_COMP; break; default: last_reused_comp = NO_COMP; break; } for (T = firstIT; T != NULL; T = T->next) { intfc = T->interface; max_component(intfc) = max(comp,max_component(intfc)); min_component(intfc) = min(comp,min_component(intfc)); } } return comp; } /*end new_component*/