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);
48 IMeshBuilder(
const char *spec)
50 std::istringstream ss(spec);
53 std::istringstream hdrss(line);
56 if (nv == 0 || nf == 0) {
59 arena.reserve(nv, nf);
60 Vector<const Vert *>
verts;
64 while (v_index < nv && spec_ok && getline(ss, line)) {
65 std::istringstream iss(line);
69 iss >> p0 >> p1 >> p2;
70 spec_ok = !iss.fail();
71 verts.append(arena.add_or_find_vert(mpq3(p0, p1, p2), v_index));
78 while (f_index < nf && spec_ok && getline(ss, line)) {
79 std::istringstream fss(line);
80 Vector<const Vert *> face_verts;
81 Vector<int> edge_orig;
83 while (spec_ok && fss >> v_index) {
84 if (v_index < 0 || v_index >= nv) {
88 face_verts.append(
verts[v_index]);
89 edge_orig.append(edge_index(f_index, fpos));
92 Face *facep = arena.add_face(face_verts, f_index, edge_orig);
100 std::cout <<
"Bad spec: " << spec;
103 imesh = IMesh(
faces);
107 static int all_shape_zero(
int UNUSED(
t))
112 TEST(boolean_trimesh, Empty)
116 IMesh out = boolean_trimesh(in, BoolOpType::None, 1, all_shape_zero,
true,
false, &arena);
122 TEST(boolean_trimesh, TetTetTrimesh)
124 const char *spec = R
"(8 8
143 IMeshBuilder mb(spec);
144 IMesh out = boolean_trimesh(
145 mb.imesh, BoolOpType::None, 1, all_shape_zero, true,
false, &mb.arena);
150 write_obj_mesh(out,
"tettet_tm");
153 IMeshBuilder mb2(spec);
154 IMesh out2 = boolean_trimesh(
155 mb2.imesh, BoolOpType::Union, 1, all_shape_zero,
true,
false, &mb2.arena);
156 out2.populate_vert();
160 write_obj_mesh(out2,
"tettet_union_tm");
163 IMeshBuilder mb3(spec);
164 IMesh out3 = boolean_trimesh(
168 [](
int t) { return t < 4 ? 0 : 1; },
172 out3.populate_vert();
176 write_obj_mesh(out3,
"tettet_union_binary_tm");
179 IMeshBuilder mb4(spec);
180 IMesh out4 = boolean_trimesh(
184 [](
int t) { return t < 4 ? 0 : 1; },
188 out4.populate_vert();
192 write_obj_mesh(out4,
"tettet_union_binary_self_tm");
195 IMeshBuilder mb5(spec);
196 IMesh out5 = boolean_trimesh(
200 [](
int t) { return t < 4 ? 0 : 1; },
204 out5.populate_vert();
208 write_obj_mesh(out5,
"tettet_intersect_binary_tm");
211 IMeshBuilder mb6(spec);
212 IMesh out6 = boolean_trimesh(
214 BoolOpType::Difference,
216 [](
int t) { return t < 4 ? 0 : 1; },
220 out6.populate_vert();
224 write_obj_mesh(out6,
"tettet_difference_binary_tm");
227 IMeshBuilder mb7(spec);
228 IMesh out7 = boolean_trimesh(
230 BoolOpType::Difference,
232 [](
int t) { return t < 4 ? 1 : 0; },
236 out7.populate_vert();
240 write_obj_mesh(out7,
"tettet_difference_rev_binary_tm");
244 TEST(boolean_trimesh, TetTet2Trimesh)
246 const char *spec = R
"(8 8
265 IMeshBuilder mb(spec);
266 IMesh out = boolean_trimesh(
267 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false, &mb.arena);
272 write_obj_mesh(out,
"tettet2_union_tm");
276 TEST(boolean_trimesh, CubeTetTrimesh)
278 const char *spec = R
"(12 16
309 IMeshBuilder mb(spec);
310 IMesh out = boolean_trimesh(
311 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false, &mb.arena);
316 write_obj_mesh(out,
"cubetet_union_tm");
320 TEST(boolean_trimesh, BinaryTetTetTrimesh)
322 const char *spec = R
"(8 8
341 IMeshBuilder mb(spec);
342 IMesh out = boolean_trimesh(
346 [](int t) { return t < 4 ? 0 : 1; },
354 write_obj_mesh(out,
"binary_tettet_isect_tm");
358 TEST(boolean_trimesh, TetTetCoplanarTrimesh)
360 const char *spec = R
"(8 8
379 IMeshBuilder mb(spec);
380 IMesh out = boolean_trimesh(
381 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false, &mb.arena);
386 write_obj_mesh(out,
"tettet_coplanar_tm");
390 TEST(boolean_trimesh, TetInsideTetTrimesh)
392 const char *spec = R
"(8 8
411 IMeshBuilder mb(spec);
412 IMesh out = boolean_trimesh(
413 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false, &mb.arena);
418 write_obj_mesh(out,
"tetinsidetet_tm");
422 TEST(boolean_trimesh, TetBesideTetTrimesh)
424 const char *spec = R
"(8 8
443 IMeshBuilder mb(spec);
444 IMesh out = boolean_trimesh(
445 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false, &mb.arena);
450 write_obj_mesh(out,
"tetbesidetet_tm");
454 TEST(boolean_trimesh, DegenerateTris)
456 const char *spec = R
"(10 10
479 IMeshBuilder mb(spec);
480 IMesh out = boolean_trimesh(
484 [](int t) { return t < 5 ? 0 : 1; },
492 write_obj_mesh(out,
"degenerate_tris_tm");
496 TEST(boolean_polymesh, TetTet)
498 const char *spec = R
"(8 8
517 IMeshBuilder mb(spec);
518 IMesh out = boolean_mesh(
519 mb.imesh, BoolOpType::None, 1, all_shape_zero, true,
false,
nullptr, &mb.arena);
524 write_obj_mesh(out,
"tettet");
527 IMeshBuilder mb2(spec);
528 IMesh out2 = boolean_mesh(
532 [](
int t) { return t < 4 ? 0 : 1; },
537 out2.populate_vert();
541 write_obj_mesh(out,
"tettet2");
545 TEST(boolean_polymesh, CubeCube)
547 const char *spec = R
"(16 12
578 IMeshBuilder mb(spec);
580 write_obj_mesh(mb.imesh,
"cube_cube_in");
582 IMesh out = boolean_mesh(
583 mb.imesh, BoolOpType::Union, 1, all_shape_zero,
true,
false,
nullptr, &mb.arena);
588 write_obj_mesh(out,
"cubecube_union");
591 IMeshBuilder mb2(spec);
592 IMesh out2 = boolean_mesh(
596 [](
int t) { return t < 6 ? 0 : 1; },
601 out2.populate_vert();
605 write_obj_mesh(out2,
"cubecube_none");
609 TEST(boolean_polymesh, CubeCone)
611 const char *spec = R
"(14 12
639 IMeshBuilder mb(spec);
640 IMesh out = boolean_mesh(
641 mb.imesh, BoolOpType::Union, 1, all_shape_zero, true,
false,
nullptr, &mb.arena);
646 write_obj_mesh(out,
"cubeccone");
650 TEST(boolean_polymesh, CubeCubeCoplanar)
652 const char *spec = R
"(16 12
683 IMeshBuilder mb(spec);
684 IMesh out = boolean_mesh(
688 [](int t) { return t < 6 ? 0 : 1; },
697 write_obj_mesh(out,
"cubecube_coplanar");
701 TEST(boolean_polymesh, TetTeTCoplanarDiff)
703 const char *spec = R
"(8 8
722 IMeshBuilder mb(spec);
723 IMesh out = boolean_mesh(
725 BoolOpType::Difference,
727 [](int t) { return t < 4 ? 0 : 1; },
736 write_obj_mesh(out,
"tettet_coplanar_diff");
740 TEST(boolean_polymesh, CubeCubeStep)
742 const char *spec = R
"(16 12
773 IMeshBuilder mb(spec);
774 IMesh out = boolean_mesh(
776 BoolOpType::Difference,
778 [](int t) { return t < 6 ? 0 : 1; },
787 write_obj_mesh(out,
"cubecubestep");
791 TEST(boolean_polymesh, CubeCyl4)
793 const char *spec = R
"(16 12
824 IMeshBuilder mb(spec);
825 IMesh out = boolean_mesh(
827 BoolOpType::Difference,
829 [](int t) { return t < 6 ? 1 : 0; },
838 write_obj_mesh(out,
"cubecyl4");
842 TEST(boolean_polymesh, CubeCubesubdivDiff)
845 const char *spec = R
"(26 22
896 IMeshBuilder mb(spec);
897 IMesh out = boolean_mesh(
899 BoolOpType::Difference,
901 [](int t) { return t < 16 ? 1 : 0; },
910 write_obj_mesh(out,
"cubecubesubdivdiff");
914 TEST(boolean_polymesh, CubePlane)
916 const char *spec = R
"(12 7
938 IMeshBuilder mb(spec);
939 IMesh out = boolean_mesh(
941 BoolOpType::Difference,
943 [](int t) { return t >= 1 ? 0 : 1; },
952 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)