コード例 #1
0
ファイル: ch.c プロジェクト: 5432935/crossbridge
void add_segments(DCEL_segment *n,DCEL_segment *act,DCEL_segment *first,
		  int direction) {
  DCEL_segment *k; /* the new segment */
  point p;

  /* p will contain the point of the segment act that doesn't touch n */
  if (point_equal(act->v1,n->v1)) 
    p = act->v2;
  else 
    p = act->v1;
  
  if (visible(direction,n->v1,n->v2,p)) {
    /* p is visible from n.v2 */
    k = (DCEL_segment *) malloc (sizeof(DCEL_segment));
    
    /* set the coordinats of the new segment */
    k->v1 = p;       /* The "smallest" point */
    k->v2 = n->v2;

    if (direction == l) { 
      /* Add segments left of the new line */
      k->p1 = act->p1;                                /* no 5. */
      k->p2 = n;                                      /* no 2. */
      k->q1 = act;                                    /* no 4. */
      k->q2 = first;                                  /* no 8. */

      n->q2 = k;                                      /* no 1. */
      
      /* set_previous_segment_pointer                    no 7. */
      if (point_equal(act->p1->v1,p))
	act->p1->q1 = k;
      else
	act->p1->q2 = k;
      
      act->p1 = k;                                    /* no 6. */
      first->p2 = k;                                  /* no 3. */ 
      add_segments(k,k->p1,first,direction); }
    else {
      /* Add segments right of the new line */
      k->q1 = act->q1;                                /* no 5. */
      k->q2 = n;                                      /* no 8. */
      k->p1 = act;                                    /* no 4. */
      k->p2 = first;                                  /* no 2. */
      
      n->p2 = k;                                      /* no 1. */
      
      /* set_previous_segment_pointer                    no 7. */
      if (point_equal(act->q1->v1,p))
	act->q1->p1 = k;
      else
	act->q1->p2 = k;
      
      act->q1 = k;                                    /* no 6. */
      first->q2 = k;                                  /* no 3. */ 
      add_segments(k,k->q1,first,direction); }
  }
}
コード例 #2
0
ファイル: trans-common.c プロジェクト: BoxianLai/moxiedev
static void
new_condition (segment_info *v, gfc_equiv *eq1, gfc_equiv *eq2)
{
  HOST_WIDE_INT offset1, offset2;
  segment_info *a;

  offset1 = calculate_offset (eq1->expr);
  offset2 = calculate_offset (eq2->expr);

  a = get_segment_info (eq2->expr->symtree->n.sym,
			v->offset + offset1 - offset2);
 
  current_segment = add_segments (current_segment, a);
}
コード例 #3
0
ファイル: main.c プロジェクト: mmiotk/Teoria-graf-w-i-sieci
int main(void){
	//tests();
	POLYGON temp;
	assert(get_size(&temp.size_points)==TRUE);
	alloc_points(&temp.max_of_x,&temp.points,temp.size_points);
	temp.segments=create_segments(temp.size_points);
	add_segments(temp.points,temp.segments,temp.size_points);
	draw_polygon(temp);
	triangulal_polygol(temp); 
	printf("Potrzeba %d straznikow\n",coloring_sl(temp.points,temp.segments,temp.size_points));
	print_colors(temp.points,temp.size_points);
	draw_polygon(temp);
	free_segments(temp.segments,temp.size_points);
	free_points(temp.points);
	return EXIT_SUCCESS;
}
コード例 #4
0
ファイル: trans-common.c プロジェクト: aosm/gcc_40
static void
new_segment (gfc_common_head *common, gfc_symbol *sym)
{

  current_segment = get_segment_info (sym, current_offset);

  /* The offset of the next common variable.  */
  current_offset += current_segment->length;

  /* Add all object directly or indirectly equivalenced with this common
     variable.  */
  add_equivalences ();

  if (current_segment->offset < 0)
    gfc_error ("The equivalence set for '%s' cause an invalid "
	       "extension to COMMON '%s' at %L", sym->name,
	       common->name, &common->where);

  /* Add these to the common block.  */
  current_common = add_segments (current_common, current_segment);
}
コード例 #5
0
ファイル: trans-common.c プロジェクト: BoxianLai/moxiedev
static void
translate_common (gfc_common_head *common, gfc_symbol *var_list)
{
  gfc_symbol *sym;
  segment_info *s;
  segment_info *common_segment;
  HOST_WIDE_INT offset;
  HOST_WIDE_INT current_offset;
  unsigned HOST_WIDE_INT align;
  bool saw_equiv;

  common_segment = NULL;
  offset = 0;
  current_offset = 0;
  align = 1;
  saw_equiv = false;

  /* Add symbols to the segment.  */
  for (sym = var_list; sym; sym = sym->common_next)
    {
      current_segment = common_segment;
      s = find_segment_info (sym);

      /* Symbol has already been added via an equivalence.  Multiple
	 use associations of the same common block result in equiv_built
	 being set but no information about the symbol in the segment.  */
      if (s && sym->equiv_built)
	{
	  /* Ensure the current location is properly aligned.  */
	  align = TYPE_ALIGN_UNIT (s->field);
	  current_offset = (current_offset + align - 1) &~ (align - 1);

	  /* Verify that it ended up where we expect it.  */
	  if (s->offset != current_offset)
	    {
	      gfc_error ("Equivalence for '%s' does not match ordering of "
			 "COMMON '%s' at %L", sym->name,
			 common->name, &common->where);
	    }
	}
      else
	{
	  /* A symbol we haven't seen before.  */
	  s = current_segment = get_segment_info (sym, current_offset);

	  /* Add all objects directly or indirectly equivalenced with this
	     symbol.  */
	  add_equivalences (&saw_equiv);

	  if (current_segment->offset < 0)
	    gfc_error ("The equivalence set for '%s' cause an invalid "
		       "extension to COMMON '%s' at %L", sym->name,
		       common->name, &common->where);

	  if (gfc_option.flag_align_commons)
	    offset = align_segment (&align);

	  if (offset)
	    {
	      /* The required offset conflicts with previous alignment
		 requirements.  Insert padding immediately before this
		 segment.  */
	      if (gfc_option.warn_align_commons)
		{
		  if (strcmp (common->name, BLANK_COMMON_NAME))
		    gfc_warning ("Padding of %d bytes required before '%s' in "
				 "COMMON '%s' at %L; reorder elements or use "
				 "-fno-align-commons", (int)offset,
				 s->sym->name, common->name, &common->where);
		  else
		    gfc_warning ("Padding of %d bytes required before '%s' in "
				 "COMMON at %L; reorder elements or use "
				 "-fno-align-commons", (int)offset,
				 s->sym->name, &common->where);
		}
	    }

	  /* Apply the offset to the new segments.  */
	  apply_segment_offset (current_segment, offset);
	  current_offset += offset;

	  /* Add the new segments to the common block.  */
	  common_segment = add_segments (common_segment, current_segment);
	}

      /* The offset of the next common variable.  */
      current_offset += s->length;
    }

  if (common_segment == NULL)
    {
      gfc_error ("COMMON '%s' at %L does not exist",
		 common->name, &common->where);
      return;
    }

  if (common_segment->offset != 0 && gfc_option.warn_align_commons)
    {
      if (strcmp (common->name, BLANK_COMMON_NAME))
	gfc_warning ("COMMON '%s' at %L requires %d bytes of padding; "
		     "reorder elements or use -fno-align-commons",
		     common->name, &common->where, (int)common_segment->offset);
      else
	gfc_warning ("COMMON at %L requires %d bytes of padding; "
		     "reorder elements or use -fno-align-commons",
		     &common->where, (int)common_segment->offset);
    }

  create_common (common, common_segment, saw_equiv);
}
コード例 #6
0
ファイル: ch.c プロジェクト: 5432935/crossbridge
CHpoints *construct_ch() {
  DCEL_segment *root;
  /* Left and right are the pointer that point to the segments to
     the left and right of the rightmost point in the convex hull
     at a given time. */
  struct DCEL_segment *left,*right;
  
  CHno=0;   /* reset number of points on hull */
  
  if (!empty()) { 
    /* At least one point was plotted */
    
    /* First segment */
    root=(DCEL_segment *) malloc(sizeof(DCEL_segment));
    root->v1 = delete_min(&Splaytree);
    root->p1 = root;
    root->p2 = root;
    root->q1 = root;
    root->q2 = root;
 
    /* Setup left and right initally */
    left=root;
    right=root;
    
    if (empty()) {
      /* only one point was plotted */
      root->v2 = root->v1; }
    else { 
      /* more than one point was plotted */
      root->v2 = delete_min(&Splaytree);

      /* As long as there are points left extend the convex hull */
      while (!empty()) {
	DCEL_segment *n;
	n = (DCEL_segment *) malloc (sizeof(DCEL_segment));
	
	/* Construct new segment */
	n->v1 = left->v2;
	n->v2 = delete_min(&Splaytree);
	
	/* Set the new segment's pointers */
	n->p1 = left;
	n->q1 = right;
	n->p2 = n;
	n->q2 = n;
	
	/* Set pointers in left and right to point to n. These
	   pointers are the * marked ones in the figure 2 */
	right->p2 = n;
	left->q2 = n;
	
	/* Connect all the visible points "left" of the segment */
	add_segments(n,left,n,l);
	left = n->p2;
	
	/* Connect all the visible points "right" of the segment */
	add_segments(n,right,left,r);
	right = left->q2; }
    }
    free_tree(Splaytree);
    return remove_points(get_points_on_hull(left,right));
  }
}
コード例 #7
0
static void
translate_common (gfc_common_head *common, gfc_symbol *var_list)
{
  gfc_symbol *sym;
  segment_info *s;
  segment_info *common_segment;
  HOST_WIDE_INT offset;
  HOST_WIDE_INT current_offset;
  unsigned HOST_WIDE_INT align;
  unsigned HOST_WIDE_INT max_align;
  bool saw_equiv;

  common_segment = NULL;
  current_offset = 0;
  max_align = 1;
  saw_equiv = false;

  /* Add symbols to the segment.  */
  for (sym = var_list; sym; sym = sym->common_next)
    {
      if (sym->equiv_built)
	{
	  /* Symbol has already been added via an equivalence.  */
	  current_segment = common_segment;
	  s = find_segment_info (sym);

	  /* Ensure the current location is properly aligned.  */
	  align = TYPE_ALIGN_UNIT (s->field);
	  current_offset = (current_offset + align - 1) &~ (align - 1);

	  /* Verify that it ended up where we expect it.  */
	  if (s->offset != current_offset)
	    {
	      gfc_error ("Equivalence for '%s' does not match ordering of "
			 "COMMON '%s' at %L", sym->name,
			 common->name, &common->where);
	    }
	}
      else
	{
	  /* A symbol we haven't seen before.  */
	  s = current_segment = get_segment_info (sym, current_offset);

	  /* Add all objects directly or indirectly equivalenced with this
	     symbol.  */
	  add_equivalences (&saw_equiv);

	  if (current_segment->offset < 0)
	    gfc_error ("The equivalence set for '%s' cause an invalid "
		       "extension to COMMON '%s' at %L", sym->name,
		       common->name, &common->where);

	  offset = align_segment (&align);

	  if (offset & (max_align - 1))
	    {
	      /* The required offset conflicts with previous alignment
		 requirements.  Insert padding immediately before this
		 segment.  */
	      gfc_warning ("Padding of %d bytes required before '%s' in "
			   "COMMON '%s' at %L", offset, s->sym->name,
			   common->name, &common->where);
	    }
	  else
	    {
	      /* Offset the whole common block.  */
	      apply_segment_offset (common_segment, offset);
	    }

	  /* Apply the offset to the new segments.  */
	  apply_segment_offset (current_segment, offset);
	  current_offset += offset;
	  if (max_align < align)
	    max_align = align;

	  /* Add the new segments to the common block.  */
	  common_segment = add_segments (common_segment, current_segment);
	}

      /* The offset of the next common variable.  */
      current_offset += s->length;
    }

  if (common_segment->offset != 0)
    {
      gfc_warning ("COMMON '%s' at %L requires %d bytes of padding at start",
		   common->name, &common->where, common_segment->offset);
    }

  create_common (common, common_segment, saw_equiv);
}