bool AdbWinUsbInterfaceObject::GetEndpointInformation(
    UCHAR endpoint_index,
    AdbEndpointInformation* info) {
  if (!IsOpened()) {
    SetLastError(ERROR_INVALID_HANDLE);
    return false;
  }

  if (NULL == info) {
    SetLastError(ERROR_INVALID_PARAMETER);
    return false;
  }

  // Get actual endpoint index for predefined read / write endpoints.
  if (ADB_QUERY_BULK_READ_ENDPOINT_INDEX == endpoint_index) {
    endpoint_index = def_read_endpoint_;
  } else if (ADB_QUERY_BULK_WRITE_ENDPOINT_INDEX == endpoint_index) {
    endpoint_index = def_write_endpoint_;
  }

  // Query endpoint information
  WINUSB_PIPE_INFORMATION pipe_info;
  if (!WinUsb_QueryPipe(winusb_handle(), interface_number(), endpoint_index,
                        &pipe_info)) {
    return false;
  }

  // Save endpoint information into output.
  info->max_packet_size = pipe_info.MaximumPacketSize;
  info->max_transfer_size = 0xFFFFFFFF;
  info->endpoint_address = pipe_info.PipeId;
  info->polling_interval = pipe_info.Interval;
  info->setting_index = interface_number();
  switch (pipe_info.PipeType) {
    case UsbdPipeTypeControl:
      info->endpoint_type = AdbEndpointTypeControl;
      break;

    case UsbdPipeTypeIsochronous:
      info->endpoint_type = AdbEndpointTypeIsochronous;
      break;

    case UsbdPipeTypeBulk:
      info->endpoint_type = AdbEndpointTypeBulk;
      break;

    case UsbdPipeTypeInterrupt:
      info->endpoint_type = AdbEndpointTypeInterrupt;
      break;

    default:
      info->endpoint_type = AdbEndpointTypeInvalid;
      break;
  }

  return true;
}
Beispiel #2
0
LOCAL	bool i_consistent_interface2d(
	INTERFACE	*intfc)
{
	CURVE              **c;
	NODE               **n;
	bool               status = YES;
	const char         *warn = "WARNING in i_consistent_interface(), ";

	/* Check Nodes */
	for (n = intfc->nodes; n && *n; ++n)
	{
	    if ((*n)->interface != intfc)
	    {
		(void) printf("%s n = %llu n->interface (%llu) != intfc (%llu)\n",
			      warn,node_number(*n),
			      interface_number((*n)->interface),
			      interface_number(intfc));
		status = NO;
	    }
	    for (c = (*n)->in_curves; c && *c; ++c)
	    {
		if ((*c)->end != *n)
		{
		    (void) printf("%s inconsistent node (%llu) "
				  "curve (%llu) pair, "
				  "curve->end != n\n",
				  warn,node_number(*n),curve_number(*c));
		    status = NO;
		}
	    }
	    for (c = (*n)->out_curves; c && *c; ++c)
	    {
		if ((*c)->start != *n)
		{
		    (void) printf("%s inconsistent node (%llu) "
				  "curve (%llu) pair, "
				  "curve->start != n\n",
				  warn,node_number(*n),curve_number(*c));
		    status = NO;
		}
	    }
	}

	/* Check Curves */
	for (c = intfc->curves; c && *c; c++)
	{
	    if (!check_curve2d(*c,intfc))
	    {
	        (void) printf("%s inconsistency in curve (%llu) found\n",
			      warn,curve_number(*c));
		status = NO;
	    }
	}
	return status;

}	/* end i_consistent_interface2d */
Beispiel #3
0
LOCAL void show_point_list(
	INTERFACE	*intfc)
{
	struct Table	*T = intfc->table;
	int		xmax = intfc->table->rect_grid.gmax[0];
	int		ix,i;

	(void) printf("\n\n\tHere is the point list of interface %llu\n\n",
		      interface_number(intfc));
	for (ix = 0; ix < xmax; ++ix)
	{
		if (T->num_of_points[ix] == 0) 
		{
		  (void) printf ("ix=%d:\tnum_of_points=0,\tpts_in_zone=NULL\n",
				 ix);
		}
		else
		{
		    (void) printf("ix=%d:\tnum_of_points=%d,\tpts_in_zone=",ix,
				  T->num_of_points[ix]);
		    for(i = 0; i < T->num_of_points[ix]; ++i)
			    (void) printf("  %llu",
					  point_number(T->pts_in_zone[ix][i]));
		    (void) printf("\n");
		}
	}
}		/*end show_point_list*/
Beispiel #4
0
EXPORT	void print_linked_node_list(
	INTERFACE	*intfc)
{
	NODE		**n, *m;
	int		i, node_count;

	n = intfc->nodes;
	if (! n)
	{
	    (void) printf("NULL node list on intfc\n");
	    return;
	}

	(void) printf("\tnode list - intfc %llu\n",(long long unsigned int)interface_number(intfc));
	for (node_count = 0;  n && *n;  ++n, ++node_count)
		;

	m = first_node(intfc);
	for (i = 0;  i <= node_count + 2;  ++i) 
	{
	    if (m != NULL)
	    {
	    	(void) printf("prev %llu  m %llu  next %llu  ",
	    		      (long long unsigned int)node_number(prev_node(m)),
			      (long long unsigned int)node_number(m),
	    		      (long long unsigned int)node_number(next_node(m)));
	    	print_propagation_status(m);
	    }
	    else
	    	break;
	    m = next_node(m);
	}
}		/*end print_linked_node_list*/
Beispiel #5
0
EXPORT	void verbose_ses_show_intfc_states(
	INTERFACE		*intfc,
	SESAME_TABLE_TYPE	eos_type,
	SESAME_EOS		*seos)
{
	const char	*s;
	CURVE		**c;

	s = sesame_table_names()[eos_type];
	(void) printf("\t\tEOS STATES ON THE %s INTERFACE %llu\n\n",s,
		interface_number(intfc));
	for( c = intfc->curves;	 *c != NULL;  c++ )
		verbose_ses_print_curve_states(*c,eos_type,seos);
	(void) printf("\n\n");
	(void) printf("\t\tEND OF EOS STATES ON THE %s INTERFACE %llu\n\n",
	       s,interface_number(intfc));
}		/*end verbose_ses_show_intfc_states*/
Beispiel #6
0
LOCAL void show_Comp_list(
	INTERFACE	*intfc)
{
	int		xmax = intfc->table->rect_grid.gmax[0];
	int		ix;

	(void) printf("\n\n\tHere is the component list of interface %llu:\n\n",
		      interface_number(intfc));
	for (ix = 0; ix < xmax; ++ix)
	    (void) printf("Comp[%d] = %d\n",ix,intfc->table->compon1d[ix]);
}		/*end show_Comp_list*/
Beispiel #7
0
LIB_LOCAL void show_COMP_1d(
	FILE		*file,
	INTERFACE	*intfc)
{
	int		ix;
	int		ixmax;

	ixmax = topological_grid(intfc).gmax[0];
	(void) fprintf(file,"\n\nCOMPONENTS by Grid Block for INTERFACE %llu:\n",
		       interface_number(intfc));
	for (ix = 0; ix < ixmax; ++ix)
	{
	    if (intfc->table->compon1d[ix] == ONFRONT)
	    	(void) fprintf(file,"ON ");
	    else
	    	(void) fprintf(file,"%2d ",intfc->table->compon1d[ix]);
	    (void) fprintf(file,"\n");
	}
	(void) fprintf(file,"\n\n");
}		/*end show_COMP_1d*/
ADBAPIHANDLE AdbWinUsbInterfaceObject::CreateHandle() {
  // Open USB device for this inteface Note that WinUsb API
  // requires the handle to be opened for overlapped I/O.
  usb_device_handle_ = CreateFile(interface_name().c_str(),
                                  GENERIC_READ | GENERIC_WRITE,
                                  FILE_SHARE_READ | FILE_SHARE_WRITE,
                                  NULL, OPEN_EXISTING,
                                  FILE_FLAG_OVERLAPPED, NULL);
  if (INVALID_HANDLE_VALUE == usb_device_handle_)
    return NULL;

  // Initialize WinUSB API for this interface
  if (!WinUsb_Initialize(usb_device_handle_, &winusb_handle_))
    return NULL;

  // Cache current interface number that will be used in
  // WinUsb_Xxx calls performed on this interface.
  if (!WinUsb_GetCurrentAlternateSetting(winusb_handle(), &interface_number_))
    return false;

  // Cache interface properties
  unsigned long bytes_written;

  // Cache USB device descriptor
  if (!WinUsb_GetDescriptor(winusb_handle(), USB_DEVICE_DESCRIPTOR_TYPE, 0, 0,
                            reinterpret_cast<PUCHAR>(&usb_device_descriptor_),
                            sizeof(usb_device_descriptor_), &bytes_written)) {
    return false;
  }

  // Cache USB configuration descriptor
  if (!WinUsb_GetDescriptor(winusb_handle(), USB_CONFIGURATION_DESCRIPTOR_TYPE,
                            0, 0,
                            reinterpret_cast<PUCHAR>(&usb_config_descriptor_),
                            sizeof(usb_config_descriptor_), &bytes_written)) {
    return false;
  }

  // Cache USB interface descriptor
  if (!WinUsb_QueryInterfaceSettings(winusb_handle(), interface_number(),
                                     &usb_interface_descriptor_)) {
    return false;
  }

  // Save indexes and IDs for bulk read / write endpoints. We will use them to
  // convert ADB_QUERY_BULK_WRITE_ENDPOINT_INDEX and
  // ADB_QUERY_BULK_READ_ENDPOINT_INDEX into actual endpoint indexes and IDs.
  for (UCHAR endpoint = 0; endpoint < usb_interface_descriptor_.bNumEndpoints;
       endpoint++) {
    // Get endpoint information
    WINUSB_PIPE_INFORMATION pipe_info;
    if (!WinUsb_QueryPipe(winusb_handle(), interface_number(), endpoint,
                          &pipe_info)) {
      return false;
    }

    if (UsbdPipeTypeBulk == pipe_info.PipeType) {
      // This is a bulk endpoint. Cache its index and ID.
      if (0 != (pipe_info.PipeId & USB_ENDPOINT_DIRECTION_MASK)) {
        // Use this endpoint as default bulk read endpoint
        ATLASSERT(0xFF == def_read_endpoint_);
        def_read_endpoint_ = endpoint;
        read_endpoint_id_ = pipe_info.PipeId;
      } else {
        // Use this endpoint as default bulk write endpoint
        ATLASSERT(0xFF == def_write_endpoint_);
        def_write_endpoint_ = endpoint;
        write_endpoint_id_ = pipe_info.PipeId;
      }
    }
  }

  return AdbInterfaceObject::CreateHandle();
}
Beispiel #9
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*/
Beispiel #10
0
LOCAL	bool	check_curve3d(
	CURVE     *c,
	INTERFACE *intfc)
{
	BOND     *b;
	BOND_TRI **bts, **bts0;
	NODE     *ns, *ne;
	SURFACE  *s, **ss;
	TRI      *tri, **tris;
	bool     status = YES;
	char     warn[1024];
	int      nsides, nbts, i;
	int      ntris;

	(void) sprintf(warn,"WARNING in check_curve3d(), curve %llu inconsistent ",
		       curve_number(c));
	if (c->interface != intfc)
	{
	    (void) printf("%s c->interface (%llu) != intfc (%llu)\n",
			  warn,interface_number(c->interface),
			  interface_number(intfc));
	    status = NO;
	}
	ns = c->start;
	if (!pointer_is_in_array(c,ns->out_curves))
	{
	    (void) printf("%s curve in not in start node (%llu) "
			  "out_curves\n",warn,node_number(ns));
	    status = NO;
	}
	ne = c->end;
	if (!pointer_is_in_array(c,ne->in_curves))
	{
	    (void) printf("%s curve in not in end node (%llu) "
			  "in_curves\n",warn,node_number(ne));
	    status = NO;
	}
	if (ns->posn != c->first->start)
	{
	    (void) printf("%s ns->posn != c->first->start\n"
			  "c->first->start = %llu, "
			  "ns = %llu, ns->posn = %llu\n",
			  warn,point_number(c->first->start),
			  node_number(ns),point_number(ns->posn));
	    status = NO;
	}
	if (ne->posn != c->last->end)
	{
	    (void) printf("%s ne->posn != c->last->end\n"
			  "c->last->end = %llu, "
			  "ne = %llu, ne->posn = %llu\n",
			  warn,point_number(c->last->end),
			  node_number(ne),point_number(ne->posn));

	    print_general_vector("c->last->end", Coords(c->last->end), 3, "\n");
	    print_general_vector("ne->posn", Coords(ne->posn), 3, "\n");
	    print_curve(c);
	    status = NO;
	}
	if (!Boundary_point(ns->posn))
	{
	    (void) printf("%s ns->posn (ns = %llu, ns->posn = %llu) is not a "
			  "boundary point\n",
			  warn,node_number(ns),point_number(ns->posn));
	    status = NO;
	}
	if (!Boundary_point(ne->posn))
	{
	    (void) printf("%s ne->posn (ne = %llu, ne->posn = %llu) is not a "
			  "boundary point\n",
			  warn,node_number(ne),point_number(ne->posn));
	    status = NO;
	}
	if (!Boundary_point(c->first->start))
	{
	    (void) printf("%s c->first->start = %llu is not a "
			  "boundary point\n",
			  warn,point_number(c->first->start));
	    status = NO;
	}
	if (!Boundary_point(c->last->end))
	{
	    (void) printf("%s c->last->end = %llu is not a "
			  "boundary point\n",
			  warn,point_number(c->last->end));
	    status = NO;
	}
	for (ss = c->pos_surfaces; ss && *ss; ++ss)
	{
	    if (!pointer_is_in_array(c,(*ss)->pos_curves))
	    {
	        (void) printf("%s curve in not s->pos_curves "
			      " s = %llu but s is in c->neg_surfaces\n",
			      warn,surface_number(*ss));
		status = NO;
	    }
	}
	for (ss = c->neg_surfaces; ss && *ss; ++ss)
	{
	    if (!pointer_is_in_array(c,(*ss)->neg_curves))
	    {
	        (void) printf("%s curve in not s->neg_curves "
			      " s = %llu but s is in c->neg_surfaces\n",
			      warn,surface_number(*ss));
		status = NO;
	    }
	}
	b = c->first;
	bts0 = Btris(b);
	for (nbts = 0, bts = Btris(b); bts && *bts; ++nbts, ++bts);
	if (nbts == 0)
	{
	    if (c->pos_surfaces || c->neg_surfaces)
	    {
		(void) printf("%s curve has no bond tris but is "
			      "connected to some surface\n",warn);
		status = NO;
	    }
	}
	if (c->first->prev != NULL)
	{
	    (void) printf("%s c->first->prev != NULL\n",warn);
	    print_bond(c->first);
	    print_bond(c->first->prev);
	    status = NO;
	}
	if (c->last->next != NULL)
	{
	    (void) printf("%s c->last->next != NULL\n",warn);
	    print_bond(c->last);
	    print_bond(c->last->next);
	    status = NO;
	}
	for (b = c->first; b != NULL; b = b->next)
	{
	    if (b->next && b->next->start != b->end)
	    {
	        (void) printf("%s bond pair (%llu -> %llu) point pointers "
			      "inconsistent\n",
			      warn,bond_number(b,intfc),
			      bond_number(b->next,intfc));
		print_bond(b);
		print_bond(b->next);
	        status = NO;
	    }
	    if (!Boundary_point(b->start))
	    {
	        (void) printf("%s b->start = %llu is not a "
			      "boundary point\n",
			      warn,point_number(b->start));
		print_bond(b);
	        status = NO;
	    }
	    if (!Boundary_point(b->end))
	    {
	        (void) printf("%s b->end = %llu is not a "
			      "boundary point\n",
			      warn,point_number(b->end));
		print_bond(b);
	        status = NO;
	    }
	    for (i = 0, bts = Btris(b); bts && *bts; ++i, ++bts)
	    {
		if ((i < nbts) &&
		    !(((*bts)->surface == bts0[i]->surface) &&
		          ((*bts)->orient == bts0[i]->orient)))
		{
	            (void) printf("%s inconsistent surface numbers on "
				  "bond tri\n",warn);
		    (void) printf("surface = %llu surface[%d] = %llu\n",
				  surface_number((*bts)->surface),i,
				  surface_number(bts0[i]->surface));
		    (void) printf("orient = %s orient[%d] = %s\n",
				  orientation_name((*bts)->orient),i,
				  orientation_name(bts0[i]->orient));
		    print_bond(b);
	            status = NO;
		}
	    }
	    if (i != nbts)
	    {
	        (void) printf("%s inconsistent %d != %d number of bond tris "
			      "on bond\n",warn,i,nbts);
		print_bond(b);
	        status = NO;
	    }
	    for (bts = Btris(b); bts && *bts; ++bts)
	    {
		if ((*bts)->curve != c)
		{
		    (void) printf("%s bond tri curve field (%llu) != c\n",
				  warn,curve_number((*bts)->curve));
		    print_bond(b);
		    status = NO;
		}
		if ((*bts)->bond != b)
		{
		    (void) printf("%s bond tri bond field (%llu) != b (%llu)\n",
				  warn,bond_number((*bts)->bond,intfc),
				  bond_number(b,intfc));
		    print_bond(b);
		    status = NO;
		}
		tri = (*bts)->tri;
		s = Surface_of_tri(tri);
		if ((*bts)->surface != s)
		{
		    (void) printf("%s bond tri surface field (%llu)"
				  "!= Surface_of_tri(tri) (%llu)\n",
				  warn,surface_number((*bts)->surface),
				  surface_number(s));
		    print_bond(b);
		    status = NO;
		}
		for (nsides = 0, i = 0; i < 3; ++i)
		{
		    if (is_side_bdry(tri,i) && (b==Bond_on_side(tri,i)))
			++nsides;
		}
		if (nsides == 0)
		{
		    (void) printf("%s bond not found on tri side\n",warn);
		    print_bond(b);
		    print_tri(tri,intfc);
		    status = NO;
		}
		else if (nsides > 1)
		{
		    (void) printf("%s bond found on multiple tri sides\n",warn);
		    print_bond(b);
		    print_tri(tri,intfc);
		    status = NO;
		}
		else
		{
		    if (orientation_of_bond_at_tri(b,tri) != (*bts)->orient)
		    {
		        (void) printf("%s inconsistent orientation at "
				      "bond tri\n",warn);
		        print_tri(tri,intfc);
		        print_bond(b);
		        status = NO;
		    }
		    switch ((*bts)->orient)
		    {
		    case POSITIVE_ORIENTATION:
	                if (!pointer_is_in_array(c,s->pos_curves))
	                {
	                    (void) printf("%s curve in not s->pos_curves "
					  " s = %llu\n",
			                  warn,surface_number(s));
		            print_bond(b);
		            print_tri(tri,intfc);
	                    status = NO;
	                }
	                if (!pointer_is_in_array(s,c->pos_surfaces))
	                {
	                    (void) printf("%s surface in not c->pos_surfaces "
					  " s = %llu\n",
			                  warn,surface_number(s));
		            print_bond(b);
		            print_tri(tri,intfc);
	                    status = NO;
	                }
			break;
		    case NEGATIVE_ORIENTATION:
	                if (!pointer_is_in_array(c,s->neg_curves))
	                {
	                    (void) printf("%s curve in not s->neg_curves "
					  " s = %llu\n",
			                  warn,surface_number(s));
		            print_bond(b);
		            print_tri(tri,intfc);
	                    status = NO;
	                }
	                if (!pointer_is_in_array(s,c->neg_surfaces))
	                {
	                    (void) printf("%s surface in not c->neg_surfaces "
					  " s = %llu\n",
			                  warn,surface_number(s));
		            print_bond(b);
		            print_tri(tri,intfc);
	                    status = NO;
	                }
			break;
		    case ORIENTATION_NOT_SET:
			(void) printf("%s inconsistent point and tri "
				      "points\n",warn);
		        print_bond(b);
		        print_tri(tri,intfc);
	                status = NO;
			break;
		    }
		}
		if (b->prev)
		{
		    TRI *t0, *t1;
	            ntris = set_tri_list_around_point(b->start,tri,&tris,intfc);
		    t0 = tris[0]; t1 = tris[ntris-1];
		    if (!(((side_of_tri_with_bond(b,t0) < 3) &&
			      (side_of_tri_with_bond(b->prev,t1) < 3))
		        ||
			     ((side_of_tri_with_bond(b,t1) < 3) &&
			      (side_of_tri_with_bond(b->prev,t0) < 3)))
		       )
		    {
			(void) printf("%s, corrupt tri list at b->start\n",
				      warn);
		        (void) printf("Bond b\n"); print_bond(b);
		        (void) printf("Bond b->prev\n"); print_bond(b->prev);
		        print_tri(tri,intfc);
			(void) printf("number of tris at point = %d\n",ntris);
			for (i = 0; i < ntris; ++i)
			{
			    (void) printf("tris[%d] - ",i);
			    print_tri(tris[i],intfc);
			}
			status = NO;
		    }
		}
	    }
	}
	return status;
}		/*end check_curve3d*/
Beispiel #11
0
LOCAL	bool i_consistent_interface3d(
	INTERFACE	*intfc)
{
	HYPER_SURF_ELEMENT *hse;
	HYPER_SURF         *hs;
	CURVE              **c;
	NODE               **n;
	POINT              *p;
	SURFACE	           **ss, *s;
	TRI	           *tri;
	bool               status = YES;
	const char         *warn = "WARNING in i_consistent_interface(), ";

	/* Check Nodes */
	for (n = intfc->nodes; n && *n; ++n)
	{
	    if ((*n)->interface != intfc)
	    {
		(void) printf("%s n = %llu n->interface (%llu) != intfc (%llu)\n",
			      warn,node_number(*n),
			      interface_number((*n)->interface),
			      interface_number(intfc));
		status = NO;
	    }
	    for (c = (*n)->in_curves; c && *c; ++c)
	    {
		if ((*c)->end != *n)
		{
		    (void) printf("%s inconsistent node (%llu) "
				  "curve (%llu) pair, "
				  "curve->end != n\n",
				  warn,node_number(*n),curve_number(*c));
		    status = NO;
		}
	    }
	    for (c = (*n)->out_curves; c && *c; ++c)
	    {
		if ((*c)->start != *n)
		{
		    (void) printf("%s inconsistent node (%llu) "
				  "curve (%llu) pair, "
				  "curve->start != n\n",
				  warn,node_number(*n),curve_number(*c));
		    status = NO;
		}
	    }
	}

	/* Check Curves */
	for (c = intfc->curves; c && *c; c++)
	{
	    if (!check_curve3d(*c,intfc))
	    {
	        (void) printf("%s inconsistency in curve (%llu) found\n",
			      warn,curve_number(*c));
		status = NO;
	    }
	}

	for (ss = intfc->surfaces; ss && *ss; ++ss)
	{
	    if (!check_consistency_of_tris_on_surface(*ss))
	    {
		(void) printf("%s inconsistency in surface (%llu) found\n",
				  warn,surface_number(*ss));
		status = NO;
	    }
	}

	(void) next_point(intfc,NULL,NULL,NULL);
	while (next_point(intfc,&p,&hse,&hs))
	{
	    BOND        *b = NULL, *bb;
	    BOND_TRI    **bts;
	    CURVE       **c;
	    TRI         **tris;
	    int         i, ntris;
	    int         v, pside, nside;

	    tri = Tri_of_hse(hse);
	    s = Surface_of_hs(hs);
	    if ((v = Vertex_of_point(tri,p)) == ERROR)
	    {
	        (void) printf("%s point not on tri, s = %llu\n",
			      warn,surface_number(s));
	    	(void) printf("p(%llu) - (%g, %g, %g), ",
	    		      point_number(p),
	    		      Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		print_tri(tri,hs->interface);
		status = NO;
	    }
	    if (!Boundary_point(p))
	    {
		ntris = set_tri_list_around_point(p,tri,&tris,intfc);
		if ((tri != tris[0]) ||
		    (tri != Prev_tri_at_vertex(tris[ntris-1],p)))
		{
		    bool consistent_tri_list = NO;
		    if (allow_null_sides)
		    {
			if ((Next_tri_at_vertex(tris[0],p) == NULL) &&
		            (Prev_tri_at_vertex(tris[ntris-1],p) == NULL))
			  consistent_tri_list = YES;  
		    }
		    if (!consistent_tri_list)
		    {
		        (void) printf("\n%s Corrupt tri list s (%llu) "
	    	                      "p(%llu) - (%g, %g, %g)\n",
				      warn,surface_number(s),
	    		              point_number(p),
	    		              Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		        print_tri(tri,hs->interface);
		        (void) printf("%d tris about point\n",ntris);
		        for (i = 0; i < ntris; ++i)
		        {
			    (void) printf("tris[%d] - ",i);
			    print_tri(tris[i],hs->interface);
		        }
		        (void) printf("End printout of "
				      "Corrupt tri list s (%llu) "
	    	                      "p(%llu) - (%g, %g, %g)\n\n",
				      surface_number(s),point_number(p),
	    		              Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		        status = NO;
		    }
		}
		continue;
	    }
	    nside = v;
	    pside = Prev_m3(v);
	    if (is_side_bdry(tri,nside))
		b = Bond_on_side(tri,nside);
	    else if (is_side_bdry(tri,pside))
		b = Bond_on_side(tri,pside);
	    else    //#bjet2
	    {
		ntris = set_tri_list_around_point(p,tri,&tris,intfc);
		v = Vertex_of_point(tris[0],p);
		nside = v;
		pside = Prev_m3(v);
		if (is_side_bdry(tris[0],nside))
		    b = Bond_on_side(tris[0],nside);
		else if (is_side_bdry(tris[0],pside))
		    b = Bond_on_side(tris[0],pside);
		else
		{
		    int i;
	            (void) printf("%s Boundary_point has no adjacent "
				  "tri with a bond\n",warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",
	    		          point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    for (i = 0; i < ntris; ++i)
		    {
			(void) printf("tris[%d] - ",i);
			print_tri(tris[i],hs->interface);
		    }
		    status = NO;
		}
		tri = tris[0];
	    }
	    for (bts = Btris(b); bts && *bts; ++bts)
	        if ((*bts)->tri == tri)
	    	    break;
	    if ((bts == NULL) || (*bts == NULL))
	    {
		(void) printf("%s bond tri for tri  not found\n",warn);
	    	(void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		      Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		print_tri(tri,hs->interface);
		print_bond(b);
		status = NO;
	    }
	    else
	    {
	        if ((*bts)->bond != b)
	        {
		    (void) printf("%s (*bts)->bond != b\n",warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    print_bond(b);
		    status = NO;
	        }
	        if ((*bts)->surface != s)
	        {
	            (void) printf("%s inconsistent surfaces at bond tri\n",
				  warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    print_bond(b);
		    status = NO;
	        }
		if (orientation_of_bond_at_tri(b,tri) != (*bts)->orient)
		{
		    (void) printf("%s inconsistent orientation at bond tri\n",
				  warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    print_bond(b);
		    status = NO;
		}
	        switch ((*bts)->orient)
	        {
	        case POSITIVE_ORIENTATION:
		    for (c = s->pos_curves; c && *c; c++)
		        if ((*c) == (*bts)->curve)
			    break;
	            break;
	        case NEGATIVE_ORIENTATION:
		    for (c = s->neg_curves; c && *c; c++)
		        if ((*c) == (*bts)->curve)
			    break;
	            break;
	        case ORIENTATION_NOT_SET:
		    c = NULL;
	            (void) printf("%s undetermined orientation at "
				  "bond on tri\n",warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    print_bond(b);
		    status = NO;
		    break;
	        }
	        if ((c == NULL) || (*c == NULL))
	        {
		    (void) printf("%s curve with bond on tri not found\n",warn);
	    	    (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		          Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		    print_tri(tri,hs->interface);
		    print_bond(b);
		    status = NO;
	        }
	        else
	        {
	            for (bb = (*c)->first; bb != NULL; bb = bb->next)
		        if (bb == b)
		            break;
	            if (bb == NULL)
	            {
		        (void) printf("%s bond not on curve\n",warn);
	    	        (void) printf("p(%llu) - (%g, %g, %g), ",point_number(p),
	    		              Coords(p)[0],Coords(p)[1],Coords(p)[2]);
		        print_tri(tri,hs->interface);
		        print_bond(b);
		        print_curve(*c);
		        status = NO;
	            }
	        }
	    }
	}

	if (status == NO)
	{
	    (void) printf("WARNING in i_consistent_interface(), "
	                  "Inconsistent interface found\n");
	    print_interface(intfc);
	}

	allow_null_sides = NO;
	return status;
}		/*end i_consistent_interface*/
Beispiel #12
0
LOCAL	bool	check_curve2d(
	CURVE     *c,
	INTERFACE *intfc)
{
	BOND     *b;
	NODE     *ns, *ne;
	bool     status = YES;
	char     warn[1024];

	(void) sprintf(warn,"WARNING in check_curve(), curve %llu inconsistent ",
		       curve_number(c));
	if (c->interface != intfc)
	{
	    (void) printf("%s c->interface (%llu) != intfc (%llu)\n",
			  warn,interface_number(c->interface),
			  interface_number(intfc));
	    status = NO;
	}
	ns = c->start;
	if (!pointer_is_in_array(c,ns->out_curves))
	{
	    (void) printf("%s curve in not in start node (%llu) "
			  "out_curves\n",warn,node_number(ns));
	    status = NO;
	}
	ne = c->end;
	if (!pointer_is_in_array(c,ne->in_curves))
	{
	    (void) printf("%s curve in not in end node (%llu) "
			  "in_curves\n",warn,node_number(ne));
	    status = NO;
	}
	if (ns->posn != c->first->start)
	{
	    (void) printf("%s ns->posn != c->first->start\n"
			  "c->first->start = %llu, "
			  "ns = %llu, ns->posn = %llu\n",
			  warn,point_number(c->first->start),
			  node_number(ns),point_number(ns->posn));
	    status = NO;
	}
	if (ne->posn != c->last->end)
	{
	    (void) printf("%s ne->posn != c->last->end\n"
			  "c->last->end = %llu, "
			  "ne = %llu, ne->posn = %llu\n",
			  warn,point_number(c->last->end),
			  node_number(ne),point_number(ne->posn));
	    status = NO;
	}
	if (c->first->prev != NULL)
	{
	    (void) printf("%s c->first->prev != NULL\n",warn);
	    print_bond(c->first);
	    print_bond(c->first->prev);
	    status = NO;
	}
	if (c->last->next != NULL)
	{
	    (void) printf("%s c->last->next != NULL\n",warn);
	    print_bond(c->last);
	    print_bond(c->last->next);
	    status = NO;
	}
	for (b = c->first; b != NULL; b = b->next)
	{
	    if (b->next && b->next->start != b->end)
	    {
	        (void) printf("%s bond pair (%llu -> %llu) point pointers "
			      "inconsistent\n",
			      warn,bond_number(b,intfc),
			      bond_number(b->next,intfc));
		print_bond(b);
		print_bond(b->next);
	        status = NO;
	    }
	    if ((b->next && b->next->prev != b) || 
	 	(b->prev && b->prev->next != b) ||
		b->next == b || b->prev == b)
	    {
	        (void) printf("%s bond pair (%llu -> %llu) link pointers "
			      "inconsistent\n",
			      warn,bond_number(b,intfc),
			      bond_number(b->next,intfc));
		print_bond(b);
		print_bond(b->next);
		return NO;	/* this is a potential deadloop, so exit */
	    }
	}
	return status;
}		/*end check_curve2d*/