static boolean
llvm_middle_end_linear_run_elts(struct draw_pt_middle_end *middle,
                                unsigned start,
                                unsigned count,
                                const ushort *draw_elts,
                                unsigned draw_count,
                                unsigned prim_flags)
{
   struct llvm_middle_end *fpme = llvm_middle_end(middle);
   struct draw_fetch_info fetch_info;
   struct draw_prim_info prim_info;

   fetch_info.linear = TRUE;
   fetch_info.start = start;
   fetch_info.count = count;
   fetch_info.elts = NULL;

   prim_info.linear = FALSE;
   prim_info.start = 0;
   prim_info.count = draw_count;
   prim_info.elts = draw_elts;
   prim_info.prim = prim_type(fpme->input_prim, prim_flags);
   prim_info.flags = prim_flags;
   prim_info.primitive_count = 1;
   prim_info.primitive_lengths = &draw_count;

   llvm_pipeline_generic( middle, &fetch_info, &prim_info );

   return TRUE;
}
static void
llvm_middle_end_linear_run(struct draw_pt_middle_end *middle,
                           unsigned start,
                           unsigned count,
                           unsigned prim_flags)
{
   struct llvm_middle_end *fpme = llvm_middle_end(middle);
   struct draw_fetch_info fetch_info;
   struct draw_prim_info prim_info;

   fetch_info.linear = TRUE;
   fetch_info.start = start;
   fetch_info.count = count;
   fetch_info.elts = NULL;

   prim_info.linear = TRUE;
   prim_info.start = 0;
   prim_info.count = count;
   prim_info.elts = NULL;
   prim_info.prim = prim_type(fpme->input_prim, prim_flags);
   prim_info.flags = prim_flags;
   prim_info.primitive_count = 1;
   prim_info.primitive_lengths = &count;

   llvm_pipeline_generic( middle, &fetch_info, &prim_info );
}
static void
llvm_middle_end_run(struct draw_pt_middle_end *middle,
                    const unsigned *fetch_elts,
                    unsigned fetch_count,
                    const ushort *draw_elts,
                    unsigned draw_count,
                    unsigned prim_flags)
{
   struct llvm_middle_end *fpme = llvm_middle_end(middle);
   struct draw_fetch_info fetch_info;
   struct draw_prim_info prim_info;

   fetch_info.linear = FALSE;
   fetch_info.start = 0;
   fetch_info.elts = fetch_elts;
   fetch_info.count = fetch_count;

   prim_info.linear = FALSE;
   prim_info.start = 0;
   prim_info.count = draw_count;
   prim_info.elts = draw_elts;
   prim_info.prim = prim_type(fpme->input_prim, prim_flags);
   prim_info.flags = prim_flags;
   prim_info.primitive_count = 1;
   prim_info.primitive_lengths = &draw_count;

   llvm_pipeline_generic( middle, &fetch_info, &prim_info );
}
Exemple #4
0
PUBLIC void init_type(void)
{
     void_type = prim_type("void");
     char_type = prim_type("char");
     int_type = prim_type("integer");
     bool_type = prim_type("boolean");
     scalar_type = prim_type("*scalar*");
     string_type = prim_type("*string*");
     text_type = prim_type("text");
     err_type = prim_type("*err_type*");

     def_const("true", bool_type, "TRUE");
     def_const("false", bool_type, "FALSE");
     dummy_def = def_const("*dummy*", err_type, "");

     _input_ = declare(VAR, enter("input", BUILTIN), text_type);
     _output_ = declare(VAR, enter("output", BUILTIN), text_type);
}
Exemple #5
0
int main(int argc, char **argv) {	
	FILE *fp, *foff, *ftrans;
	
	Val v;
	lang_defun("sphere", sphere_parse);
	lang_defun("conep", conep_parse);
	lang_defun("cylin", cylin_parse);
	
	if (lang_parse() == 0)
		v = lang_eval();
	
	fprintf(stderr, "\n");
	//fprintf(stderr, "type = %d\n", v.type);
	//fprintf(stderr, "V_PRIM = %d\n", V_PRIM);
	int primID = prim_type(v.u.v);
	fprintf(stderr, "prim_type = %d\n", primID);
	
	double Vol_calc;
	double radius;
	double height;
		
	if (primID == SPHERE){
		fprintf(stderr, "It's a SPHERE! \n");
		Sphere *s = ((Prim*)v.u.v)->d;
		radius = s->r;
		Vol_calc = 4 * PI * pow(radius,3) / 3;
	};

	if (primID == CONEP){
		fprintf(stderr, "It's a CONE! \n");
		Conep *c = ((Prim*)v.u.v)->d;
		radius = c->r;
		height = c->h;
		Vol_calc = PI * height * SQR(radius) / 3;
	};

	if (primID == CYLIN){
		fprintf(stderr, "It's a CYLINDER! \n");
		Cylin *c = ((Prim*)v.u.v)->d;
		radius = c->r;
		height = c->h;
		Vol_calc = PI * height * SQR(radius);
	};
	
	double randnum = rand() % 99;
	char meshSDLfile[sizeof "MESH0000.sdl"];
	char meshOFFfile[sizeof "MESH0000.sdl"];
	char meshtransfile[sizeof "transMESH0000.sdl"];
	printf("Writing mesh files...\n");
	printf("MESH%2d%2.0f.sdl\n",primID,randnum);
	printf("MESH%2d%2.0f.off\n",primID,randnum);
	                         
	sprintf(meshSDLfile,"MESH%2d%2.0f.sdl",primID,randnum);	
	sprintf(meshOFFfile,"MESH%2d%2.0f.off",primID,randnum);
	sprintf(meshtransfile,"transMESH%2d%2.0f.off",primID,randnum);
	fp = 	fopen(meshSDLfile,"w");
	foff = fopen(meshOFFfile,"w");
	ftrans = fopen(meshtransfile,"w");
	
	Prim *p = (Prim*)v.u.v;
	double step = 0.1;
	double Vol1 = rayvolume(p,step);
	
	double level = 3;
	iMesh *mesh = prim_uv_decomp(p,3);
	imesh_write(mesh,fp);
	imesh_writeOFF(mesh,foff);
	
	printf("Volume (rayvolume.c): %g \n",Vol1);
	printf("Volume (formula): %g \n",Vol_calc);
	
	printf("\nParsing SDL mesh and translating to OFF mesh...\n --> transMESH%2d%2.0f.sdl\n",primID,randnum);
	
	rewind(fp);
	imesh_translate(fp,ftrans);

	fclose(fp);
	fclose(foff);
	fclose(ftrans);
	
	return 0;
}