Ejemplo n.º 1
0
/*
    Extract both points that make up a bone measurement.
*/
void writePoints ( int cat, int skelID, int boneID, int unitID )
{
    double *xpnts, *ypnts, *zpnts;
    
    	
    xpnts = G_malloc ( sizeof ( double ) * 1 );
    ypnts = G_malloc ( sizeof ( double ) * 1 );
    zpnts = G_malloc ( sizeof ( double ) * 1 );
    
    xpnts[0] = ax;
    ypnts[0] = ay;
    zpnts[0] = az;
    
    write_vect ( cat, skelID, boneID, unitID, xpnts, ypnts, zpnts, 1, GV_POINT );    
    
    xpnts[0] = bx;
    ypnts[0] = by;
    zpnts[0] = bz;
    
    write_vect ( cat + 1, skelID, boneID, unitID, xpnts, ypnts, zpnts, 1, GV_POINT );
    
    G_free ( xpnts );  
    G_free ( ypnts );
    G_free ( zpnts );        
}
Ejemplo n.º 2
0
/*
    Construct a 3D pyramid enclosing two point measurements.
*/
void writeTriangle ( int cat, int skelID, int boneID, int unitID, 
                     double xys[], int start1, int start2 )
{
    double *xpnts, *ypnts, *zpnts;
    
    	
    xpnts = G_malloc ( sizeof ( double ) * 4 );
    ypnts = G_malloc ( sizeof ( double ) * 4 );
    zpnts = G_malloc ( sizeof ( double ) * 4 );
    
    xpnts[0] = bx;
    ypnts[0] = by;
    zpnts[0] = bz;
    
    xpnts[1] = xys[start1];
    ypnts[1] = xys[start1 + 1];
    zpnts[1] = xys[start1 + 2];
   
    xpnts[2] = xys[start2];
    ypnts[2] = xys[start2 + 1];
    zpnts[2] = xys[start2 + 2];

    xpnts[3] = bx;
    ypnts[3] = by;
    zpnts[3] = bz;
    
    write_vect ( cat, skelID, boneID, unitID, xpnts, ypnts, zpnts, 4, GV_FACE );
    
    G_free ( xpnts );  
    G_free ( ypnts );
    G_free ( zpnts );    
}
Ejemplo n.º 3
0
/*
    Construct a straight line between two point measurements.
*/
void writeLine ( int cat, int skelID, int boneID, int unitID )
{
    double *xpnts, *ypnts, *zpnts;
    
    	
    xpnts = G_malloc ( sizeof ( double ) * 2 );
    ypnts = G_malloc ( sizeof ( double ) * 2 );
    zpnts = G_malloc ( sizeof ( double ) * 2 );
    
    xpnts[0] = ax;
    ypnts[0] = ay;
    zpnts[0] = az;
    
    xpnts[1] = bx;
    ypnts[1] = by;
    zpnts[1] = bz;
    
    write_vect ( cat, skelID, boneID, unitID, xpnts, ypnts, zpnts, 2, GV_LINE );
    
    G_free ( xpnts );  
    G_free ( ypnts );
    G_free ( zpnts );
}
Ejemplo n.º 4
0
/*
    Construct a 3D rectangular plane enclosing two point measurements.
*/
void writeSquare( int cat, int skelID, int boneID, int unitID, 
                     double xys[] )
{
    double *xpnts, *ypnts, *zpnts;
    
    	
    xpnts = G_malloc ( sizeof ( double ) * 5 );
    ypnts = G_malloc ( sizeof ( double ) * 5 );
    zpnts = G_malloc ( sizeof ( double ) * 5 );
    
    xpnts[0] = xys[0];
    ypnts[0] = xys[1];
    zpnts[0] = xys[2];
    
    xpnts[1] = xys[3];
    ypnts[1] = xys[4];
    zpnts[1] = xys[5];
   
    xpnts[2] = xys[6];
    ypnts[2] = xys[7];
    zpnts[2] = xys[8];

    xpnts[3] = xys[9];
    ypnts[3] = xys[10];
    zpnts[3] = xys[11];

    xpnts[4] = xys[0];
    ypnts[4] = xys[1];
    zpnts[4] = xys[2];    
    
    write_vect ( cat, skelID, boneID, unitID, xpnts, ypnts, zpnts, 5, GV_FACE );
    
    G_free ( xpnts );  
    G_free ( ypnts );
    G_free ( zpnts );
}
Ejemplo n.º 5
0
void add_circle(struct dxf_file *dxf, struct Map_info *Map)
{
    int code;
    char handle[DXF_BUF_SIZE];	/* entity handle, 16 hexadecimal digits */
    char layer[DXF_BUF_SIZE];	/* layer name */
    int layer_flag = 0;		/* indicates if a layer name has been found */
    int xflag = 0;		/* indicates if a x value has been found */
    int yflag = 0;		/* indicates if a y value has been found */
    int rflag = 0;		/* indicates if a radius has been found */
    double centerx = 0;		/* read in from dxf file */
    double centery = 0;		/* read in from dxf file */
    double radius = 0;		/* read in from dxf file */
    double zcoor = 0;		/* read in from dxf file */
    int arr_size = 0;

    handle[0] = 0;
    strcpy(layer, UNIDENTIFIED_LAYER);

    /* read in lines and process information until a 0 is read in */
    while ((code = dxf_get_code(dxf)) != 0) {
        if (code == -2)
            return;

        switch (code) {
        case 5:		/* entity handle */
            strcpy(handle, dxf_buf);
            break;
        case 8:		/* layer name */
            if (!layer_flag && *dxf_buf) {
                if (flag_list) {
                    if (!is_layer_in_list(dxf_buf))
                        add_layer_to_list(dxf_buf, 1);
                    return;
                }
                /* skip if (opt_layers != NULL && (
                 * (flag_invert == 0 && is_layer_in_list == 0) ||
                 * (flag_invert == 1 && is_layer_in_list == 1)
                 * )
                 */
                if (opt_layers && flag_invert == is_layer_in_list(dxf_buf))
                    return;
                strcpy(layer, dxf_buf);
                layer_flag = 1;
            }
            break;
        case 10:		/* x coordinate */
            centerx = atof(dxf_buf);
            xflag = 1;
            break;
        case 20:		/* y coordinate */
            centery = atof(dxf_buf);
            yflag = 1;
            break;
        case 30:		/* z coordinate */
            zcoor = atof(dxf_buf);
            break;
        case 40:		/* radius */
            radius = atof(dxf_buf);
            rflag = 1;
            break;
        }
    }

    if (xflag && yflag && rflag) {
        arr_size = make_arc(0, centerx, centery, radius, 0.0, 360.0, zcoor);
        write_vect(Map, layer, "CIRCLE", handle, "", arr_size, GV_LINE);
    }

    return;
}
Ejemplo n.º 6
0
int write_grid(struct grid_description *grid_info, struct Map_info *Map, int nbreaks, int out_type)
{

    int i, k, j;
    int rows, cols;
    int num_v_rows, num_v_cols;
    double x, y, x_len, y_len;
    double sx, sy;
    double width, length;
    double next_x, next_y;
    double snext_x, snext_y;
    double angle, dum;

    struct line_pnts *Points;

    Points = Vect_new_line_struct();

    num_v_rows = grid_info->num_vect_rows;
    num_v_cols = grid_info->num_vect_cols;
    rows = grid_info->num_rows;
    cols = grid_info->num_cols;
    width = grid_info->width;
    length = grid_info->length;
    angle = grid_info->angle;

    /*
     * For latlon, must draw in shorter sections
     * to make sure that each section of the grid
     * line is less than half way around the globe
     */
     x_len = length / (1. * nbreaks + 1);
     y_len = width / (1. * nbreaks + 1);

    /* write out all the vector lengths (x vectors) of the entire grid  */
    G_verbose_message(_("Writing out vector rows..."));
    y = grid_info->origin_y;
    for (i = 0; i < num_v_rows; ++i) {
	double startx;

	startx = grid_info->origin_x;
	G_percent(i, num_v_rows, 2);

	for (k = 0; k < cols; k++) {
	    x = startx;
            j = 0;
	    do {
		if (j < nbreaks)
		    next_x = x + x_len;
		else
		    next_x = startx + length;

		sx = x;
		sy = y;
		snext_x = next_x;
		dum = y;

		rotate(&x, &y, grid_info->origin_x, grid_info->origin_y,
		       angle);
		rotate(&next_x, &dum, grid_info->origin_x,
		       grid_info->origin_y, angle);
		write_vect(x, y, next_x, dum, Map, Points, out_type);

		y = sy;
		x = next_x = snext_x;
                j++;
	    } while (j <= nbreaks);
	    startx += length;
	}
	y += width;
    }

    /* write out all the vector widths (y vectors) of the entire grid  */
    G_verbose_message(_("Writing out vector columns..."));
    x = grid_info->origin_x;
    for (i = 0; i < num_v_cols; ++i) {
        double starty;
	starty = grid_info->origin_y;
	G_percent(i, num_v_cols, 2);

	for (k = 0; k < rows; k++) {
	  y = starty;
	  j = 0;
	  do {
	      if (j < nbreaks)
		  next_y = y + y_len;
	      else
		  next_y = starty + width;

	      sx = x;
	      sy = y;
	      snext_y = next_y;
	      dum = x;
	      rotate(&x, &y, grid_info->origin_x, grid_info->origin_y, angle);
	      rotate(&dum, &next_y, grid_info->origin_x, grid_info->origin_y,
		    angle);

	      write_vect(x, y, dum, next_y, Map, Points, out_type);

	      x = sx;
	      y = next_y = snext_y;
	      j++;
	  } while (j <= nbreaks);
	  /* To get exactly the same coordinates as above, y+=width is wrong */
	  starty += width;
	}
	x += length;
    }

    /* new with Vlib */
    Vect_destroy_line_struct(Points);

    return (0);
}
Ejemplo n.º 7
0
void add_text(struct dxf_file *dxf, struct Map_info *Map)
{
    int code;
    char handle[DXF_BUF_SIZE];	/* entity handle, 16 hexadecimal digits */
    char layer[DXF_BUF_SIZE];	/* layer name */
    int layer_flag = 0;		/* indicates if a layer name has been found */
    int xflag = 0;		/* indicates if a x value has been found */
    int yflag = 0;		/* indicates if a y value has been found */
    double height = 1.0;	/* read in from dxf file */
    double angle = 0.0;		/* read in from dxf file */
    char label[DXF_BUF_SIZE];	/* read in from dxf file */
    int label_len = 0;

    handle[0] = 0;
    strcpy(layer, UNIDENTIFIED_LAYER);

    zpnts[0] = 0.0;
    /* read in lines and process information until a 0 is read in */
    while ((code = dxf_get_code(dxf)) != 0) {
        if (code == -2)
            return;

        switch (code) {
        case 1:		/* label value */
            label_len = strlen(dxf_buf);
            strcpy(label, dxf_buf);
            break;
        case 5:		/* entity handle */
            strcpy(handle, dxf_buf);
            break;
        case 8:		/* layer name */
            if (!layer_flag && *dxf_buf) {
                if (flag_list) {
                    if (!is_layer_in_list(dxf_buf))
                        add_layer_to_list(dxf_buf, 1);
                    return;
                }
                /* skip if (opt_layers != NULL && (
                 * (flag_invert == 0 && is_layer_in_list == 0) ||
                 * (flag_invert == 1 && is_layer_in_list == 1)
                 * )
                 */
                if (opt_layers && flag_invert == is_layer_in_list(dxf_buf))
                    return;
                strcpy(layer, dxf_buf);
                layer_flag = 1;
            }
            break;
        case 10:		/* x coordinate */
            xpnts[0] = atof(dxf_buf);
            xflag = 1;
            break;
        case 20:		/* y coordinate */
            ypnts[0] = atof(dxf_buf);
            yflag = 1;
            break;
        case 30:		/* z coordinate */
            zpnts[0] = atof(dxf_buf);
            break;
        case 40:		/* text height */
            height = atof(dxf_buf);
            break;
        case 50:		/* text angle */
            angle = atof(dxf_buf);
            break;

        case 7:		/* text style name */
        case 11:		/* alignment point */
        case 21:		/* alignment point */
        case 31:		/* alignment point */
        case 41:		/* relative x scale factor */
        case 51:		/* oblique angle */
        case 71:		/* text generation flag */
        case 72:		/* horizontal text justification type */
            break;
        }
    }

    if (label_len == 0)
        return;

    if (xflag && yflag) {
        /* TODO */
#if 0
        double theta, length, diag, base1, base2;

        /* now build the points of the box */
        theta = angle * M_PI / 180.;
        length = (label_len - 1) * height;

        /* base angles for polar description of rectangle */
        base1 = M_PI / 2.;
        base2 = atan2(1., (double)(label_len - 1));
        diag = hypot(length, height);

        xpnts[4] = xpnts[0];
        ypnts[4] = ypnts[0];
        zpnts[4] = zpnts[0];

        xpnts[1] = xpnts[0] + (height * cos(theta + base1));
        ypnts[1] = ypnts[0] + (height * sin(theta + base1));
        zpnts[1] = zpnts[0];

        xpnts[2] = xpnts[0] + (diag * cos(theta + base2));
        ypnts[2] = ypnts[0] + (diag * sin(theta + base2));
        zpnts[2] = zpnts[0];

        xpnts[3] = xpnts[0] + (length * cos(theta));
        ypnts[3] = ypnts[0] + (length * sin(theta));
        zpnts[3] = zpnts[0];

        write_vect(Map, layer, "TEXT", handle, "", 5, GV_LINE);
#endif
        write_vect(Map, layer, "TEXT", handle, label, 1, GV_POINT);
    }

    return;
}