71 YAC_ASSERT(num_corners >= 3,
"ERROR(yac_triangulate_cell): number < 3")
73 switch (num_corners) {
75 if (start_corner == 0) {
82 (
size_t [3]){(size_t)((start_corner + 0)%3),
83 (size_t)((start_corner + 1)%3),
84 (
size_t)((start_corner + 2)%3)});
87 size_t idx[5] = {(size_t)((start_corner + 0)%num_corners),
88 (
size_t)((start_corner + 1)%num_corners),
89 (size_t)((start_corner + 2)%num_corners),
90 (
size_t)((start_corner + 3)%num_corners),
91 (size_t)((start_corner + 0)%num_corners)};
97 size_t idx[7] = {(size_t)((start_corner + 0)%num_corners),
98 (
size_t)((start_corner + 1)%num_corners),
99 (size_t)((start_corner + 2)%num_corners),
100 (
size_t)((start_corner + 3)%num_corners),
101 (size_t)((start_corner + 4)%num_corners),
102 (
size_t)((start_corner + 0)%num_corners),
103 (size_t)((start_corner + 2)%num_corners)};
110 size_t idx[9] = {(size_t)((start_corner + 0)%num_corners),
111 (
size_t)((start_corner + 1)%num_corners),
112 (size_t)((start_corner + 2)%num_corners),
113 (
size_t)((start_corner + 3)%num_corners),
114 (size_t)((start_corner + 4)%num_corners),
115 (
size_t)((start_corner + 5)%num_corners),
116 (size_t)((start_corner + 0)%num_corners),
117 (
size_t)((start_corner + 2)%num_corners),
118 (size_t)((start_corner + 4)%num_corners)};
127 size_t temp_corner_indices[2*num_corners];
129 for (
size_t i = start_corner; i < num_corners; ++i, ++j)
130 temp_corner_indices[j] = i;
131 for (
size_t i = 0; i < start_corner; ++i, ++j)
132 temp_corner_indices[j] = i;
134 for (
size_t i = 0; i < num_corners - 2; ++i, ++j) {
136 cell, triangles + i, &(temp_corner_indices[2 * i]));
137 temp_corner_indices[j] = temp_corner_indices[2 * i];
145 size_t const * corner_indices,
size_t num_corners,
size_t start_corner,
146 size_t (*triangle_indices)[3]) {
149 num_corners >= 3,
"ERROR(yac_triangulate_corner_indices): number < 3")
151 switch (num_corners) {
153 triangle_indices[0][0] = corner_indices[(start_corner + 0)%3];
154 triangle_indices[0][1] = corner_indices[(start_corner + 1)%3];
155 triangle_indices[0][2] = corner_indices[(start_corner + 2)%3];
158 triangle_indices[0][0] = corner_indices[start_corner];
159 triangle_indices[0][1] = corner_indices[(start_corner + 1)%4];
160 triangle_indices[0][2] = corner_indices[(start_corner + 2)%4];
161 triangle_indices[1][0] = corner_indices[(start_corner + 2)%4];
162 triangle_indices[1][1] = corner_indices[(start_corner + 3)%4];
163 triangle_indices[1][2] = corner_indices[start_corner];
166 triangle_indices[0][0] = corner_indices[start_corner];
167 triangle_indices[0][1] = corner_indices[(start_corner + 1)%6];
168 triangle_indices[0][2] = corner_indices[(start_corner + 2)%6];
169 triangle_indices[1][0] = corner_indices[(start_corner + 2)%6];
170 triangle_indices[1][1] = corner_indices[(start_corner + 3)%6];
171 triangle_indices[1][2] = corner_indices[(start_corner + 4)%6];
172 triangle_indices[2][0] = corner_indices[(start_corner + 4)%6];
173 triangle_indices[2][1] = corner_indices[(start_corner + 5)%6];
174 triangle_indices[2][2] = corner_indices[start_corner];
175 triangle_indices[3][0] = corner_indices[start_corner];
176 triangle_indices[3][1] = corner_indices[(start_corner + 2)%6];
177 triangle_indices[3][2] = corner_indices[(start_corner + 4)%6];
180 size_t temp_corner_indices[2*num_corners];
182 for (
size_t i = start_corner; i < num_corners; ++i, ++j)
183 temp_corner_indices[j] = corner_indices[i];
184 for (
size_t i = 0; i < start_corner; ++i, ++j)
185 temp_corner_indices[j] = corner_indices[i];
187 for (
size_t i = 0; i < num_corners - 2; ++i, ++j) {
188 memcpy(triangle_indices[i], temp_corner_indices + 2 * i,
189 3 *
sizeof(*temp_corner_indices));
190 temp_corner_indices[j] = temp_corner_indices[2 * i];