@@ -107,8 +107,7 @@ void testCoordsMatrix(const auto& tm)
107
107
REQUIRE (verts.rows () == tm.vertexNumber ());
108
108
REQUIRE (verts.cols () == 3 );
109
109
110
- vcl::uint i = 0 ;
111
- for (const auto & c : tm.vertices () | vcl::views::coords) {
110
+ for (vcl::uint i = 0 ; const auto & c : tm.vertices () | vcl::views::coords) {
112
111
REQUIRE (verts (i, 0 ) == c.x ());
113
112
REQUIRE (verts (i, 1 ) == c.y ());
114
113
REQUIRE (verts (i, 2 ) == c.z ());
@@ -124,8 +123,7 @@ void testTrianglesMatrix(const auto& tm)
124
123
REQUIRE (tris.rows () == tm.faceNumber ());
125
124
REQUIRE (tris.cols () == 3 );
126
125
127
- vcl::uint i = 0 ;
128
- for (const auto & f : tm.faces ()) {
126
+ for (vcl::uint i = 0 ; const auto & f : tm.faces ()) {
129
127
for (vcl::uint j = 0 ; j < 3 ; ++j) {
130
128
REQUIRE (tris (i, j) == f.vertexIndex (j));
131
129
}
@@ -140,8 +138,7 @@ void testFaceSizesVector(const auto& pm)
140
138
141
139
REQUIRE (sizes.size () == pm.faceNumber ());
142
140
143
- vcl::uint i = 0 ;
144
- for (const auto & f : pm.faces ()) {
141
+ for (vcl::uint i = 0 ; const auto & f : pm.faces ()) {
145
142
REQUIRE (sizes[i] == f.vertexNumber ());
146
143
++i;
147
144
}
@@ -155,8 +152,7 @@ void testFaceVector(const auto& pm)
155
152
vcl::uint nIndices = countPerFaceVertexReferences (pm);
156
153
REQUIRE (faces.size () == nIndices);
157
154
158
- vcl::uint i = 0 ;
159
- for (const auto & f : pm.faces ()) {
155
+ for (vcl::uint i = 0 ; const auto & f : pm.faces ()) {
160
156
for (const auto * v : f.vertices ()) {
161
157
REQUIRE (faces[i] == pm.index (v));
162
158
++i;
@@ -172,8 +168,7 @@ void testFaceMatrix(const auto& pm)
172
168
REQUIRE (faces.rows () == pm.faceNumber ());
173
169
REQUIRE (faces.cols () == vcl::largestFaceSize (pm));
174
170
175
- vcl::uint i = 0 ;
176
- for (const auto & f : pm.faces ()) {
171
+ for (vcl::uint i = 0 ; const auto & f : pm.faces ()) {
177
172
vcl::uint j = 0 ;
178
173
for (j = 0 ; j < f.vertexNumber (); ++j) {
179
174
REQUIRE (faces (i, j) == f.vertexIndex (j));
@@ -186,15 +181,37 @@ void testFaceMatrix(const auto& pm)
186
181
}
187
182
}
188
183
184
+ template <typename MatrixType>
185
+ void testTriangulatedFaceMatrix (const auto & pm)
186
+ {
187
+ vcl::TriPolyIndexBiMap indexMap;
188
+ auto tris = vcl::triangulatedFaceIndicesMatrix<MatrixType>(pm, indexMap);
189
+
190
+ vcl::uint tNumber = countTriangulatedTriangles (pm);
191
+
192
+ REQUIRE (tris.rows () == tNumber);
193
+ REQUIRE (tris.cols () == 3 );
194
+
195
+ for (vcl::uint i = 0 ; i < 3 ; ++i) {
196
+ // polygon associated to ith triangle
197
+ vcl::uint fIdx = indexMap.polygon (i);
198
+ const auto & f = pm.face (fIdx );
199
+
200
+ for (vcl::uint j = 0 ; j < 3 ; ++j) {
201
+ REQUIRE (f.containsVertex (tris (i, j)));
202
+ }
203
+ ++i;
204
+ }
205
+ }
206
+
189
207
template <typename VectorType>
190
208
void testVertexSelectionVector (const auto & tm)
191
209
{
192
210
auto sel = vcl::vertexSelectionVector<VectorType>(tm);
193
211
194
212
REQUIRE (sel.size () == tm.vertexNumber ());
195
213
196
- vcl::uint i = 0 ;
197
- for (const auto & v : tm.vertices ()) {
214
+ for (vcl::uint i = 0 ; const auto & v : tm.vertices ()) {
198
215
REQUIRE ((bool ) sel[i] == v.selected ());
199
216
++i;
200
217
}
@@ -207,8 +224,7 @@ void testFaceSelectionVector(const auto& tm)
207
224
208
225
REQUIRE (sel.size () == tm.faceNumber ());
209
226
210
- vcl::uint i = 0 ;
211
- for (const auto & f : tm.faces ()) {
227
+ for (vcl::uint i = 0 ; const auto & f : tm.faces ()) {
212
228
REQUIRE ((bool ) sel[i] == f.selected ());
213
229
++i;
214
230
}
@@ -222,8 +238,7 @@ void testVertNormalsMatrix(const auto& tm)
222
238
REQUIRE (vertNormals.rows () == tm.vertexNumber ());
223
239
REQUIRE (vertNormals.cols () == 3 );
224
240
225
- vcl::uint i = 0 ;
226
- for (const auto & n : tm.vertices () | vcl::views::normals) {
241
+ for (vcl::uint i = 0 ; const auto & n : tm.vertices () | vcl::views::normals) {
227
242
REQUIRE (vertNormals (i, 0 ) == n.x ());
228
243
REQUIRE (vertNormals (i, 1 ) == n.y ());
229
244
REQUIRE (vertNormals (i, 2 ) == n.z ());
@@ -239,8 +254,7 @@ void testFaceNormalsMatrix(const auto& tm)
239
254
REQUIRE (faceNormals.rows () == tm.faceNumber ());
240
255
REQUIRE (faceNormals.cols () == 3 );
241
256
242
- vcl::uint i = 0 ;
243
- for (const auto & n : tm.faces () | vcl::views::normals) {
257
+ for (vcl::uint i = 0 ; const auto & n : tm.faces () | vcl::views::normals) {
244
258
REQUIRE (faceNormals (i, 0 ) == n.x ());
245
259
REQUIRE (faceNormals (i, 1 ) == n.y ());
246
260
REQUIRE (faceNormals (i, 2 ) == n.z ());
@@ -256,8 +270,7 @@ void testVertColorsMatrix(const auto& tm)
256
270
REQUIRE (vertColors.rows () == tm.vertexNumber ());
257
271
REQUIRE (vertColors.cols () == 4 );
258
272
259
- vcl::uint i = 0 ;
260
- for (const auto & c : tm.vertices () | vcl::views::colors) {
273
+ for (vcl::uint i = 0 ; const auto & c : tm.vertices () | vcl::views::colors) {
261
274
REQUIRE (vertColors (i, 0 ) == c.red ());
262
275
REQUIRE (vertColors (i, 1 ) == c.green ());
263
276
REQUIRE (vertColors (i, 2 ) == c.blue ());
@@ -274,8 +287,7 @@ void testVertColorsVector(const auto& tm)
274
287
275
288
REQUIRE (vertColors.size () == tm.vertexNumber ());
276
289
277
- vcl::uint i = 0 ;
278
- for (const auto & c : tm.vertices () | vcl::views::colors) {
290
+ for (vcl::uint i = 0 ; const auto & c : tm.vertices () | vcl::views::colors) {
279
291
REQUIRE (vertColors[i] == c.rgba ());
280
292
++i;
281
293
}
@@ -289,8 +301,7 @@ void testFaceColorsMatrix(const auto& tm)
289
301
REQUIRE (faceColors.rows () == tm.faceNumber ());
290
302
REQUIRE (faceColors.cols () == 4 );
291
303
292
- vcl::uint i = 0 ;
293
- for (const auto & c : tm.faces () | vcl::views::colors) {
304
+ for (vcl::uint i = 0 ; const auto & c : tm.faces () | vcl::views::colors) {
294
305
REQUIRE (faceColors (i, 0 ) == c.red ());
295
306
REQUIRE (faceColors (i, 1 ) == c.green ());
296
307
REQUIRE (faceColors (i, 2 ) == c.blue ());
@@ -307,8 +318,7 @@ void testFaceColorsVector(const auto& tm)
307
318
308
319
REQUIRE (faceColors.size () == tm.faceNumber ());
309
320
310
- vcl::uint i = 0 ;
311
- for (const auto & c : tm.faces () | vcl::views::colors) {
321
+ for (vcl::uint i = 0 ; const auto & c : tm.faces () | vcl::views::colors) {
312
322
REQUIRE (faceColors[i] == c.rgba ());
313
323
++i;
314
324
}
@@ -321,8 +331,7 @@ void testVertexQualityVector(const auto& tm)
321
331
322
332
REQUIRE (qual.size () == tm.vertexNumber ());
323
333
324
- vcl::uint i = 0 ;
325
- for (const auto & v : tm.vertices ()) {
334
+ for (vcl::uint i = 0 ; const auto & v : tm.vertices ()) {
326
335
REQUIRE (qual[i] == v.quality ());
327
336
++i;
328
337
}
@@ -335,8 +344,7 @@ void testFaceQualityVector(const auto& tm)
335
344
336
345
REQUIRE (qual.size () == tm.faceNumber ());
337
346
338
- vcl::uint i = 0 ;
339
- for (const auto & f : tm.faces ()) {
347
+ for (vcl::uint i = 0 ; const auto & f : tm.faces ()) {
340
348
REQUIRE (qual[i] == f.quality ());
341
349
++i;
342
350
}
@@ -475,6 +483,30 @@ TEMPLATE_TEST_CASE(
475
483
}
476
484
}
477
485
486
+ SECTION (" Triangulated Faces..." )
487
+ {
488
+ SECTION (" Eigen Row Major" )
489
+ {
490
+ testTriangulatedFaceMatrix<EigenRowMatrix<vcl::uint>>(pm);
491
+ }
492
+ SECTION (" Eigen 3 Row Major" )
493
+ {
494
+ testTriangulatedFaceMatrix<Eigen3RowMatrix<vcl::uint>>(pm);
495
+ }
496
+ SECTION (" Eigen Col Major" )
497
+ {
498
+ testTriangulatedFaceMatrix<EigenColMatrix<vcl::uint>>(pm);
499
+ }
500
+ SECTION (" Eigen 3 Col Major" )
501
+ {
502
+ testTriangulatedFaceMatrix<Eigen3ColMatrix<vcl::uint>>(pm);
503
+ }
504
+ SECTION (" vcl::Array2" )
505
+ {
506
+ testTriangulatedFaceMatrix<vcl::Array2<vcl::uint>>(pm);
507
+ }
508
+ }
509
+
478
510
SECTION (" Vertex selection..." )
479
511
{
480
512
randomSelection<vcl::ElemId::VERTEX>(tm);
0 commit comments