-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathtest3d_c.c
159 lines (118 loc) · 4.18 KB
/
test3d_c.c
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// gcc -Wall -Wextra test3d_c.c -Xlinker -rpath=../lib
// -L ../lib -ljigsaw -o test3d_c
// Use JIGSAW to mesh a simple geometry with user-defined
// mesh-spacing data defined on a "mesh" in E^3.
# include "../inc/lib_jigsaw.h"
# include "print.h"
# include "stdio.h"
int test3d_c (int _verb)
{
int _retv = 0;
/*-------------------------------- setup JIGSAW types */
jigsaw_jig_t _jjig ;
jigsaw_init_jig_t(&_jjig) ;
jigsaw_msh_t _geom ;
jigsaw_init_msh_t(&_geom) ;
jigsaw_msh_t _hfun ;
jigsaw_init_msh_t(&_hfun) ;
jigsaw_msh_t _mesh ;
jigsaw_init_msh_t(&_mesh) ;
/*-------------------------------- setup JIGSAW geom. */
jigsaw_VERT3_t _geom_vert3[8] = { // setup geom.
{ {0., 0., 0.}, +0 } ,
{ {1., 0., 0.}, +0 } ,
{ {1., 1., 0.}, +0 } ,
{ {0., 1., 0.}, +0 } ,
{ {0., 0., 1.}, +0 } ,
{ {1., 0., 1.}, +0 } ,
{ {1., 1., 1.}, +0 } ,
{ {0., 1., 1.}, +0 }
} ;
jigsaw_TRIA3_t _geom_tria3[12] = {
{ {+0, +1, +2}, +0 } ,
{ {+0, +2, +3}, +0 } ,
{ {+4, +5, +6}, +0 } ,
{ {+4, +6, +7}, +0 } ,
{ {+0, +1, +5}, +0 } ,
{ {+0, +5, +4}, +0 } ,
{ {+1, +2, +6}, +0 } ,
{ {+1, +6, +5}, +0 } ,
{ {+2, +3, +7}, +0 } ,
{ {+2, +7, +6}, +0 } ,
{ {+3, +7, +4}, +0 } ,
{ {+3, +4, +0}, +0 }
} ;
_geom._flags
= JIGSAW_EUCLIDEAN_MESH;
_geom._vert3._data = &_geom_vert3[0] ;
_geom._vert3._size = +8 ;
_geom._tria3._data = &_geom_tria3[0] ;
_geom._tria3._size = +12;
/*-------------------------------- setup JIGSAW hfun. */
jigsaw_VERT3_t _hfun_vert3[9] = { // setup hfun.
{ {.5, .5, 0.}, +0 } ,
{ {0., 0., 0.}, +0 } ,
{ {1., 0., 0.}, +0 } ,
{ {1., 1., 0.}, +0 } ,
{ {0., 1., 0.}, +0 } ,
{ {0., 0., 1.}, +0 } ,
{ {1., 0., 1.}, +0 } ,
{ {1., 1., 1.}, +0 } ,
{ {0., 1., 1.}, +0 } ,
} ;
jigsaw_TRIA4_t _hfun_tria4[10] = {
{ {0, 5, 2, 1}, +0 } ,
{ {0, 6, 5, 2}, +0 } ,
{ {7, 0, 6, 2}, +0 } ,
{ {7, 0, 3, 2}, +0 } ,
{ {8, 0, 5, 1}, +0 } ,
{ {8, 0, 4, 1}, +0 } ,
{ {8, 0, 6, 5}, +0 } ,
{ {8, 7, 0, 6}, +0 } ,
{ {8, 0, 4, 3}, +0 } ,
{ {8, 7, 0, 3}, +0 } ,
} ;
fp32_t _hfun_value[9]= {
.5f, .5f, .5f, .5f, .5f,
1.f, 1.f, 1.f, 1.f
} ;
_hfun._flags
= JIGSAW_EUCLIDEAN_MESH;
_hfun._vert3._data = &_hfun_vert3[0] ;
_hfun._vert3._size = +9 ;
_hfun._tria4._data = &_hfun_tria4[0] ;
_hfun._tria4._size = +10;
_hfun._value._data = &_hfun_value[0] ;
_hfun._value._size = +9 ;
/*-------------------------------- build JIGSAW tria. */
_jjig._verbosity = _verb;
_jjig._hfun_scal =
JIGSAW_HFUN_ABSOLUTE;
_jjig._hfun_hmax = 1. ;
_jjig._hfun_hmin = 0. ;
_jjig._geom_feat = +1 ; // do "sharp" geom.
_jjig._mesh_top1 = +1 ;
_jjig._mesh_dims = +3 ; // make 3-dim cell
_jjig._mesh_kern = // non-default opts
JIGSAW_KERN_DELAUNAY;
_jjig._optm_kern =
JIGSAW_KERN_CVT_DQDX;
_jjig._optm_cost =
JIGSAW_KERN_SKEW_COS;
_retv = jigsaw (
& _jjig , // the config. opt.
& _geom , // geom. data
NULL , // empty init. obj.
& _hfun , // hfun. data
& _mesh ) ;
/*-------------------------------- print JIGSAW tria. */
if (_verb > 0 )
output_msh_data_3(&_mesh);
jigsaw_free_msh_t(&_mesh);
printf (
"[3d_c] JIGSAW returned code : %d \n", _retv) ;
return _retv ;
}
# ifndef __SKIP_MAIN__
int main () { return test3d_c(1) ; }
# endif//__SKIP_MAIN__