Browse Source

more bugs

tonton th 2 months ago
parent
commit
166dc651b4
3 changed files with 32 additions and 12 deletions
  1. 1
    1
      .gitignore
  2. 29
    7
      importobj.c
  3. 2
    4
      tools/read_obj.c

+ 1
- 1
.gitignore View File

@@ -6,7 +6,7 @@ tbb
6 6
 gmon.out
7 7
 dummy-file
8 8
 
9
-tools/covid-19.obj
9
+tools/*.obj
10 10
 tools/read_obj
11 11
 tools/xyz
12 12
 

+ 29
- 7
importobj.c View File

@@ -21,7 +21,9 @@ int try_to_read_an_OBJ_file(char *fname, int notused)
21 21
 FILE		*fpin;
22 22
 char		line[LINE_SZ+1], *cptr;
23 23
 float		x, y, z;
24
-int		foo;
24
+int		foo, nbre;
25
+BBList          *bublist;
26
+Bubulle         bubulle;
25 27
 
26 28
 #if DEBUG_LEVEL
27 29
 fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
@@ -32,6 +34,14 @@ if (NULL==(fpin=fopen(fname, "r"))) {
32 34
 	exit(1);
33 35
 	}
34 36
 
37
+bublist = alloc_bubulles(fname, 1000, 0);
38
+if (NULL==bublist) {
39
+        fprintf(stderr, "err in %s, aborting...\n", __func__);
40
+        abort();
41
+        }
42
+print_bublist_desc(bublist, 0);
43
+
44
+nbre = 0;
35 45
 while(cptr=fgets(line, LINE_SZ, fpin)) {
36 46
 
37 47
 	if (verbosity>1) fputs(line, stderr);
@@ -46,16 +56,28 @@ while(cptr=fgets(line, LINE_SZ, fpin)) {
46 56
 	cptr = strtok(NULL, " ");
47 57
 	foo = sscanf(cptr, "%f", &z);
48 58
 
49
-	fprintf(stdout, "%16g   %16g   %16g\n", x, y, z);
50
-
51
-	}
52
-
59
+	memset(&bubulle, 0, sizeof(Bubulle));
60
+	niceprint_bubulle(&bubulle, 0);
53 61
 
54
- 
62
+	bubulle.p.x = x;
63
+	bubulle.p.y = y;
64
+	bubulle.p.z = z;
65
+	niceprint_bubulle(&bubulle, 0);
55 66
 
67
+	foo = push_bubulle(bublist, &bubulle);
68
+	if (foo) {
69
+		fprintf(stderr, "err %d on push\n", foo);
70
+		break;
71
+		}
72
+	nbre++;
73
+	}
56 74
 fclose(fpin);
57 75
 
58
-return -7800;
76
+if(verbosity) {
77
+	fprintf(stderr, "%s : %d vertices loaded\n", __func__, nbre);
78
+	}
79
+
80
+return 0;
59 81
 }
60 82
 
61 83
 /* --------------------------------------------------------------------- */

+ 2
- 4
tools/read_obj.c View File

@@ -18,12 +18,10 @@ if (2 != argc) {
18 18
 	exit(0);
19 19
 	}
20 20
 
21
-verbosity = 0;
21
+verbosity = 1;
22 22
 
23 23
 foo = try_to_read_an_OBJ_file(argv[1], 0);
24
-
25
-
26
-
24
+fprintf(stderr, "try to read -> %d\n", foo);
27 25
 
28 26
 return 0;
29 27
 }

Loading…
Cancel
Save