Пример #1
0
{
	STREAMOUT	*sop = (STREAMOUT *)p;
	
	if (sop->ofp != NULL) {
		int	status = 0;
		if (sop->outpipe)
			status = pclose(sop->ofp);
		else if (sop->ofp != stdout)
			status = fclose(sop->ofp);
		if (status)
			error(SYSTEM, "error closing output stream");
	}
	free(p);
}

LUTAB	ofiletab = LU_SINIT(free,closestream);	/* output file table */

#define OF_MODIFIER	01
#define OF_BIN		02

/************************** STREAM & FILE I/O ***************************/

/* Construct output file name and return flags whether modifier/bin present */
static int
ofname(char *oname, const char *ospec, const char *mname, int bn)
{
	const char	*mnp = NULL;
	const char	*bnp = NULL;
	const char	*cp;
	
	if (ospec == NULL)
Пример #2
0
				/* keep consistent with above */
enum {TYP_UNKNOWN, TYP_TEXT, TYP_ASCII, TYP_RGBE, TYP_XYZE, TYP_FLOAT,
		TYP_DOUBLE, TYP_RBFMESH, TYP_OCTREE, TYP_TMESH, TYP_BINARY};
		
#define has_header(t)	(!( 1L<<(t) & (1L<<TYP_TEXT | 1L<<TYP_BINARY) ))

				/* header variables to always ignore */
const char	*hdr_ignkey[] = {
			"SOFTWARE",
			"CAPDATE",
			"GMT",
			"FRAME",
			NULL	/* terminator */
		};
				/* header variable settings */
LUTAB	hdr1 = LU_SINIT(free,free);
LUTAB	hdr2 = LU_SINIT(free,free);

				/* advance appropriate file line count */
#define adv_linecnt(htp)	(lin1cnt += (htp == &hdr1), \
					lin2cnt += (htp == &hdr2))

typedef struct {		/* dynamic line buffer */
	char	*str;
	int	len;
	int	siz;
} LINEBUF;

#define init_line(bp)	((bp)->str = NULL, (bp)->siz = 0)
				/* 100 MByte limit on line buffer */
#define MAXBUF		(100L<<20)
Пример #3
0
static long  ogetint(int);
static char  *ogetstr(char *);
static int  loadobj(void);
static void  skiptree(void);
static void  octerror(int etyp, char *msg);
static OCTINST	*getoct(char *);

static char  *infn;			/* input file name */
static FILE  *infp;			/* input file stream */
static int  objsize;			/* size of stored OBJECT's */
static short  otypmap[NUMOTYPE+8];	/* object type map */

static unsigned long	imhash(const char *mod) {return((unsigned long)mod);}
static LUTAB	imtab = {imhash,NULL,NULL,NULL,0,NULL,0};

static LUTAB	ottab = LU_SINIT(free,free);


int
o_instance(o)				/* convert instance to list call */
register OBJREC	*o;
{
	XF	xfs;
	register OCTINST	*ot;
					/* set up */
	if (o->oargs.nsargs < 1)
		objerror(o, USER, "missing octree");
	setmaterial(NULL, NULL, 0);
					/* put out transform (if any) */
	if (o->oargs.nsargs > 1) {
		if (xf(&xfs, o->oargs.nsargs-1, o->oargs.sarg+1) !=
Пример #4
0
#define O_VRML1		3	/* VRML 1.0 output */

#define MAXID		48	/* maximum identifier length */

#define VERTFMT		"%+16.9e %+16.9e %+16.9e\n%+6.3f %+6.3f %+6.3f"
#define VZVECT		"+0.000 +0.000 +0.000"
#define VFLEN		92	/* total vertex string length */
#define MAXVERT		10240	/* maximum cached vertices */

#define setvkey(k,v)	sprintf(k,VERTFMT,(v)->p[0],(v)->p[1],(v)->p[2],\
					(v)->n[0],(v)->n[1],(v)->n[2]);

char	vlist[MAXVERT][VFLEN];	/* our vertex cache */
int	nverts;			/* current cache size */

LUTAB	vert_tab = LU_SINIT(NULL,NULL);

struct face {
	struct face	*next;		/* next face in list */
	short		nv;		/* number of vertices */
	short		vl[3];		/* vertex index list (variable) */
}	*flist, *flast;		/* our face cache */

#define newface(n)	(struct face *)malloc(sizeof(struct face) + \
				((n) > 3 ? (n)-3 : 0)*sizeof(short))
#define freeface(f)	free(f)

#define	TABSTOP		8	/* assumed number of characters per tab */
#define	SHIFTW		2	/* nesting shift width */
#define MAXIND		15	/* maximum indent level */
Пример #5
0
#ifndef lint
static const char	RCSid[] = "$Id$";
#endif
/*
 * Routines for Radiance -> OpenGL materials.
 */

#include "copyright.h"

#include "radogl.h"

int	domats = 1;			/* are we doing materials? */

extern lut_free_t	freemtl;

LUTAB	mtab = LU_SINIT(free,freemtl);


void
rgl_matclear(void)			/* clean up materials */
{
	lu_done(&mtab);
	domats = 1;
}


MATREC *
getmatp(			/* find material record for modifier name */
	char	*nam
)
{
Пример #6
0
#include <ctype.h>
#include <string.h>
#include <stdio.h>

#include "platform.h"
#include "rtmath.h"
#include "rtio.h"
#include "rtprocess.h"
#include "object.h"
#include "color.h"
#include "lookup.h"

#define C_1SIDEDTHICK	0.005


LUTAB	rmats = LU_SINIT(free,NULL);		/* defined material table */

LUTAB	rdispatch = LU_SINIT(NULL,NULL);	/* function dispatch table */

char	curmat[80];				/* current material */
char	curobj[128] = "Untitled";		/* current object name */

double	unit_mult = 1.;				/* units multiplier */

#define hasmult		(unit_mult < .999 || unit_mult > 1.001)

/*
 * Stuff for tracking and reusing vertices:
 */

char	VKFMT[] = "%+16.9e %+16.9e %+16.9e";