3 #include "testing/testing.h"
19 namespace blender::meshintersect::tests {
21 constexpr
bool DO_OBJ =
false;
30 static constexpr
int MAX_FACE_LEN = 1000;
32 static int edge_index(
int face_index,
int facepos)
34 return face_index * MAX_FACE_LEN + facepos;
37 static std::pair<int, int> face_and_pos_for_edge_index(
int e_index)
39 return std::pair<int, int>(e_index / MAX_FACE_LEN, e_index % MAX_FACE_LEN);
50 IMeshBuilder(
const char *spec)
52 std::istringstream ss(spec);
55 std::istringstream hdrss(line);
58 if (nv == 0 || nf == 0) {
61 arena.reserve(nv, nf);
62 Vector<const Vert *>
verts;
66 while (v_index < nv && spec_ok && getline(ss, line)) {
67 std::istringstream iss(line);
71 iss >> p0 >> p1 >> p2;
72 spec_ok = !iss.fail();
73 verts.append(arena.add_or_find_vert(mpq3(p0, p1, p2), v_index));
80 while (f_index < nf && spec_ok && getline(ss, line)) {
81 std::istringstream fss(line);
82 Vector<const Vert *> face_verts;
83 Vector<int> edge_orig;
85 while (spec_ok && fss >> v_index) {
86 if (v_index < 0 || v_index >= nv) {
90 face_verts.append(
verts[v_index]);
91 edge_orig.append(edge_index(f_index, fpos));
94 Face *facep = arena.add_face(face_verts, f_index, edge_orig);
102 std::cout <<
"Bad spec: " << spec;
105 imesh = IMesh(
faces);
109 static int all_shape_zero(
int UNUSED(
t))
114 TEST(boolean_trimesh, Empty)
118 IMesh
out = boolean_trimesh(in, BoolOpType::None, 1, all_shape_zero,
true,
false, &arena);
124 TEST(boolean_trimesh, TetTetTrimesh)
126 const char *spec = R
"(8 8
145 IMeshBuilder mb(spec);
146 IMesh out = boolean_trimesh(
147 mb.imesh, BoolOpType::None, 1, all_shape_zero, true,
false, &mb.arena);
152 write_obj_mesh(
out,
"tettet_tm");
155 IMeshBuilder mb2(spec);
156 IMesh out2 = boolean_trimesh(
157 mb2.imesh, BoolOpType::Union, 1, all_shape_zero,
true,
false, &mb2.arena);
158 out2.populate_vert();
162 write_obj_mesh(out2,
"tettet_union_tm");
165 IMeshBuilder mb3(spec);
166 IMesh out3 = boolean_trimesh(
170 [](
int t) { return t < 4 ? 0 : 1; },
174 out3.populate_vert();
178 write_obj_mesh(out3,
"tettet_union_binary_tm");
181 IMeshBuilder mb4(spec);
182 IMesh out4 = boolean_trimesh(
186 [](
int t) { return t < 4 ? 0 : 1; },
190 out4.populate_vert();
194 write_obj_mesh(out4,
"tettet_union_binary_self_tm");
197 IMeshBuilder mb5(spec);
198 IMesh out5 = boolean_trimesh(
202 [](
int t) { return t < 4 ? 0 : 1; },
206 out5.populate_vert();
210 write_obj_mesh(out5,
"tettet_intersect_binary_tm");
213 IMeshBuilder mb6(spec);
214 IMesh out6 = boolean_trimesh(
216 BoolOpType::Difference,
218 [](
int t) { return t < 4 ? 0 : 1; },
222 out6.populate_vert();
226 write_obj_mesh(out6,
"tettet_difference_binary_tm");
229 IMeshBuilder mb7(spec);
230 IMesh out7 = boolean_trimesh(
232 BoolOpType::Difference,
234 [](
int t) { return t < 4 ? 1 : 0; },
238 out7.populate_vert();
242 write_obj_mesh(out7,
"tettet_difference_rev_binary_tm");
246 TEST(boolean_trimesh, TetTet2Trimesh)
248 const char *spec = R
"(8 8
267 IMeshBuilder mb(spec);
268 IMesh out = boolean_trimesh(
269 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false, &mb.arena);
274 write_obj_mesh(
out,
"tettet2_union_tm");
278 TEST(boolean_trimesh, CubeTetTrimesh)
280 const char *spec = R
"(12 16
311 IMeshBuilder mb(spec);
312 IMesh out = boolean_trimesh(
313 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false, &mb.arena);
318 write_obj_mesh(
out,
"cubetet_union_tm");
322 TEST(boolean_trimesh, BinaryTetTetTrimesh)
324 const char *spec = R
"(8 8
343 IMeshBuilder mb(spec);
344 IMesh out = boolean_trimesh(
348 [](int t) { return t < 4 ? 0 : 1; },
356 write_obj_mesh(
out,
"binary_tettet_isect_tm");
360 TEST(boolean_trimesh, TetTetCoplanarTrimesh)
362 const char *spec = R
"(8 8
381 IMeshBuilder mb(spec);
382 IMesh out = boolean_trimesh(
383 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false, &mb.arena);
388 write_obj_mesh(
out,
"tettet_coplanar_tm");
392 TEST(boolean_trimesh, TetInsideTetTrimesh)
394 const char *spec = R
"(8 8
413 IMeshBuilder mb(spec);
414 IMesh out = boolean_trimesh(
415 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false, &mb.arena);
420 write_obj_mesh(
out,
"tetinsidetet_tm");
424 TEST(boolean_trimesh, TetBesideTetTrimesh)
426 const char *spec = R
"(8 8
445 IMeshBuilder mb(spec);
446 IMesh out = boolean_trimesh(
447 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false, &mb.arena);
452 write_obj_mesh(
out,
"tetbesidetet_tm");
456 TEST(boolean_trimesh, DegenerateTris)
458 const char *spec = R
"(10 10
481 IMeshBuilder mb(spec);
482 IMesh out = boolean_trimesh(
486 [](int t) { return t < 5 ? 0 : 1; },
494 write_obj_mesh(
out,
"degenerate_tris_tm");
498 TEST(boolean_polymesh, TetTet)
500 const char *spec = R
"(8 8
519 IMeshBuilder mb(spec);
520 IMesh out = boolean_mesh(
521 mb.imesh, BoolOpType::None, 1, all_shape_zero, true,
false,
nullptr, &mb.arena);
526 write_obj_mesh(
out,
"tettet");
529 IMeshBuilder mb2(spec);
530 IMesh out2 = boolean_mesh(
534 [](
int t) { return t < 4 ? 0 : 1; },
539 out2.populate_vert();
543 write_obj_mesh(
out,
"tettet2");
547 TEST(boolean_polymesh, CubeCube)
549 const char *spec = R
"(16 12
580 IMeshBuilder mb(spec);
582 write_obj_mesh(mb.imesh,
"cube_cube_in");
584 IMesh
out = boolean_mesh(
585 mb.imesh, BoolOpType::Union, 1, all_shape_zero,
true,
false,
nullptr, &mb.arena);
590 write_obj_mesh(
out,
"cubecube_union");
593 IMeshBuilder mb2(spec);
594 IMesh out2 = boolean_mesh(
598 [](
int t) { return t < 6 ? 0 : 1; },
603 out2.populate_vert();
607 write_obj_mesh(out2,
"cubecube_none");
611 TEST(boolean_polymesh, CubeCone)
613 const char *spec = R
"(14 12
641 IMeshBuilder mb(spec);
642 IMesh out = boolean_mesh(
643 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false,
nullptr, &mb.arena);
648 write_obj_mesh(
out,
"cubeccone");
652 TEST(boolean_polymesh, CubeCubeCoplanar)
654 const char *spec = R
"(16 12
685 IMeshBuilder mb(spec);
686 IMesh out = boolean_mesh(
690 [](int t) { return t < 6 ? 0 : 1; },
699 write_obj_mesh(
out,
"cubecube_coplanar");
703 TEST(boolean_polymesh, TetTeTCoplanarDiff)
705 const char *spec = R
"(8 8
724 IMeshBuilder mb(spec);
725 IMesh out = boolean_mesh(
727 BoolOpType::Difference,
729 [](int t) { return t < 4 ? 0 : 1; },
738 write_obj_mesh(
out,
"tettet_coplanar_diff");
742 TEST(boolean_polymesh, CubeCubeStep)
744 const char *spec = R
"(16 12
775 IMeshBuilder mb(spec);
776 IMesh out = boolean_mesh(
778 BoolOpType::Difference,
780 [](int t) { return t < 6 ? 0 : 1; },
789 write_obj_mesh(
out,
"cubecubestep");
793 TEST(boolean_polymesh, CubeCyl4)
795 const char *spec = R
"(16 12
826 IMeshBuilder mb(spec);
827 IMesh out = boolean_mesh(
829 BoolOpType::Difference,
831 [](int t) { return t < 6 ? 1 : 0; },
840 write_obj_mesh(
out,
"cubecyl4");
844 TEST(boolean_polymesh, CubeCubesubdivDiff)
847 const char *spec = R
"(26 22
898 IMeshBuilder mb(spec);
899 IMesh out = boolean_mesh(
901 BoolOpType::Difference,
903 [](int t) { return t < 16 ? 1 : 0; },
912 write_obj_mesh(
out,
"cubecubesubdivdiff");
916 TEST(boolean_polymesh, CubePlane)
918 const char *spec = R
"(12 7
940 IMeshBuilder mb(spec);
941 IMesh out = boolean_mesh(
943 BoolOpType::Difference,
945 [](int t) { return t >= 1 ? 0 : 1; },
954 write_obj_mesh(
out,
"cubeplane");
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
Read Guarded memory(de)allocation.
DBVT_INLINE bool Intersect(const btDbvtAabbMm &a, const btDbvtAabbMm &b)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)