Beispiel #1
0
/*!
 * \ingroup file
 */
void
lib3ds_file_dump_instances(Lib3dsFile *file)
{
    Lib3dsNode *p;

    ASSERT(file);
    for (p=file->nodes; p!=0; p=p->next) {
        dump_instances(p,"");
    }
}
Beispiel #2
0
static void
dump_instances(Lib3dsNode *node, const char* parent) {
    Lib3dsNode *p;
    char name[255];

    strcpy(name, parent);
    strcat(name, ".");
    strcat(name, node->name);
    if (node->type == LIB3DS_NODE_MESH_INSTANCE) {
        Lib3dsMeshInstanceNode *n = (Lib3dsMeshInstanceNode*)node;
        printf("  %s : %s\n", name, n->instance_name);
    }
    for (p = node->childs; p != 0; p = p->next) {
        dump_instances(p, parent);
    }
}
Beispiel #3
0
static void
dump_instances(Lib3dsNode *node, const char* parent)
{
    Lib3dsNode *p;
    char name[255];

    ASSERT(node);
    ASSERT(parent);
    strcpy(name, parent);
    strcat(name, ".");
    strcat(name, node->name);
    if (node->type==LIB3DS_OBJECT_NODE) {
        printf("  %s : %s\n", name, node->data.object.instance);
    }
    for (p=node->childs; p!=0; p=p->next) {
        dump_instances(p, parent);
    }
}
Beispiel #4
0
int
main(int argc, char **argv) {
    FILE *file;
    Lib3dsFile *f = 0;
    Lib3dsIo io;
    int result;
    int i;

    parse_args(argc, argv);

    file = fopen(filename, "rb");
    if (!file) {
        fprintf(stderr, "***ERROR***\nFile not found: %s\n", filename);
        exit(1);
    }

    f = lib3ds_file_new();

    memset(&io, 0, sizeof(io));
    io.self = file;
    io.seek_func = fileio_seek_func;
    io.tell_func = fileio_tell_func;
    io.read_func = fileio_read_func;
    io.write_func = fileio_write_func;
    io.log_func = fileio_log_func;

    result =  lib3ds_file_read(f, &io);

    fclose(file);

    if (!result) {
        fprintf(stderr, "***ERROR***\nLoading file failed: %s\n", filename);
        exit(1);
    }

    if (flags & LIB3DSDUMP_MATERIALS) {
        printf("Dumping materials:\n");
        for (i = 0; i < f->nmaterials; ++i) material_dump(f->materials[i]);
        printf("\n");
    }
    if (flags & LIB3DSDUMP_TRIMESHES) {
        printf("Dumping meshes:\n");
        for (i = 0; i < f->nmeshes; ++i) mesh_dump(f->meshes[i]);
        printf("\n");
    }
    if (flags & LIB3DSDUMP_INSTANCES) {
        Lib3dsNode *p;
        printf("Dumping instances:\n");
        for (p = f->nodes; p != 0; p = p->next) {
            dump_instances(p, "");
        }
        printf("\n");
    }
    if (flags & LIB3DSDUMP_CAMERAS) {
        printf("Dumping cameras:\n");
        for (i = 0; i < f->ncameras; ++i) camera_dump(f->cameras[i]);
        printf("\n");
    }
    if (flags & LIB3DSDUMP_LIGHTS) {
        printf("Dumping lights:\n");
        for (i = 0; i < f->nlights; ++i) light_dump(f->lights[i]);
        printf("\n");
    }
    if (flags & LIB3DSDUMP_NODES) {
        Lib3dsNode *p;
        printf("Dumping node hierarchy:\n");
        for (p = f->nodes; p != 0; p = p->next) {
            node_dump(p, 1);
        }
        printf("\n");
    }
    if (output) {
        if (!lib3ds_file_save(f, output)) {
            printf("***ERROR**** Writing %s\n", output);
        }
    }

    lib3ds_file_free(f);
    return 0;
}
void debug_white(struct board *board)
	{
	short x,y,x1,y1,f,g,j;
	struct threat_combo tc[GROUPS];
	short threats[GROUPS],thnumb,anythreat=0,ccmb;
	short key,oracle,combo,pentas;
	char **matrix;
	short i,*bpos,px,py;

	if(check_early_win(board))
		{
		printf("An early win is detected! (ESC to return)\n\r");
		while(readkey()!=0x1b);
		return;
		}

    pentas=0;
	combo=threat_combo(board,tc);

	thnumb=count_odd_threats(board,threats);
	if(thnumb+combo==0 && !pentas)
		{
		printf("No decisive threats, (ESC to return)\n\r");
		while(readkey()!=0x1b);
		return;
		}

	do
		{
		memset(board->usablegroup,0xff,GROUPS*sizeof(short));
		memset(board->sqused,0xff,(BOARDX+1)*(BOARDY+2)*sizeof(short));
		memset(board->wipesq,0x00,(BOARDX+1)*(BOARDY+2)*sizeof(short));

		if(anythreat<thnumb)
			{
			wipe_above(board,threats[anythreat]);
			wipe_odd(board,threats[anythreat]);

			px=ELX(threats[anythreat]);
			for(py=0;py<BOARDY;py++)
                if(board->square[ELM(px,py)]==EMPTY)
                    board->sqused[ELM(px,py)]=NO;
			}
		else if(anythreat<thnumb+combo)
			{
			ccmb=anythreat-thnumb;

			px=ELX(tc[ccmb].cross);
			x =ELX(tc[ccmb].odd);

			for(y=0;y<BOARDY;y++)
				{
				if(board->square[ELM(px,y)]==EMPTY)
					board->sqused[ELM(px,y)]=NO;

				if(board->square[ELM( x,y)]==EMPTY)
					board->sqused[ELM( x,y)]=NO;
				}

			if(ELY(tc[ccmb].even)>ELY(tc[ccmb].odd))
				handle_even_above_odd(board,&tc[ccmb]);
            else handle_odd_above_even(board,&tc[ccmb]);
            }
		else fatal_error("What am I doing?");

		board->sp=0;
		board->intgp.j=0;
		board->intgp.k=0;

		for(i=0;i<GROUPS;i++)
			{
			if(threat_group(board,i,WHITE) &&
				!wiped_group(board,i) && board->usablegroup[i])
				{
				board->intgp.tgroups[i]=YES;
				board->intgp.j++;
				}
			else board->intgp.tgroups[i]=NO;

			if(threat_group(board,i,BLACK))
				{
				board->intgp.mygroups[i]=YES;
				board->intgp.k++;
				}
			else board->intgp.mygroups[i]=NO;
			}

		claimeven(board);
		baseinverse(board);
		vertical(board);
		aftereven(board);
		lowinverse(board);
		highinverse(board);
		baseclaim(board);
		before(board);

		dump_instances(board);
		dump_file_board(board);

		if(anythreat<thnumb) dump_file_threat(board,anythreat);

		matrix=(char **)allocate_matrix(board);
		build_adjacency_matrix(matrix,board);

        oracle=problem_solver(board,matrix,NO,NULL);

		printf("\n\r");
		printf("Total sol. found : %d, total dangerous groups %d, groups solved %d\n\r",
				board->sp,board->intgp.j,board->problem_solved);


		if(anythreat<thnumb)
			{
			printf("Odd threat at %c%d, oracle spits out %d\n\r",
						ELX(threats[anythreat])+97,ELY(threats[anythreat])+1,oracle);
			}
		else if(anythreat<thnumb+combo)
			{
			printf("Double odd threat at %c%d, oracle spits out %d\n\r",
						ELX(tc[anythreat-thnumb].cross)+97,ELY(tc[anythreat-thnumb].cross)+1,oracle);
			}
		else
			{
			printf("Pentas found.\n\r",pentas);
			}


        printf("1 - 9 to see rules instances, ESC to return to game play\n");
        printf("j to dump the non adjacencies, t to test rule compatibility\n");
        printf("s to show squares available\n");

		while((key=readkey())!=0x1b)
			{
			switch(key)
				{
				case '1':
					dump_solutions(board,CLAIMEVEN);
					break;

				case '2':
					dump_solutions(board,BASEINVERSE);
					break;

				case '3':
					dump_solutions(board,VERTICAL);
					break;

				case '4':
					dump_solutions(board,AFTEREVEN);
					break;

				case '5':
					dump_solutions(board,LOWINVERSE);
					break;

				case '6':
					dump_solutions(board,HIGHINVERSE);
					break;

				case '7':
					dump_solutions(board,BASECLAIM);
					break;

				case '8':
					dump_solutions(board,BEFORE);
					break;

				case '9':
					dump_solutions(board,SPECIALBEFORE);
					break;

				case 'j':
					dump_no_adjacencies(matrix,board);
					break;

				case 't':
					test_conditions(matrix,board);
					break;

                case 's':
                    show_square_used(board);
                    break;

				}
			}

		free_matrix(matrix,board);
		anythreat++;
		} while(anythreat<thnumb+combo || pentas);

	}
void debug_black(struct board *board)
	{
	short key,oracle;
	register x;
	char **matrix;
	short i,*bpos;


	board->sp=0;

	board->intgp.j=0;
	board->intgp.k=0;

	memset(board->sqused,0xff,(BOARDX+1)*(BOARDY+2)*sizeof(short));

	for(i=0;i<GROUPS;i++)
		{
		if(threat_group(board,i,BLACK))
			{
			board->intgp.tgroups[i]=YES;
			board->intgp.j++;
			}
		else board->intgp.tgroups[i]=NO;

		if(threat_group(board,i,WHITE))
			{
			board->intgp.mygroups[i]=YES;
			board->intgp.k++;
			}
		else board->intgp.mygroups[i]=NO;
		}

	claimeven(board);
	baseinverse(board);
	vertical(board);
	aftereven(board);
	lowinverse(board);
	highinverse(board);
	baseclaim(board);
	before(board);

	dump_instances(board);
	dump_file_board(board);

	matrix=(char **)allocate_matrix(board);
	build_adjacency_matrix(matrix,board);

    oracle=problem_solver(board,matrix,NO,NULL);

	printf("\n\r");
	printf("Total sol. found : %d, total dangerous groups %d, groups solved %d\n\r",
				board->sp,board->intgp.j,board->problem_solved);
	printf("Oracle spits out %d\n\r",oracle);

	printf("Key 1 - 9 to see rules instances, ESC to return to game play\n\r");
	printf("j to dump the non adjacencies, t to test rule compatibility\n\r");

	while((key=readkey())!=0x1b)
		{
		switch(key)
			{
			case '1':
				dump_solutions(board,CLAIMEVEN);
				break;

			case '2':
				dump_solutions(board,BASEINVERSE);
				break;

			case '3':
				dump_solutions(board,VERTICAL);
				break;

			case '4':
				dump_solutions(board,AFTEREVEN);
				break;

			case '5':
				dump_solutions(board,LOWINVERSE);
				break;

			case '6':
				dump_solutions(board,HIGHINVERSE);
				break;

			case '7':
				dump_solutions(board,BASECLAIM);
				break;

			case '8':
				dump_solutions(board,BEFORE);
				break;

			case '9':
				dump_solutions(board,SPECIALBEFORE);
				break;

			case 'j':
				dump_no_adjacencies(matrix,board);
				break;

			case 't':
				test_conditions(matrix,board);
				break;
			}
		}

	free_matrix(matrix,board);
	}