Пример #1
0
LONGMATRIX_VECTOR *read_fine_indices(char *filename,short print) {
	/*!
	 * \author Emanuele Cordano
	 * date May 2009
	 *
	 * \param (char*) - name of filename
	 *\param (short) -
	 */
	LONGMATRIX_VECTOR *lm;
	FILE *fd;
	long j,n_po;
	fd=t_fopen(filename,"r");

	n_po=(long)read_index(fd,no_PRINT);
	lm=new_longmatrix_vector(n_po);

	for (j=lm->nl;j<=lm->nh;j++) {
		if (print==1) printf("Function read_fine_indices element %ld of %ld is being defined \n",j,lm->nh);
		lm->element[j]=read_longmatrix(fd,"a",no_PRINT);
		if (print==1) printf("Function read_fine_indices element %ld of %ld is read [%ld,%ld] f.e. %ld \n",j,lm->nh,lm->element[j]->nrh,lm->element[j]->nrh,lm->element[j]->element[1][1]);
		if (!lm->element[j]) t_error("lm->element[j] in read_fine_indices was not defined");

	//		if (polygons->element[j]->index!=j) printf ("Error in read_polygonvector (polygon %ld) inconstancy: %ld %ld \n",j,j,polygons->element[j]->index);
	}

	t_fclose(fd);

	if (print==1) printf("Function read_fine_indices was successfully executed! \n");

	return lm;
}
Пример #2
0
polygon_connection_attribute_array *read_connection_attribute_array(char *filename,short print) {
	/*!
	 *
	 * \author Emanuele Cordano
	 * \author May 2008
	 *
	 *\param (char*) - name of filename
	 *\param (short) -
	 *
	 *\brief It creates and reads a polygonvector from the following options:
	 */
	polygon_connection_attribute_array *pca;
	FILE *fd;
	long j,n_po;

	fd=t_fopen(filename,"r");
	n_po=(long)read_index(fd,no_PRINT);
	pca=new_connection_attributes(n_po);

	for (j=pca->nl;j<=pca->nh;j++) {
		pca->element[j]=read_connections(fd,print);

	//	if (pca->element[j]->index!=j) printf ("Error in read_connection_attributes (polygon %ld) inconstancy: %ld %ld \n",j,j,pca->element[j]->index);
	}

	t_fclose(fd);
	if (print==1) printf("Function read_connection_attributes (number of polygons %ld) was successfully executed!!",pca->nh);

	return pca;

}
Пример #3
0
LINEVECTOR *read_linevector (char *filename, short print) {
	/*!
	 * \author Emanuele Cordano
	 * \date May 2009
	 *
	 *\param filename (char *) - name of the file where to read line_information
	 *\param print (short)
	 *
	 *
	 *\brief It creates and reads a linevector from the following options:
	 *\brief index{1}
	 *  FILE CONTAINIG NECESSARY INFORMATION FOR LINES
			x    y    line_index    lenght2d    x_P1    y_P1    x_P2   y_P2

			1: double matrix lines information  {55550,8}
	 */

	FILE *fd;
	DOUBLEMATRIX *ldata;
	LINEVECTOR *lines;
	POINT *P1,*P2;
	long index,j,ja;

	int ix=1; /*! x coordinate of the middle point */
	int iy=ix+1; /*! y coordinate of the midddele point */
	int iline_index=iy+1; /*! iline_index of the line */
	int ilength2d=iline_index+1; /*! lenght of the line */
	int iP1_x=ilength2d+1; /*! P1 x coordinate */
	int iP1_y=iP1_x+1; /*! P1 y coordinate */
	int iP2_x=iP1_y+1; /*! P2 x coordinate */
	int iP2_y=iP2_x+1; /*! P2 y coordinate */
	int indata=iP2_y; /* number of data */

	fd=t_fopen(filename,"r");
	index=(long)read_index(fd,no_PRINT);
	ldata=read_doublematrix(fd,"a",no_PRINT);
	if (ldata->nch!=indata) printf("Warning in read_linevector: inconstancy on number of columns (data) : %ld %d \n",ldata->nch,indata);
	//if (ldata->nrh!=index)  printf("Error in read_linevector: inconstancy on number of lines : %ld %ld",ldata->nrh,index);
	lines=new_linevector(ldata->nrh);
	for (j=lines->nl;j<=lines->nh;j++) {
		ja=(long)ldata->element[j][iline_index];
		if (j!=ja) printf("Error in read_linevector (line %ld of %ld): inconstancy on line index : %ld %ld \n",j,lines->nh,j,ja);
		P1=new_point(j-1,ldata->element[j][iP1_x],ldata->element[j][iP1_y],NULL_ELEVATION);
		P2=new_point(j,ldata->element[j][iP2_x],ldata->element[j][iP2_y],NULL_ELEVATION);
		lines->element[j]=new_line_from_points(j,P1,P2);
		free_point(P1);
		free_point(P2);

	}

	free_doublematrix(ldata);
	if (print==1) printf("Function read_linevector (number of lines %ld) was successfully executed!! \n",lines->nh);

	return lines;

}
Пример #4
0
LONGBIN *read_line_indices(char *filename,short print) {
	/*
	 *
	 * \author Emanuele Cordano
	 * date May 2009
	 *
	 * \param (char*) - name of filename
	 *\param (short) -
	 *
	 */
	LONGVECTOR **lv;
	LONGBIN *lb;
	LONGVECTOR *vi;
	FILE *fd;
	long j,n_l,c;
	fd=t_fopen(filename,"r");

	n_l=(long)read_index(fd,print);
//	printf("n_l=%ld",n_l);

	lv=(LONGVECTOR **)malloc((size_t)(n_l*sizeof(LONGVECTOR *)));
//	stop_execution();
	for (j=0;j<=n_l-1;j++) {
		lv[j]=read_longarray(fd,print);
	}
	vi=new_longvector(n_l);
	for (j=vi->nl;j<=vi->nh;j++) {
		vi->element[j]=lv[j-1]->nh;
	}
	lb=new_longbin(vi);
	for (j=lb->index->nl;j<=lb->index->nh;j++) {
		for(c=1;c<=lb->index->element[j];c++) {
			lb->element[j][c]=lv[j-1]->element[c];
		}
	}

	free_longvector(vi);
	for (j=0;j<=n_l-1;j++) {
			free_longvector(lv[j]);
	}
	free(lv);
	t_fclose(fd);

	if (print==1) printf("Function read_line_indices was successfully executed! \n");




	return lb;


}
Пример #5
0
	if (ch != EOF)
		ungetc(ch, tf->file);
	return (1);
}


/***************************************************************************
 * Lines without words
 */

T_FUNC(empty_input, "empty input")
{
	struct t_file *tf;
	int ret;

	tf = t_fopen(NULL);
	ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
	t_fclose(tf);
	return (ret);
}

T_FUNC(empty_line, "empty line")
{
	struct t_file *tf;
	int ret;

	tf = t_fopen(NULL);
	t_fprintf(tf, "\n");
	t_frewind(tf);
	ret = orw_expect(tf, NULL, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
	t_fclose(tf);