Esempio n. 1
0
int
main(		/* compile a .OBJ file into a mesh */
	int  argc,
	char  *argv[]
)
{
	int  nmatf = 0;
	char  pathnames[12800];
	char  *pns = pathnames;
	char  *matinp[128];
	char  *cp;
	int  i, j;

	progname = argv[0];
	ofun[OBJ_FACE].funp = o_face;

	for (i = 1; i < argc && argv[i][0] == '-'; i++)
		switch (argv[i][1]) {
		case 'n':				/* set limit */
			objlim = atoi(argv[++i]);
			break;
		case 'r':				/* resolution limit */
			resolu = atoi(argv[++i]);
			break;
		case 'a':				/* material file */
			matinp[nmatf++] = argv[++i];
			break;
		case 'l':				/* library material */
			cp = getpath(argv[++i], getrlibpath(), R_OK);
			if (cp == NULL) {
				sprintf(errmsg,
					"cannot find library material: '%s'",
						argv[i]);
				error(USER, errmsg);
			}
			matinp[nmatf++] = strcpy(pns, cp);
			while (*pns++)
				;
			break;
		case 'w':				/* supress warnings */
			nowarn = 1;
			break;
		default:
			sprintf(errmsg, "unknown option: '%s'", argv[i]);
			error(USER, errmsg);
			break;
		}

	if (i < argc-2)
		error(USER, "too many file arguments");
					/* initialize mesh */
	cvinit(i==argc-2 ? argv[i+1] : "<stdout>");
					/* load material input */
	for (j = 0; j < nmatf; j++)
		readobj(matinp[j]);
					/* read .OBJ file into triangles */
	if (i == argc)
		wfreadobj(NULL);
	else
		wfreadobj(argv[i]);
	
	cvmeshbounds();			/* set octree boundaries */

	if (i == argc-2)		/* open output file */
		if (freopen(argv[i+1], "w", stdout) == NULL)
			error(SYSTEM, "cannot open output file");
	SET_FILE_BINARY(stdout);
	newheader("RADIANCE", stdout);	/* new binary file header */
	printargs(i<argc ? i+1 : argc, argv, stdout);
	fputformat(MESHFMT, stdout);
	fputc('\n', stdout);

	mincusize = ourmesh->mcube.cusize / resolu - FTINY;

	for (i = 0; i < nobjects; i++)	/* add triangles to octree */
		if (objptr(i)->otype == OBJ_FACE)
			addface(&ourmesh->mcube, i);

					/* optimize octree */
	ourmesh->mcube.cutree = combine(ourmesh->mcube.cutree);

	if (ourmesh->mcube.cutree == EMPTY)
		error(WARNING, "mesh is empty");
	
	cvmesh();			/* convert mesh and leaf nodes */

	writemesh(ourmesh, stdout);	/* write mesh to output */
	
	/* printmeshstats(ourmesh, stderr); */

	quit(0);
	return 0; /* pro forma return */
}
Esempio n. 2
0
/*============================================================================*/
int main (int argc, char **argv)                                               {
/* printf("argc=%d\n", argc);  */
#ifdef PROOL
if(argc==3)
{
exitif(strlen(argv[1])>195, "unical: sorry input file name too long.", NULL);
strcpy(inname, argv[1]);
exitif(strlen(argv[1])>195, "unical: sorry output file name too long.", NULL);
strcpy(outname, argv[2]);
printf("unical1, Copyright(C) 2011 Bernhardi \n");
printf("some modif. by prool, 2015. www.prool.kharkov.org\n");
printf("unical comes with ABSOLUTELY NO WARRANTY. This is free\n");
printf("software, and you are welcome to redistribute it under\n");
printf("certain conditions, see http://www.gnu.org/licenses/gpl.html\n\n");
}
else
{
printf("unical: usage: unical inputfile outputfile\n");
exit(0);
}
#else
if(argc==2)                                                               {
exitif(strlen(argv[1])>195, "unical: sorry file name too long.", NULL);
strcpy(problem, argv[1]);
full=0;                                                                   }
else if(argc==3)                                                          {
exitif(strncmp(argv[1],"-f",2)!=0, "unical: command not understood.", NULL);
exitif(strlen(argv[2])>195, "unical: sorry file name too long.", NULL);
strcpy(problem, argv[2]);
full=1;                                                                   }
else                                                                      {
printf("unical: usage: unical [-f] unv_filename (without extension .unv)\n");
exit(0);                                                                  }

printf("unical1, Copyright(C) 2011 Bernhardi \n");   
printf("unical comes with ABSOLUTELY NO WARRANTY. This is free\n");
printf("software, and you are welcome to redistribute it under\n");
printf("certain conditions, see http://www.gnu.org/licenses/gpl.html\n\n");

strcpy(inname, problem);
strcat(inname, ".unv");
#endif

#ifdef PROOL
process_e(inname); // convert exponent letter D+00 to E+00
strcpy(inname,TMPNAME);
#endif 

printf("unical: Reading from file %s\n",inname);
fid = fopen(inname,"r");
exitif(fid==0,"Error reading from file ",inname);

countuni();     /* determine number of elements, nodes, etc. */
printf("unical: maxnode=%d, sumele=%d\n", maxnode, sumele);
allocate();     /* allocate large arrays. */
rewind(fid);
readnodes();    /* read nodes: coordinates. */
rewind(fid);
readelements(); /* read element connectivities. */
rewind(fid);
readgroups();   /* read group information. */

/* close universal file  */
printf("unical: closing universal file %s\n", inname);
ret = fclose(fid);
exitif(ret < 0,"while attempting to close file ",inname);  

#ifndef PROOL
strcpy(outname, problem);
strcat(outname, ".inp");
#endif
printf("unical: writing to file %s\n",outname);
fid = fopen(outname,"w");
exitif(fid==0,"Error opening file ",outname);
writemesh(); /* write node point and element data to abaqus/calculix input file. */
surface();   /* process groups for boundary conditions. */

#ifndef PROOL
/* write standard ABAQUS procedure calls: *frequency step. */
fprintf(fid,"*material, name=steel\n");
fprintf(fid,"*elastic\n");
fprintf(fid,"209000.0, 0.3\n");
fprintf(fid,"*density\n");
fprintf(fid,"7.85e-09\n");
fprintf(fid,"*step\n");
fprintf(fid,"*frequency\n");
fprintf(fid,"12\n");
fprintf(fid,"*nodefile\n");
fprintf(fid,"u\n");
fprintf(fid,"*elfile, output=3D\n");
fprintf(fid,"s, e\n");
fprintf(fid,"*endstep\n");
#endif

/* close abaqus/calculix input file  */
printf("unical: closing file %s\n", outname);
ret = fclose(fid);
exitif(ret < 0,"while attempting to close file ",outname);  

printf("unical: It was a pleasure serving you. Bye. \n");
printf("unical: returning to system. \n");
#ifdef PROOL
if (remove(TMPNAME)) {printf("can't delete tmp file `%s'\n",TMPNAME); exit(1);}
#endif
exit(0);                                                                      }