-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconversionCode.dat
More file actions
84 lines (76 loc) · 2.62 KB
/
conversionCode.dat
File metadata and controls
84 lines (76 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//////////////////////////////////////////////////////////
// We need ten lines of zero at the beginning
for(temp:=0; temp<10; temp+=1) printf "0\n" >> "initialGrains.dat";
//////////////////////////////////////////////////////////
// Refine even the triangles
define face attribute tri integer;
foreach face ff do set ff.tri 0;
foreach face ff do faces[ff.original].tri += 1;
refine faces where tri==1;
//////////////////////////////////////////////////////////
// classifies the nodes
define vertex attribute class integer;
foreach vertex vv do set vv.class 0;
foreach edge ee where valence==3 do {
ee.vertex[1].class+=1;
ee.vertex[2].class+=1;
}
//////////////////////////////////////////////////////////
// prints out the node info
printf "%.0f\n", vertex_count >> "initialGrains.dat";
foreach vertex vv do printf "%.20f\t%.20f\t%.20f\n", vv.x, vv.y, vv.z >> "initialGrains.dat";
printf "\n" >> "initialGrains.dat";
//////////////////////////////////////////////////////////
// arranges the information, body by body
printf "%.0f\n", body_count >> "initialGrains.dat";
foreach body bb do
{
print bb.id;
printf "%.0f %.0f\n", bb.id, bb.valence >> "initialGrains.dat";
define vvalues integer[bb.valence][3];
asd:=1;
foreach bb.face ff do
{
if ff.vertex[2].class==0 then {
vvalues[asd][1] := ff.vertex[1].id;
vvalues[asd][2] := ff.vertex[2].id;
vvalues[asd][3] := ff.vertex[3].id;
asd+=1;
}
else if ff.vertex[3].class==0 then {
vvalues[asd][1] := ff.vertex[2].id;
vvalues[asd][2] := ff.vertex[3].id;
vvalues[asd][3] := ff.vertex[1].id;
asd+=1;
}
else {
vvalues[asd][1] := ff.vertex[3].id;
vvalues[asd][2] := ff.vertex[1].id;
vvalues[asd][3] := ff.vertex[2].id;
asd+=1;
}
};
//////////////////////////////////////////////////////////
// arranges the triplets in order
for(sort:=1; sort<bb.valence-1; sort+=1) {
for(sort2:=sort+1; sort2<=bb.valence; sort2+=1){
if(vvalues[sort][2]=vvalues[sort2][2] and vvalues[sort][3]=vvalues[sort2][1]) then {
temp1:=vvalues[sort+1][1];
temp2:=vvalues[sort+1][2];
temp3:=vvalues[sort+1][3];
vvalues[sort+1][1] := vvalues[sort2][1];
vvalues[sort+1][2] := vvalues[sort2][2];
vvalues[sort+1][3] := vvalues[sort2][3];
vvalues[sort2][1] := temp1;
vvalues[sort2][2] := temp2;
vvalues[sort2][3] := temp3;
}
};
};
asd:=1;
foreach bb.face ff do {
printf "%.0f\t%.0f\t%.0f\n", vvalues[asd][1], vvalues[asd][2], vvalues[asd][3] >> "initialGrains.dat";
asd+=1;
};
printf "\n" >> "initialGrains.dat";
}